test: pin compatiliby check tests
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
knoflook 2021-11-01 10:48:47 +01:00
parent 7586abc3ca
commit b3072cb5e2
Signed by: knoflook
GPG Key ID: D6A1D0E8FC4FEF1C
1 changed files with 46 additions and 0 deletions

View File

@ -886,6 +886,52 @@ func TestDeltaString(t *testing.T) {
}
}
func TestIsUpgradeCompatible(t *testing.T) {
testsTrue := [][]string{
{"22-fpm", "22-fpm"},
{"22-fpm", "22.0-fpm"},
{"22-fpm", "22.0.0-fpm"},
{"22-fpm", "22.2.0-fpm"},
{"22-fpm", "22.0.0-fpm"},
{"22.2-fpm", "22.2-fpm"},
{"22.2-fpm", "22.2.0-fpm"},
{"22.2.2-fpm", "22.2.2-fpm"},
}
testsFalse := [][]string{
{"22-fpm", "22-alpine"},
{"22-fpm", "23-fpm"},
{"22-fpm", "21-fpm"},
{"22.2-fpm", "22.0.2-fpm"},
{"22.2.0-fpm", "22.2.2-fpm"},
}
for _, test := range testsTrue {
pin, err := tagcmp.Parse(test[0])
if err != nil {
t.Error(err)
}
upTag, err := tagcmp.Parse(test[1])
if err != nil {
t.Error(err)
}
if !pin.IsUpgradeCompatible(upTag) {
t.Errorf("pin %s should be upgradable to %s but returned false", test[0], test[1])
}
}
for _, test := range testsFalse {
pin, err := tagcmp.Parse(test[0])
if err != nil {
t.Error(err)
}
upTag, err := tagcmp.Parse(test[1])
if err != nil {
t.Error(err)
}
if pin.IsUpgradeCompatible(upTag) {
t.Errorf("pin %s should not be upgradable to %s but returned true", test[0], test[1])
}
}
}
func TestUpgradeDelta(t *testing.T) {
pairs := []struct {
t1 string