-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmain_test.go
44 lines (42 loc) · 1006 Bytes
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"testing"
)
func Test_getVersion(t *testing.T) {
tests := []struct {
testName string
prerelase string
version string
expectedResult string
}{
// Test cases
{
testName: "getVersion_WithDevPrelease_ShouldReturnVersionAndVersionPostfix",
prerelase: "dev",
version: "0.0.0",
expectedResult: "0.0.0-dev",
},
{
testName: "getVersion_WithRCPrelease_ShouldReturnVersionAndVersionPostfix",
prerelase: "rc",
version: "0.0.1",
expectedResult: "0.0.1-rc",
},
{
testName: "getVersion_WithoutPrelease_ShouldReturnVersionOnly",
prerelase: "",
version: "0.0.2",
expectedResult: "0.0.2",
},
}
for _, tt := range tests {
t.Run(tt.testName, func(t *testing.T) {
Version = tt.version
VersionPostfix = tt.prerelase
printVersion()
if Version != tt.expectedResult {
t.Errorf("getVersion() = %v, expected %v", Version, tt.expectedResult)
}
})
}
}