2021-09-29 15:38:50 +00:00
|
|
|
package version
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestVersion(t *testing.T) {
|
2022-01-27 12:29:49 +00:00
|
|
|
t.Parallel()
|
|
|
|
|
2021-09-29 15:38:50 +00:00
|
|
|
for give, want := range map[string]string{
|
|
|
|
// without changes
|
|
|
|
"vvv": "vvv",
|
|
|
|
"victory": "victory",
|
|
|
|
"voodoo": "voodoo",
|
|
|
|
"foo": "foo",
|
|
|
|
"0.0.0": "0.0.0",
|
|
|
|
"v": "v",
|
|
|
|
"V": "V",
|
|
|
|
|
|
|
|
// "v" prefix removal
|
|
|
|
"v0.0.0": "0.0.0",
|
|
|
|
"V0.0.0": "0.0.0",
|
|
|
|
"v1": "1",
|
|
|
|
"V1": "1",
|
|
|
|
|
|
|
|
// with spaces
|
|
|
|
" 0.0.0": "0.0.0",
|
|
|
|
"v0.0.0 ": "0.0.0",
|
|
|
|
" V0.0.0": "0.0.0",
|
|
|
|
"v1 ": "1",
|
|
|
|
" V1": "1",
|
|
|
|
"v ": "v",
|
|
|
|
} {
|
|
|
|
version = give
|
|
|
|
|
|
|
|
if v := Version(); v != want {
|
|
|
|
t.Errorf("want: %s, got: %s", want, v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|