chore: add more tests (#3006)

This commit is contained in:
Kevin Wan
2023-03-10 17:36:39 +08:00
committed by GitHub
parent 7a0c04bc21
commit 3a493cd6a6
25 changed files with 66 additions and 28 deletions

View File

@@ -15,8 +15,10 @@ func TestCompareVersions(t *testing.T) {
out bool
}{
{"1", "1.0.1", ">", false},
{"1.0.1", "1.0", "<", false},
{"1", "0.9.9", ">", true},
{"1", "1.0-1", "<", true},
{"1", "1.0-1", "!", false},
{"1.0.1", "1-0.1", "<", false},
{"1.0.1", "1.0.1", "==", true},
{"1.0.1", "1.0.2", "==", false},
@@ -37,3 +39,21 @@ func TestCompareVersions(t *testing.T) {
})
}
}
func TestStrsToInts(t *testing.T) {
testCases := []struct {
input []string
expected []int64
}{
{[]string{}, nil},
{[]string{"1", "2", "3"}, []int64{1, 2, 3}},
}
for _, tc := range testCases {
tc := tc
t.Run("", func(t *testing.T) {
actual := strsToInts(tc.input)
assert.Equal(t, tc.expected, actual)
})
}
}