Skip to content

Commit

Permalink
fix: tests with more than one -
Browse files Browse the repository at this point in the history
fix failing tests with more then one `-`
  • Loading branch information
rodneyosodo committed Nov 23, 2023
1 parent a598159 commit 882f0a0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,18 @@ func test(t *testing.T, name, prefix, suffix string, firstNames, secondNames []s
}
name = strings.TrimSuffix(name, suffix)

if strings.Contains(name, "-") {
if !contains(firstNames, strings.Split(name, "-")[0]) {
t.Errorf("Generated name '%s' is not contained in the list of first names", name)
}
if strings.Count(name, "-") == 1 {

Check failure on line 168 in generator_test.go

View workflow job for this annotation

GitHub Actions / testing

`if strings.Count(name, "-") == 1` has complex nested blocks (complexity: 6) (nestif)
if strings.Contains(name, "-") {
if !contains(firstNames, strings.Split(name, "-")[0]) {
t.Errorf("Generated name '%s' is not contained in the list of first names", name)
}

if !contains(secondNames, strings.Split(name, "-")[1]) {
t.Errorf("Generated name '%s' is not contained in the list of second names", name)
if !contains(secondNames, strings.Split(name, "-")[1]) {
t.Errorf("Generated name '%s' is not contained in the list of second names", name)
}
} else {
t.Errorf("Expected a name does not contain a family name separator, got %s", name)
}
} else {
t.Errorf("Expected a name does not contain a family name separator, got %s", name)
}
}

Expand Down

0 comments on commit 882f0a0

Please sign in to comment.