Skip to content

Commit 617a685

Browse files
authored
Fix and re-format test data (#467)
Different packages in the test data were sharing the same channel. It doesn't currently affect the test, but in real world this doesn't happen since channel belongs to only one package Also there was a bit strange formatting of bundle structs. Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent e846ffb commit 617a685

File tree

1 file changed

+90
-48
lines changed

1 file changed

+90
-48
lines changed

internal/controllers/operator_controller_test.go

Lines changed: 90 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,60 +1049,102 @@ func verifyConditionsInvariants(op *operatorsv1alpha1.Operator) {
10491049
}
10501050

10511051
var (
1052-
alphaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{
1053-
Name: "alpha",
1054-
}}
1055-
betaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{
1056-
Name: "beta",
1057-
}}
1052+
prometheusAlphaChannel = catalogmetadata.Channel{
1053+
Channel: declcfg.Channel{
1054+
Name: "alpha",
1055+
Package: "prometheus",
1056+
},
1057+
}
1058+
prometheusBetaChannel = catalogmetadata.Channel{
1059+
Channel: declcfg.Channel{
1060+
Name: "beta",
1061+
Package: "prometheus",
1062+
Entries: []declcfg.ChannelEntry{
1063+
{
1064+
Name: "operatorhub/prometheus/beta/0.37.0",
1065+
},
1066+
{
1067+
Name: "operatorhub/prometheus/beta/0.47.0",
1068+
Replaces: "operatorhub/prometheus/beta/0.37.0",
1069+
},
1070+
},
1071+
},
1072+
}
1073+
plainBetaChannel = catalogmetadata.Channel{
1074+
Channel: declcfg.Channel{
1075+
Name: "beta",
1076+
Package: "plain",
1077+
},
1078+
}
1079+
badmediaBetaChannel = catalogmetadata.Channel{
1080+
Channel: declcfg.Channel{
1081+
Name: "beta",
1082+
Package: "badmedia",
1083+
},
1084+
}
10581085
)
10591086

10601087
var testBundleList = []*catalogmetadata.Bundle{
1061-
{Bundle: declcfg.Bundle{
1062-
Name: "operatorhub/prometheus/alpha/0.37.0",
1063-
Package: "prometheus",
1064-
Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35",
1065-
Properties: []property.Property{
1066-
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.37.0"}`)},
1067-
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1088+
{
1089+
Bundle: declcfg.Bundle{
1090+
Name: "operatorhub/prometheus/alpha/0.37.0",
1091+
Package: "prometheus",
1092+
Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35",
1093+
Properties: []property.Property{
1094+
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.37.0"}`)},
1095+
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1096+
},
10681097
},
1069-
}, InChannels: []*catalogmetadata.Channel{&alphaChannel}},
1070-
{Bundle: declcfg.Bundle{
1071-
Name: "operatorhub/prometheus/beta/0.37.0",
1072-
Package: "prometheus",
1073-
Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35",
1074-
Properties: []property.Property{
1075-
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.37.0"}`)},
1076-
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1098+
InChannels: []*catalogmetadata.Channel{&prometheusAlphaChannel},
1099+
},
1100+
{
1101+
Bundle: declcfg.Bundle{
1102+
Name: "operatorhub/prometheus/beta/0.37.0",
1103+
Package: "prometheus",
1104+
Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35",
1105+
Properties: []property.Property{
1106+
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.37.0"}`)},
1107+
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1108+
},
10771109
},
1078-
}, InChannels: []*catalogmetadata.Channel{&betaChannel}},
1079-
{Bundle: declcfg.Bundle{
1080-
Name: "operatorhub/prometheus/beta/0.47.0",
1081-
Package: "prometheus",
1082-
Image: "quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed",
1083-
Properties: []property.Property{
1084-
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.47.0"}`)},
1085-
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1110+
InChannels: []*catalogmetadata.Channel{&prometheusBetaChannel},
1111+
},
1112+
{
1113+
Bundle: declcfg.Bundle{
1114+
Name: "operatorhub/prometheus/beta/0.47.0",
1115+
Package: "prometheus",
1116+
Image: "quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed",
1117+
Properties: []property.Property{
1118+
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.47.0"}`)},
1119+
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1120+
},
10861121
},
1087-
}, InChannels: []*catalogmetadata.Channel{&betaChannel}},
1088-
{Bundle: declcfg.Bundle{
1089-
Name: "operatorhub/plain/0.1.0",
1090-
Package: "plain",
1091-
Image: "quay.io/operatorhub/plain@sha256:plain",
1092-
Properties: []property.Property{
1093-
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"plain","version":"0.1.0"}`)},
1094-
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1095-
{Type: "olm.bundle.mediatype", Value: json.RawMessage(`"plain+v0"`)},
1122+
InChannels: []*catalogmetadata.Channel{&prometheusBetaChannel},
1123+
},
1124+
{
1125+
Bundle: declcfg.Bundle{
1126+
Name: "operatorhub/plain/0.1.0",
1127+
Package: "plain",
1128+
Image: "quay.io/operatorhub/plain@sha256:plain",
1129+
Properties: []property.Property{
1130+
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"plain","version":"0.1.0"}`)},
1131+
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1132+
{Type: "olm.bundle.mediatype", Value: json.RawMessage(`"plain+v0"`)},
1133+
},
10961134
},
1097-
}, InChannels: []*catalogmetadata.Channel{&betaChannel}},
1098-
{Bundle: declcfg.Bundle{
1099-
Name: "operatorhub/badmedia/0.1.0",
1100-
Package: "badmedia",
1101-
Image: "quay.io/operatorhub/badmedia@sha256:badmedia",
1102-
Properties: []property.Property{
1103-
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"badmedia","version":"0.1.0"}`)},
1104-
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1105-
{Type: "olm.bundle.mediatype", Value: json.RawMessage(`"badmedia+v1"`)},
1135+
InChannels: []*catalogmetadata.Channel{&plainBetaChannel},
1136+
},
1137+
{
1138+
Bundle: declcfg.Bundle{
1139+
Name: "operatorhub/badmedia/0.1.0",
1140+
Package: "badmedia",
1141+
Image: "quay.io/operatorhub/badmedia@sha256:badmedia",
1142+
Properties: []property.Property{
1143+
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"badmedia","version":"0.1.0"}`)},
1144+
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1145+
{Type: "olm.bundle.mediatype", Value: json.RawMessage(`"badmedia+v1"`)},
1146+
},
11061147
},
1107-
}, InChannels: []*catalogmetadata.Channel{&betaChannel}},
1148+
InChannels: []*catalogmetadata.Channel{&badmediaBetaChannel},
1149+
},
11081150
}

0 commit comments

Comments
 (0)