@@ -10,6 +10,7 @@ import (
1010 "github.com/crossplane-contrib/crossplane-diff/cmd/diff/renderer"
1111 dt "github.com/crossplane-contrib/crossplane-diff/cmd/diff/renderer/types"
1212 tu "github.com/crossplane-contrib/crossplane-diff/cmd/diff/testutils"
13+ gcmp "github.com/google/go-cmp/cmp"
1314 apierrors "k8s.io/apimachinery/pkg/api/errors"
1415 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516 un "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -382,16 +383,16 @@ func TestDefaultDiffCalculator_CalculateDiff(t *testing.T) {
382383 }
383384
384385 // Check the basics of the diff
385- if diff . Gvk != tt .wantDiff .Gvk {
386- t .Errorf ("Gvk = %v, want %v " , diff . Gvk . String (), tt . wantDiff . Gvk . String () )
386+ if diff := gcmp . Diff ( tt .wantDiff .Gvk , diff . Gvk ); diff != "" {
387+ t .Errorf ("Gvk mismatch (- want +got): \n %s " , diff )
387388 }
388389
389- if diff . ResourceName != tt .wantDiff .ResourceName {
390- t .Errorf ("ResourceName = %v, want %v " , diff . ResourceName , tt . wantDiff . ResourceName )
390+ if diff := gcmp . Diff ( tt .wantDiff .ResourceName , diff . ResourceName ); diff != "" {
391+ t .Errorf ("ResourceName mismatch (- want +got): \n %s " , diff )
391392 }
392393
393- if diff . DiffType != tt .wantDiff .DiffType {
394- t .Errorf ("DiffType = %v, want %v " , diff . DiffType , tt . wantDiff . DiffType )
394+ if diff := gcmp . Diff ( tt .wantDiff .DiffType , diff . DiffType ); diff != "" {
395+ t .Errorf ("DiffType mismatch (- want +got): \n %s " , diff )
395396 }
396397
397398 // For modified resources, check that LineDiffs is populated
@@ -692,8 +693,8 @@ func TestDefaultDiffCalculator_CalculateDiffs(t *testing.T) {
692693 }
693694
694695 // Check that we have the expected number of diffs
695- if len ( diffs ) != len (tt .expectedDiffs ) {
696- t .Errorf ("CalculateDiffs() returned %d diffs, want %d " , len ( diffs ), len ( tt . expectedDiffs ) )
696+ if diff := gcmp . Diff ( len (tt .expectedDiffs ), len ( diffs )); diff != "" {
697+ t .Errorf ("CalculateDiffs() number of diffs mismatch (- want +got): \n %s " , diff )
697698
698699 // Print what diffs we actually got to help debug
699700 for key , diff := range diffs {
@@ -709,9 +710,8 @@ func TestDefaultDiffCalculator_CalculateDiffs(t *testing.T) {
709710 continue
710711 }
711712
712- if diff .DiffType != expectedType {
713- t .Errorf ("CalculateDiffs() diff for key %s has type %s, want %s" ,
714- expectedKey , diff .DiffType , expectedType )
713+ if diff := gcmp .Diff (expectedType , diff .DiffType ); diff != "" {
714+ t .Errorf ("CalculateDiffs() diff type for key %s mismatch (-want +got):\n %s" , expectedKey , diff )
715715 }
716716
717717 // Check that LineDiffs is not empty for non-nil diffs
@@ -870,9 +870,8 @@ func TestDefaultDiffCalculator_CalculateRemovedResourceDiffs(t *testing.T) {
870870 }
871871
872872 // Check that the correct resources were identified for removal
873- if len (diffs ) != len (tt .expectedRemoved ) {
874- t .Errorf ("CalculateRemovedResourceDiffs() found %d resources to remove, want %d" ,
875- len (diffs ), len (tt .expectedRemoved ))
873+ if diff := gcmp .Diff (len (tt .expectedRemoved ), len (diffs )); diff != "" {
874+ t .Errorf ("CalculateRemovedResourceDiffs() number of removed resources mismatch (-want +got):\n %s" , diff )
876875
877876 // Log what we found for debugging
878877 for key := range diffs {
0 commit comments