Skip to content

Commit

Permalink
operator: update TestIsMachineConfigPoolConfigurationValid to check o…
Browse files Browse the repository at this point in the history
…sImageURL
  • Loading branch information
kikisdeliveryservice committed May 24, 2021
1 parent db4ca30 commit e46e92e
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion pkg/operator/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
tests := []struct {
knownConfigs []config
source []string
testurl string
generated string

err error
Expand All @@ -43,13 +44,15 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
}, {
knownConfigs: nil,
source: []string{"c-0", "u-0"},
testurl: "myurl",
generated: "g",
err: configNotFound,
}, {
knownConfigs: []config{{
name: "g",
}},
source: []string{"c-0", "u-0"},
testurl: "myurl",
generated: "g",
err: errors.New("g must be created by controller version v2: <unknown>"),
}, {
Expand All @@ -58,6 +61,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
version: "v1",
}},
source: []string{"c-0", "u-0"},
testurl: "myurl",
generated: "g",
err: errors.New("controller version mismatch for g expected v2 has v1: <unknown>"),
}, {
Expand All @@ -71,6 +75,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
name: "u-0",
}},
source: []string{"c-0", "u-0"},
testurl: "myurl",
generated: "g",
err: errors.New("controller version mismatch for c-0 expected v2 has v1: <unknown>"),
}, {
Expand All @@ -84,8 +89,23 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
name: "u-0",
}},
source: []string{"c-0", "u-0"},
testurl: "myurl",
generated: "g",
err: nil,
}, {
knownConfigs: []config{{
name: "g",
version: "v2",
}, {
name: "c-0",
version: "v2",
}, {
name: "u-0",
}},
source: []string{"c-0", "u-0"},
testurl: "wrongurl",
generated: "g",
err: errors.New("osImageURL mismatch for dummy-pool in g expected: myurl got: wrongurl"),
}}

for idx, test := range tests {
Expand All @@ -102,6 +122,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
Name: c.name,
Annotations: annos,
},
Spec: mcfgv1.MachineConfigSpec{OSImageURL: test.testurl},
}, nil
}
}
Expand All @@ -123,7 +144,7 @@ func TestIsMachineConfigPoolConfigurationValid(t *testing.T) {
Status: mcfgv1.MachineConfigPoolStatus{
Configuration: mcfgv1.MachineConfigPoolStatusConfiguration{ObjectReference: corev1.ObjectReference{Name: test.generated}, Source: source},
},
}, "v2", getter)
}, "v2", "myurl", getter)
if !reflect.DeepEqual(err, test.err) {
t.Fatalf("expected %v got %v", test.err, err)
}
Expand Down

0 comments on commit e46e92e

Please sign in to comment.