27 lines
672 B
Go
27 lines
672 B
Go
package firmwareversion
|
|||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestAtLeast(t *testing.T) {
|
||
|
|
tests := []struct {
|
||
|
|
current, minimum string
|
||
|
|
want bool
|
||
|
|
}{
|
||
|
|
{"1.2.3", "1.2.3", true},
|
||
|
|
{"v1.3.0", "1.2.9", true},
|
||
|
|
{"1.2.3", "1.2.4", false},
|
||
|
|
{"1.2.3", "1.2.3-rc.1", true},
|
||
|
|
{"1.2.3-rc.2", "1.2.3-rc.1", true},
|
||
|
|
{"1.2.3-rc.1", "1.2.3", false},
|
||
|
|
{"0.1.0-sim", "0.1.0-sim", true},
|
||
|
|
{"vendor-r2", "vendor-r2", true},
|
||
|
|
{"vendor-r3", "vendor-r2", false},
|
||
|
|
{"anything", "", true},
|
||
|
|
}
|
||
|
|
for _, test := range tests {
|
||
|
|
if got := AtLeast(test.current, test.minimum); got != test.want {
|
||
|
|
t.Errorf("AtLeast(%q,%q)=%v want %v", test.current, test.minimum, got, test.want)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|