-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix firewall auto update gets reverted. (#409)
- Loading branch information
Showing
5 changed files
with
114 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package worker | ||
|
||
import ( | ||
"github.com/google/go-cmp/cmp" | ||
"github.com/metal-stack/metal-lib/pkg/testcommon" | ||
|
||
"testing" | ||
) | ||
|
||
func Test_patchUpdate(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
old string | ||
new string | ||
want bool | ||
wantErr error | ||
}{ | ||
{ | ||
name: "no update", | ||
old: "firewall-ubuntu-3.0", | ||
new: "firewall-ubuntu-3.0", | ||
want: false, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "no update fully qualified", | ||
old: "firewall-ubuntu-3.0.20240101", | ||
new: "firewall-ubuntu-3.0.20240101", | ||
want: false, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "patch update", | ||
old: "firewall-ubuntu-3.0.20240101", | ||
new: "firewall-ubuntu-3.0.20240201", | ||
want: true, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "minor update", | ||
old: "firewall-ubuntu-3.0.20240101", | ||
new: "firewall-ubuntu-3.1.20240101", | ||
want: false, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "major update", | ||
old: "firewall-ubuntu-3.0.20240101", | ||
new: "firewall-ubuntu-4.0.20240101", | ||
want: false, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "os update", | ||
old: "firewall-ubuntu-3.0.20240101", | ||
new: "firewall-debian-3.0.20240101", | ||
want: false, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "update to fully qualified", | ||
old: "firewall-ubuntu-3.0", | ||
new: "firewall-ubuntu-3.0.20240101", | ||
want: true, | ||
wantErr: nil, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got, err := patchUpdate(tt.old, tt.new) | ||
if diff := cmp.Diff(tt.wantErr, err, testcommon.ErrorStringComparer()); diff != "" { | ||
t.Errorf("error diff (+got -want):\n %s", diff) | ||
} | ||
|
||
if diff := cmp.Diff(got, tt.want, testcommon.StrFmtDateComparer()); diff != "" { | ||
t.Errorf("diff (+got -want):\n %s", diff) | ||
} | ||
}) | ||
} | ||
} |