Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #11 from neotoolkit/feat/test
Browse files Browse the repository at this point in the history
test: cleanup tests
  • Loading branch information
sashamelentyev committed Jun 26, 2022
2 parents 9084b5e + 9726bf0 commit 94b845a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
2 changes: 1 addition & 1 deletion boolean_test.go
Expand Up @@ -11,6 +11,6 @@ func TestBoolean_Boolean(t *testing.T) {
f := faker.NewFaker().Boolean()

if reflect.TypeOf(f.Boolean()).String() != "bool" {
t.Fatal("Boolean type must be bool")
t.Error("Boolean type must be bool")
}
}
28 changes: 17 additions & 11 deletions faker_test.go
Expand Up @@ -8,27 +8,30 @@ import (
)

func TestIntBetween(t *testing.T) {
t.Parallel()

f := faker.NewFaker()

tests := []struct {
for _, tc := range []struct {
name string
min int
max int
}{
{
name: "",
name: "min 1, max 100",
min: 1,
max: 100,
},
{
name: "",
name: "min 1, max 1",
min: 1,
max: 1,
},
}

for _, tc := range tests {
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

value := f.IntBetween(tc.min, tc.max)

valueType := fmt.Sprintf("%T", value)
Expand All @@ -49,7 +52,9 @@ func TestIntBetween(t *testing.T) {
}

func TestByName(t *testing.T) {
tests := []struct {
t.Parallel()

for _, tc := range []struct {
name string
faker string
}{
Expand Down Expand Up @@ -157,15 +162,16 @@ func TestByName(t *testing.T) {
name: "",
faker: "UUID",
},
}

for _, tc := range tests {
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

f := faker.NewFaker()
got := f.ByName(tc.faker)

if nil == got {
t.Fatal("faker by name is nil")
t.Error("faker by name is nil")
}
})
}
Expand Down
8 changes: 4 additions & 4 deletions internet_test.go
Expand Up @@ -11,7 +11,7 @@ func TestUsername(t *testing.T) {
username := i.Username()

if len(username) == 0 {
t.Fatal("username is empty")
t.Error("username is empty")
}
}

Expand All @@ -20,7 +20,7 @@ func TestGTLD(t *testing.T) {
gTLD := i.GTLD()

if len(gTLD) == 0 {
t.Fatal("gTLD is empty")
t.Error("GTLD is empty")
}
}

Expand All @@ -29,7 +29,7 @@ func TestDomain(t *testing.T) {
d := i.Domain()

if len(d) == 0 {
t.Fatal("domain is empty")
t.Error("domain is empty")
}
}

Expand All @@ -38,6 +38,6 @@ func TestEmail(t *testing.T) {
e := i.Email()

if len(e) == 0 {
t.Fatal("domain is empty")
t.Error("email is empty")
}
}
26 changes: 13 additions & 13 deletions person_test.go
Expand Up @@ -12,7 +12,7 @@ func TestPerson_FirstName(t *testing.T) {
firstName := f.Person().FirstName()

if len(firstName) == 0 {
t.Fatal("firstName is empty")
t.Error("firstName is empty")
}
}

Expand All @@ -22,7 +22,7 @@ func TestPerson_LastName(t *testing.T) {
lastName := p.LastName()

if len(lastName) == 0 {
t.Fatal("lastName is empty")
t.Error("lastName is empty")
}
}

Expand All @@ -31,7 +31,7 @@ func TestPerson_FirstNameMale(t *testing.T) {
firstNameMale := f.Person().FirstNameMale()

if len(firstNameMale) == 0 {
t.Fatal("firstNameMale is empty")
t.Error("firstNameMale is empty")
}
}

Expand All @@ -41,7 +41,7 @@ func TestPerson_FirstNameFemale(t *testing.T) {
firstNameFemale := p.FirstNameFemale()

if len(firstNameFemale) == 0 {
t.Fatal("firstNameFemale is empty")
t.Error("firstNameFemale is empty")
}
}

Expand All @@ -51,19 +51,19 @@ func TestPerson_Name(t *testing.T) {
name := p.Name()

if len(name) == 0 {
t.Fatal("name is empty")
t.Error("name is empty")
}

if strings.Contains(name, "{{FirstNameMale}}") {
t.Fatal("name is format")
t.Error("name is format")
}

if strings.Contains(name, "{{FirstNameFemale}}") {
t.Fatal("name is format")
t.Error("name is format")
}

if strings.Contains(name, "{{LastName}}") {
t.Fatal("name is format")
t.Error("name is format")
}
}

Expand All @@ -73,7 +73,7 @@ func TestPerson_NameMale(t *testing.T) {
nameMale := p.NameMale()

if len(nameMale) == 0 {
t.Fatal("nameMale is empty")
t.Error("nameMale is empty")
}
}

Expand All @@ -83,7 +83,7 @@ func TestPerson_NameFemale(t *testing.T) {
nameFemale := p.NameFemale()

if len(nameFemale) == 0 {
t.Fatal("nameFemale is empty")
t.Error("nameFemale is empty")
}
}

Expand All @@ -93,7 +93,7 @@ func TestPerson_Gender(t *testing.T) {
gender := p.Gender()

if !(gender == "Male" || gender == "Female") {
t.Fatal("gender must be male or female")
t.Error("gender must be male or female")
}
}

Expand All @@ -103,7 +103,7 @@ func TestPerson_GenderMale(t *testing.T) {
genderMale := p.GenderMale()

if genderMale != "Male" {
t.Fatal("genderMale must be male")
t.Error("genderMale must be male")
}
}

Expand All @@ -113,6 +113,6 @@ func TestPerson_GenderFemale(t *testing.T) {
genderFemale := p.GenderFemale()

if genderFemale != "Female" {
t.Fatal("genderFemale must be female")
t.Error("genderFemale must be female")
}
}
6 changes: 3 additions & 3 deletions uuid_test.go
Expand Up @@ -13,11 +13,11 @@ func TestUUID_v4(t *testing.T) {

match, err := regexp.MatchString("^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$", value)
if err != nil {
t.Fatal(err)
t.Error(err)
}

if !match {
t.Fatal("want true, got false")
t.Error("want true, got false")
}
}

Expand All @@ -27,6 +27,6 @@ func TestUUID_V4UniqueInSequence(t *testing.T) {
current := f.UUID().V4()

if last == current {
t.Fatal("want unique uuid")
t.Error("want unique uuid")
}
}

0 comments on commit 94b845a

Please sign in to comment.