MCPcopy Index your code
hub / github.com/databus23/helm-diff / TestChangeOwnership

Function TestChangeOwnership

diff/diff_test.go:1189–1271  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1187}
1188
1189func TestChangeOwnership(t *testing.T) {
1190 ansi.DisableColors(true)
1191
1192 specOriginal := map[string]*manifest.MappingResult{
1193 "default, foobar, ConfigMap (v1)": {
1194 Name: "default, foobar, ConfigMap (v1)",
1195 Kind: "Secret",
1196 Content: `
1197apiVersion: v1
1198kind: ConfigMap
1199metadata:
1200 name: foobar
1201data:
1202 key1: value1
1203`,
1204 },
1205 }
1206
1207 t.Run("OnChangeOwnershipWithoutSpecChange", func(t *testing.T) {
1208 var buf1 bytes.Buffer
1209 diffOptions := Options{"diff", 10, false, true, false, []string{}, 0.5, []string{}} // NOTE: ShowSecrets = false
1210
1211 newOwnedReleases := map[string]OwnershipDiff{
1212 "default, foobar, ConfigMap (v1)": {
1213 OldRelease: "default/oldfoobar",
1214 NewRelease: "default/foobar",
1215 },
1216 }
1217 if changesSeen := ManifestsOwnership(specOriginal, specOriginal, newOwnedReleases, &diffOptions, &buf1); !changesSeen {
1218 t.Error("Unexpected return value from Manifests: Expected the return value to be `true` to indicate that it has seen any change(s), but was `false`")
1219 }
1220
1221 require.Equal(t, `default, foobar, ConfigMap (v1) changed ownership:
1222- default/oldfoobar
1223+ default/foobar
1224`, buf1.String())
1225 })
1226
1227 t.Run("OnChangeOwnershipWithSpecChange", func(t *testing.T) {
1228 var buf1 bytes.Buffer
1229 diffOptions := Options{"diff", 10, false, true, false, []string{}, 0.5, []string{}} // NOTE: ShowSecrets = false
1230
1231 specNew := map[string]*manifest.MappingResult{
1232 "default, foobar, ConfigMap (v1)": {
1233 Name: "default, foobar, ConfigMap (v1)",
1234 Kind: "Secret",
1235 Content: `
1236apiVersion: v1
1237kind: ConfigMap
1238metadata:
1239 name: foobar
1240data:
1241 key1: newValue1
1242`,
1243 },
1244 }
1245
1246 newOwnedReleases := map[string]OwnershipDiff{

Callers

nothing calls this directly

Calls 2

ManifestsOwnershipFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected