godev/cmd/worker: add unit test for normalizeCounterName
diff --git a/godev/cmd/worker/main_test.go b/godev/cmd/worker/main_test.go
index 352b7f2..b5af0da 100644
--- a/godev/cmd/worker/main_test.go
+++ b/godev/cmd/worker/main_test.go
@@ -504,3 +504,58 @@
t.Errorf("charts = %+v\n, (-want +got): %v", got, diff)
}
}
+
+func TestNormalizeCounterName(t *testing.T) {
+ testcases := []struct {
+ name string
+ prefix string
+ counter string
+ want string
+ }{
+ {
+ name: "strip patch version for Version",
+ prefix: "Version",
+ counter: "v0.15.3",
+ want: "Version:v0.15",
+ },
+ {
+ name: "strip patch go version for Version",
+ prefix: "Version",
+ counter: "go1.12.3",
+ want: "Version:go1.12",
+ },
+ {
+ name: "concatenate devel for Version",
+ prefix: "Version",
+ counter: "devel",
+ want: "Version:devel",
+ },
+ {
+ name: "concatenate for GOOS",
+ prefix: "GOOS",
+ counter: "darwin",
+ want: "GOOS:darwin",
+ },
+ {
+ name: "concatenate for GOARCH",
+ prefix: "GOARCH",
+ counter: "amd64",
+ want: "GOARCH:amd64",
+ },
+ {
+ name: "strip patch version for GoVersion",
+ prefix: "GoVersion",
+ counter: "go1.12.3",
+ want: "GoVersion:go1.12",
+ },
+ }
+
+ for _, tc := range testcases {
+ t.Run(tc.name, func(t *testing.T) {
+ got := normalizeCounterName(tc.prefix, tc.counter)
+ if tc.want != got {
+ t.Errorf("normalizeCounterName should return %s, got %s", tc.want, got)
+ }
+ })
+ }
+}
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Code-Review | +2 |
t.Errorf("normalizeCounterName should return %s, got %s", tc.want, got)
This should follow the following advice for test error messages:
https://google.github.io/styleguide/go/decisions#identify-the-input
https://google.github.io/styleguide/go/decisions#got-before-want
So this could be written:
```
t.Errorf("normalizeCounterName(%q, %q) = %q, want %q", tc.prefix, tc.counter, got, tc.want)
```
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Commit-Queue | +1 |
t.Errorf("normalizeCounterName should return %s, got %s", tc.want, got)
This should follow the following advice for test error messages:
https://google.github.io/styleguide/go/decisions#identify-the-input
https://google.github.io/styleguide/go/decisions#got-before-wantSo this could be written:
```
t.Errorf("normalizeCounterName(%q, %q) = %q, want %q", tc.prefix, tc.counter, got, tc.want)
```
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Run-TryBot | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Commit-Queue | +1 |
Run-TryBot | +0 |
Hongxiang JiangTryBots beginning. Status page: https://farmer.golang.org/try?commit=ab68aa4d
Acknowledged
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
Run-TryBot | +1 |
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |
godev/cmd/worker: add unit test for normalizeCounterName
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. | Gerrit |