Skip to content

Commit

Permalink
Add unit test for config_diff when old or new is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
shankerwangmiao committed Apr 18, 2023
1 parent bca49ab commit 4007bb2
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions worker/config_diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ func TestConfigDiff(t *testing.T) {
difference := diffMirrorConfig(oldList, newList)
So(len(difference), ShouldEqual, 0)
})
Convey("When old config is empty", t, func() {
newList := []mirrorConfig{
mirrorConfig{Name: "debian"},
mirrorConfig{Name: "debian-security"},
mirrorConfig{Name: "fedora"},
mirrorConfig{Name: "archlinux"},
mirrorConfig{Name: "AOSP"},
mirrorConfig{Name: "ubuntu"},
}
oldList := make([]mirrorConfig, 0)

difference := diffMirrorConfig(oldList, newList)
So(len(difference), ShouldEqual, len(newList))
})
Convey("When new config is empty", t, func() {
oldList := []mirrorConfig{
mirrorConfig{Name: "debian"},
mirrorConfig{Name: "debian-security"},
mirrorConfig{Name: "fedora"},
mirrorConfig{Name: "archlinux"},
mirrorConfig{Name: "AOSP"},
mirrorConfig{Name: "ubuntu"},
}
newList := make([]mirrorConfig, 0)

difference := diffMirrorConfig(oldList, newList)
So(len(difference), ShouldEqual, len(oldList))
})
Convey("When giving two config lists with different names", t, func() {
oldList := []mirrorConfig{
mirrorConfig{Name: "debian"},
Expand Down

0 comments on commit 4007bb2

Please sign in to comment.