Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
fix: golint failure
Browse files Browse the repository at this point in the history
  • Loading branch information
autumn31 committed Feb 23, 2021
1 parent fc19f47 commit 981d489
Showing 1 changed file with 38 additions and 8 deletions.
46 changes: 38 additions & 8 deletions faker_test.go
Expand Up @@ -2017,8 +2017,18 @@ func TestRandomMaxMinMapSliceSize(t *testing.T) {
}

orimax, orimin := randomMaxSize, randomMinSize
defer SetRandomMapAndSliceMaxSize(orimax)
defer SetRandomMapAndSliceMinSize(orimin)
defer func() {
err := SetRandomMapAndSliceMaxSize(orimax)
if err != nil {
t.Fatal(err)
}
}()
defer func() {
err := SetRandomMapAndSliceMinSize(orimin)
if err != nil {
t.Fatal(err)
}
}()

for _, c := range []struct {
max, min, expect int
Expand All @@ -2027,10 +2037,19 @@ func TestRandomMaxMinMapSliceSize(t *testing.T) {
{2, 2, 2},
{2, 3, 3}, // if min >= max, result will always be min
} {
SetRandomMapAndSliceMaxSize(c.max)
SetRandomMapAndSliceMinSize(c.min)
err := SetRandomMapAndSliceMaxSize(c.max)
if err != nil {
t.Fatal(err)
}
err = SetRandomMapAndSliceMinSize(c.min)
if err != nil {
t.Fatal(err)
}
s := SliceMap{}
FakeData(&s)
err = FakeData(&s)
if err != nil {
t.Error(err)
}

if len(s.Map) != c.expect {
t.Errorf("map (len:%d) not expect length with test case %+v\n", len(s.Map), c)
Expand All @@ -2050,11 +2069,22 @@ func TestRandomMapSliceSize(t *testing.T) {
}
expect := 5
orimax := randomMaxSize
defer SetRandomMapAndSliceSize(orimax)
SetRandomMapAndSliceSize(expect)
defer func() {
err := SetRandomMapAndSliceSize(orimax)
if err != nil {
t.Fatal(err)
}
}()
err := SetRandomMapAndSliceSize(expect)
if err != nil {
t.Fatal(err)
}
for i := 0; i < 10; i++ {
s := SliceMap{}
FakeData(&s)
err := FakeData(&s)
if err != nil {
t.Error(err)
}

if len(s.Map) >= 5 {
t.Errorf("map (len:%d) is greater than expected length %d", len(s.Map), expect)
Expand Down

0 comments on commit 981d489

Please sign in to comment.