Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static <R extends HasMetadata, P extends HasMetadata> Matcher.Result<R> m
final var kubernetesSerialization = context.getClient().getKubernetesSerialization();
var desiredNode = kubernetesSerialization.convertValue(desired, JsonNode.class);
var actualNode = kubernetesSerialization.convertValue(actualResource, JsonNode.class);
var wholeDiffJsonPatch = JsonDiff.asJson(desiredNode, actualNode);
var wholeDiffJsonPatch = JsonDiff.asJson(actualNode, desiredNode);

boolean matched = true;
for (int i = 0; i < wholeDiffJsonPatch.size() && matched; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void matchesTrivialCases() {

@Test
void matchesAdditiveOnlyChanges() {
actual.getSpec().getTemplate().getMetadata().getLabels().put("new-key", "val");
desired.getSpec().getTemplate().getMetadata().getLabels().put("new-key", "val");
assertThat(GenericKubernetesResourceMatcher.match(desired, actual, context).matched())
.withFailMessage("Additive changes should not cause a mismatch by default")
.isTrue();
Expand All @@ -61,11 +61,10 @@ void matchesWithStrongSpecEquality() {

@Test
void doesNotMatchRemovedValues() {
actual = createDeployment();
assertThat(
GenericKubernetesResourceMatcher.match(
dependentResource.desired(createPrimary("removed"), null), actual, context)
.matched())
desired = createDeployment();
actual = dependentResource.desired(createPrimary("removed"), null);

assertThat(GenericKubernetesResourceMatcher.match(desired, actual, context).matched())
.withFailMessage("Removing values in metadata should lead to a mismatch")
.isFalse();
}
Expand Down Expand Up @@ -118,7 +117,7 @@ void ignoresWholeSubPath() {

@Test
void matchesMetadata() {
actual =
desired =
new DeploymentBuilder(createDeployment())
.editOrNewMetadata()
.addToAnnotations("test", "value")
Expand All @@ -143,9 +142,10 @@ void matchesMetadata() {
void checkServiceAccount() {
final var serviceAccountDR = new ServiceAccountDR();

final var desired = serviceAccountDR.desired(null, context);
var actual =
new ServiceAccountBuilder(desired).addNewImagePullSecret("imagePullSecret3").build();
var actual = serviceAccountDR.desired(null, context);

final var desired =
new ServiceAccountBuilder(actual).addNewImagePullSecret("imagePullSecret3").build();

assertThat(
GenericKubernetesResourceMatcher.match(desired, actual, false, false, context)
Expand All @@ -155,9 +155,9 @@ void checkServiceAccount() {

@Test
void matchConfigMap() {
var desired = createConfigMap();
var actual = createConfigMap();
actual.getData().put("key2", "val2");
var desired = createConfigMap();
desired.getData().put("key2", "val2");

var match = GenericKubernetesResourceMatcher.match(desired, actual, true, false, context);
assertThat(match.matched()).isTrue();
Expand Down
Loading