Skip to content

Commit

Permalink
Merge pull request #75 from sashamelentyev/refactor/test
Browse files Browse the repository at this point in the history
refactor: set flags in loop
  • Loading branch information
sashamelentyev authored Sep 18, 2022
2 parents 4b5afe2 + 5cbf4b6 commit 997770b
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions pkg/analyzer/analyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,22 @@ import (
)

func TestUseStdlibVars(t *testing.T) {
a := analyzer.New()

for _, flag := range []string{
analyzer.TimeWeekdayFlag,
analyzer.TimeMonthFlag,
analyzer.TimeLayoutFlag,
analyzer.CryptoHashFlag,
analyzer.RPCDefaultPathFlag,
analyzer.OSDevNullFlag,
analyzer.SQLIsolationLevelFlag,
analyzer.TLSSignatureSchemeFlag,
analyzer.ConstantKindFlag,
} {
mustNil(t, a.Flags.Set(flag, "true"))
}

pkgs := []string{
"a/crypto",
"a/http",
Expand All @@ -20,24 +36,13 @@ func TestUseStdlibVars(t *testing.T) {
"a/constant",
}

a := analyzer.New()

mustNil(t, a.Flags.Set(analyzer.TimeWeekdayFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.TimeMonthFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.TimeLayoutFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.CryptoHashFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.RPCDefaultPathFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.OSDevNullFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.SQLIsolationLevelFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.TLSSignatureSchemeFlag, "true"))
mustNil(t, a.Flags.Set(analyzer.ConstantKindFlag, "true"))

analysistest.Run(t, analysistest.TestData(), a, pkgs...)
}

func mustNil(t *testing.T, err error) {
t.Helper()

if err != nil {
t.Error(err)
t.Fatal(err)
}
}

0 comments on commit 997770b

Please sign in to comment.