mirror of https://github.com/kubernetes/kops.git
add unit test for func IsGTE
Signed-off-by: ZouYu <zouy.fnst@cn.fujitsu.com>
This commit is contained in:
parent
123b640bde
commit
eaf317d439
|
|
@ -16,7 +16,9 @@ limitations under the License.
|
|||
|
||||
package k8sversion
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
grid := []struct {
|
||||
|
|
@ -55,3 +57,54 @@ func TestParse(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGTE(t *testing.T) {
|
||||
kv, _ := Parse("1.6.2-alpha.1+ea69570f61af8e")
|
||||
cases := []struct {
|
||||
Name string
|
||||
Version string
|
||||
Expected bool
|
||||
}{
|
||||
{
|
||||
Name: "KV greater than Version",
|
||||
Version: "1.4.0",
|
||||
Expected: true,
|
||||
},
|
||||
{
|
||||
Name: "KV greater than Version",
|
||||
Version: "1.4.0-alpha.1",
|
||||
Expected: true,
|
||||
},
|
||||
|
||||
{
|
||||
Name: "KV equal Version",
|
||||
Version: "1.6.2",
|
||||
Expected: true,
|
||||
},
|
||||
{
|
||||
Name: "KV equal Version",
|
||||
Version: "1.6.2-alpha.1+ea69570f61af8e",
|
||||
Expected: true,
|
||||
},
|
||||
|
||||
{
|
||||
Name: "Version greater than KV",
|
||||
Version: "1.6.5",
|
||||
Expected: false,
|
||||
},
|
||||
{
|
||||
Name: "KV equal Version",
|
||||
Version: "1.6.5+ea69570f61af8e",
|
||||
Expected: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
ret := kv.IsGTE(c.Version)
|
||||
if c.Expected != ret {
|
||||
t.Errorf("Expected: %v, Got: %v", c.Expected, ret)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue