Skip to content

Commit

Permalink
handle review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrato authored and github-actions committed Apr 30, 2024
1 parent 430b40b commit a9065f9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/services/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func CompareResources[T any](resA, resB T) int {
cmpopts.IgnoreFields(types.UserSpecV2{}, "Status"),
cmpopts.IgnoreFields(accesslist.AccessList{}, "Status"),
cmpopts.IgnoreUnexported(headerv1.Metadata{}),
cmpopts.IgnoreFields(accesslist.AccessListMemberSpec{}, "IneligibleStatus"), /* IneligibleStatus must be ignored in comparison */
// Managed by IneligibleStatusReconciler, ignored by all others.
cmpopts.IgnoreFields(accesslist.AccessListMemberSpec{}, "IneligibleStatus"),
cmpopts.EquateEmpty(),
)
}
Expand Down
13 changes: 13 additions & 0 deletions lib/services/compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import (
"testing"

"github.com/stretchr/testify/require"

"github.com/gravitational/teleport/api/types/accesslist"
)

func TestCompareResources(t *testing.T) {
Expand All @@ -31,6 +33,17 @@ func TestCompareResources(t *testing.T) {
// These results should be forced since we're going through a custom compare function.
compareTestCase(t, "IsEqual equal", &compareResourceWithEqual{true}, &compareResourceWithEqual{false}, Equal)
compareTestCase(t, "IsEqual not equal", &compareResourceWithEqual{false}, &compareResourceWithEqual{false}, Different)

// These results compare AccessListMemberSpec, which should ignore the IneligibleStatus field.
newAccessListMemberSpec := func(ineligibleStatus, accessList string) accesslist.AccessListMemberSpec {
return accesslist.AccessListMemberSpec{
AccessList: accessList,
IneligibleStatus: ineligibleStatus,
}
}
compareTestCase(t, "cmp equal with equal IneligibleStatus", newAccessListMemberSpec("status1", "accessList1"), newAccessListMemberSpec("status1", "accessList1"), Equal)
compareTestCase(t, "cmp equal with different IneligibleStatus", newAccessListMemberSpec("status1", "accessList1"), newAccessListMemberSpec("status2", "accessList1"), Equal)
compareTestCase(t, "cmp not equal", newAccessListMemberSpec("status1", "accessList1"), newAccessListMemberSpec("status1", "accessList2"), Different)
}

func compareTestCase[T any](t *testing.T, name string, resA, resB T, expected int) {
Expand Down

0 comments on commit a9065f9

Please sign in to comment.