test: consolidate Go tests (#39962)

Consolidate all Go tests. Coverage is identical to before. Go tests are
around 5% faster while being 7% smaller. No non-test code is touched.
This commit is contained in:
silverwind authored and GitHub committed 2026-10-24 13:48:19 +00:00
1 parent ce7364e215
commit 8abda62312
388 files changed
+18410 -29561

No files matched your search

+1 -7
View File
@@ -48,7 +48,7 @@ func TestComplexity_Generate(t *testing.T) {
const maxCount = 50
const pwdLen = 50
test := func(t *testing.T, modes []string) {
for _, modes := range [][]string{{"lower"}, {"upper"}, {"lower", "upper", "spec"}, {"off"}, {""}} {
testComplextity(modes)
for range maxCount {
pwd, err := Generate(pwdLen)
@@ -58,12 +58,6 @@ func TestComplexity_Generate(t *testing.T) {
}
}
test(t, []string{"lower"})
test(t, []string{"upper"})
test(t, []string{"lower", "upper", "spec"})
test(t, []string{"off"})
test(t, []string{""})
// Remove settings for other tests
testComplextity([]string{"off"})
}
+15 -19
View File
@@ -47,25 +47,21 @@ func TestPassword(t *testing.T) {
assert.ErrorContains(t, err, "password cannot be empty")
assert.EqualValues(t, -1, count)
count, err = client.CheckPassword(ctx, "pwned", false)
assert.NoError(t, err)
assert.EqualValues(t, 1, count)
count, err = client.CheckPassword(ctx, "notpwned", false)
assert.NoError(t, err)
assert.EqualValues(t, 0, count)
count, err = client.CheckPassword(ctx, "paddedpwned", true)
assert.NoError(t, err)
assert.EqualValues(t, 1, count)
count, err = client.CheckPassword(ctx, "paddednotpwned", true)
assert.NoError(t, err)
assert.EqualValues(t, 0, count)
count, err = client.CheckPassword(ctx, "paddednotpwnedzero", true)
assert.NoError(t, err)
assert.EqualValues(t, 0, count)
for _, test := range []struct {
password string
padding bool
count int
}{
{"pwned", false, 1},
{"notpwned", false, 0},
{"paddedpwned", true, 1},
{"paddednotpwned", true, 0},
{"paddednotpwnedzero", true, 0},
} {
count, err = client.CheckPassword(ctx, test.password, test.padding)
assert.NoError(t, err)
assert.EqualValues(t, test.count, count)
}
count, err = client.CheckPassword(ctx, "ratelimited", false)
assert.Error(t, err)