Skip to content

Commit

Permalink
Fixed remaining violations of GoReport
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswdr committed Oct 8, 2020
1 parent 24ae463 commit 9f11a1f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions faker.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (f Faker) Int32() int32 {
return int32(f.Int())
}

// IntBetween returns a fake Int between a given minumum and maximum values for Faker
// IntBetween returns a fake Int between a given minimum and maximum values for Faker
func (f Faker) IntBetween(min, max int) int {
diff := max - min

Expand Down Expand Up @@ -275,7 +275,7 @@ func New() (f Faker) {
return
}

// New returns a new instance of Faker instance with a given seed
// NewWithSeed returns a new instance of Faker instance with a given seed
func NewWithSeed(src rand.Source) (f Faker) {
generator := rand.New(src)
f = Faker{Generator: generator}
Expand Down
5 changes: 2 additions & 3 deletions youtube.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

const charset = "abcdefghijklmnopqrstuvwxyz" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
const VideoLength = 11

// YouTube is a faker struct for YouTube
type YouTube struct {
Expand All @@ -16,7 +15,7 @@ type YouTube struct {

// GenerateVideoID returns a youtube video id
func (y YouTube) GenerateVideoID() (videoID string) {
b := make([]byte, VideoLength)
b := make([]byte, 11)
for i := range b {
b[i] = charset[rand.Intn(len(charset))]
}
Expand All @@ -33,7 +32,7 @@ func (y YouTube) GenerateShareURL() string {
return fmt.Sprintf("youtu.be/%s", y.GenerateVideoID())
}

// GenerateEmbededURL returns a fake embeded youtube video url
// GenerateEmbededURL returns a fake embedded youtube video url
func (y YouTube) GenerateEmbededURL() string {
return fmt.Sprintf("www.youtube.com/embed/%s", y.GenerateVideoID())
}
8 changes: 4 additions & 4 deletions youtube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import (

func TestGenerateVideoID(t *testing.T) {
y := New().YouTube()
Expect(t, VideoLength, len(y.GenerateVideoID()))
Expect(t, 11, len(y.GenerateVideoID()))
}

func TestGenerateFullURL(t *testing.T) {
y := New().YouTube()
split := strings.Split(y.GenerateFullURL(), "v=")
Expect(t, "www.youtube.com/watch?", split[0])
Expect(t, VideoLength, len(split[1]))
Expect(t, 11, len(split[1]))
}

func TestGenerateShareURL(t *testing.T) {
y := New().YouTube()
split := strings.Split(y.GenerateShareURL(), "/")
Expect(t, "youtu.be", split[0])
Expect(t, VideoLength, len(split[1]))
Expect(t, 11, len(split[1]))
}

func TestGenerateEmbededURL(t *testing.T) {
y := New().YouTube()
split := strings.Split(y.GenerateEmbededURL(), "embed/")
Expect(t, "www.youtube.com/", split[0])
Expect(t, VideoLength, len(split[1]))
Expect(t, 11, len(split[1]))
}

0 comments on commit 9f11a1f

Please sign in to comment.