fixed bug in version checking
parent
7b91a7a19f
commit
45fb1bf2ca
|
@ -132,12 +132,10 @@ func ShouldUpdate(current *types.Version, new *types.Version, policy types.Polic
|
|||
}
|
||||
|
||||
switch policy {
|
||||
case types.PolicyTypeAll:
|
||||
case types.PolicyTypeAll, types.PolicyTypeMajor:
|
||||
return true, nil
|
||||
case types.PolicyTypeMajor:
|
||||
return newVersion.Major() > currentVersion.Major(), nil
|
||||
case types.PolicyTypeMinor:
|
||||
return newVersion.Major() == currentVersion.Major() && newVersion.Minor() > currentVersion.Minor(), nil
|
||||
return newVersion.Major() == currentVersion.Major(), nil
|
||||
case types.PolicyTypePatch:
|
||||
return newVersion.Major() == currentVersion.Major() && newVersion.Minor() == currentVersion.Minor() && newVersion.Patch() > currentVersion.Patch(), nil
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ func TestShouldUpdate(t *testing.T) {
|
|||
new: &types.Version{Major: 1, Minor: 5, Patch: 5},
|
||||
policy: types.PolicyTypeMajor,
|
||||
},
|
||||
want: false,
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
|
@ -162,6 +162,26 @@ func TestShouldUpdate(t *testing.T) {
|
|||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "patch increase, policy minor",
|
||||
args: args{
|
||||
current: &types.Version{Major: 1, Minor: 4, Patch: 5},
|
||||
new: &types.Version{Major: 1, Minor: 4, Patch: 6},
|
||||
policy: types.PolicyTypeMinor,
|
||||
},
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "patch increase, policy ptach",
|
||||
args: args{
|
||||
current: &types.Version{Major: 1, Minor: 4, Patch: 5},
|
||||
new: &types.Version{Major: 1, Minor: 4, Patch: 6},
|
||||
policy: types.PolicyTypePatch,
|
||||
},
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue