prysm-pulse/tools/nogo_config/config_exclusion_test.go
Preston Van Loon f537a98fcd
Add staticchecks to bazel builds (#13298)
* Update staticcheck to latest

* Add static checks while ignoring for third party / external stuff

* Added a hack to keep go mod happy.

* disable SA2002

* Pin go mod tidy checker image to golang:1.20-alpine
2023-12-08 05:42:55 +00:00

30 lines
935 B
Go

package main
import "testing"
func TestAddExclusion(t *testing.T) {
cfg := Configs{
"foo": Config{},
}
cfg.AddExclusion("sa0000", []string{"foo.go", "bar.go"})
if len(cfg["sa0000"].ExcludeFiles) != 2 {
t.Errorf("Expected 2 exclusions, got %d", len(cfg["sa0000"].ExcludeFiles))
}
if cfg["sa0000"].ExcludeFiles["foo.go"] != exclusionMessage {
t.Errorf("Expected exclusion message, got %s", cfg["sa0000"].ExcludeFiles["foo.go"])
}
if cfg["sa0000"].ExcludeFiles["bar.go"] != exclusionMessage {
t.Errorf("Expected exclusion message, got %s", cfg["sa0000"].ExcludeFiles["bar.go"])
}
cfg.AddExclusion("sa0000", []string{"foo.go", "baz.go"})
if len(cfg["sa0000"].ExcludeFiles) != 3 {
t.Errorf("Expected 3 exclusions, got %d", len(cfg["sa0000"].ExcludeFiles))
}
if cfg["sa0000"].ExcludeFiles["baz.go"] != exclusionMessage {
t.Errorf("Expected exclusion message, got %s", cfg["sa0000"].ExcludeFiles["baz.go"])
}
}