Skip to content

Commit

Permalink
less code
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com>
  • Loading branch information
sthwang-metal committed Oct 17, 2023
1 parent 28ba094 commit 6c61616
Showing 1 changed file with 24 additions and 96 deletions.
120 changes: 24 additions & 96 deletions internal/manualhooks/hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,9 @@ func Test_LoadbalancerCreateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{lb.ID, lb.OwnerID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := lb.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := createEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, lb.ID, msg.Message().SubjectID)
assert.Equal(t, createEventType, msg.Message().EventType)
}

func Test_LoadbalancerUpdateHook(t *testing.T) {
Expand All @@ -90,15 +84,9 @@ func Test_LoadbalancerUpdateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{lb.ID, lb.OwnerID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := lb.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := updateEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, lb.ID, msg.Message().SubjectID)
assert.Equal(t, updateEventType, msg.Message().EventType)
}

func Test_LoadbalancerDeleteHook(t *testing.T) {
Expand All @@ -121,15 +109,9 @@ func Test_LoadbalancerDeleteHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{lb.OwnerID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := lb.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := deleteEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, lb.ID, msg.Message().SubjectID)
assert.Equal(t, deleteEventType, msg.Message().EventType)
}

func Test_OriginCreateHook(t *testing.T) {
Expand All @@ -154,15 +136,9 @@ func Test_OriginCreateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.ID, pool.OwnerID, lb.ID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := origin.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := createEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, origin.ID, msg.Message().SubjectID)
assert.Equal(t, createEventType, msg.Message().EventType)
}

func Test_OriginUpdateHook(t *testing.T) {
Expand All @@ -188,15 +164,9 @@ func Test_OriginUpdateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.ID, pool.OwnerID, lb.ID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := origin.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := updateEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, origin.ID, msg.Message().SubjectID)
assert.Equal(t, updateEventType, msg.Message().EventType)
}

func Test_OriginDeleteHook(t *testing.T) {
Expand All @@ -222,15 +192,9 @@ func Test_OriginDeleteHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.ID, pool.OwnerID, lb.ID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := origin.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := deleteEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, origin.ID, msg.Message().SubjectID)
assert.Equal(t, deleteEventType, msg.Message().EventType)
}

func Test_PoolCreateHook(t *testing.T) {
Expand All @@ -251,15 +215,9 @@ func Test_PoolCreateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.OwnerID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := pool.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := createEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, pool.ID, msg.Message().SubjectID)
assert.Equal(t, createEventType, msg.Message().EventType)
}

func Test_PoolUpdateHook(t *testing.T) {
Expand All @@ -285,15 +243,9 @@ func Test_PoolUpdateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.ID, pool.OwnerID, lb.ID, lb.LocationID, origin.ID, port.ID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := pool.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := updateEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, pool.ID, msg.Message().SubjectID)
assert.Equal(t, updateEventType, msg.Message().EventType)
}

func Test_PoolDeleteHook(t *testing.T) {
Expand All @@ -318,15 +270,9 @@ func Test_PoolDeleteHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.OwnerID, lb.ID, lb.LocationID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := pool.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := deleteEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, pool.ID, msg.Message().SubjectID)
assert.Equal(t, deleteEventType, msg.Message().EventType)
}

func Test_PortCreateHook(t *testing.T) {
Expand All @@ -350,15 +296,9 @@ func Test_PortCreateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.ID, pool.OwnerID, lb.ID, lb.LocationID, lb.ProviderID, lb.OwnerID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := port.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := createEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, port.ID, msg.Message().SubjectID)
assert.Equal(t, createEventType, msg.Message().EventType)
}

func Test_PortUpdateHook(t *testing.T) {
Expand All @@ -383,15 +323,9 @@ func Test_PortUpdateHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{pool.ID, pool.OwnerID, lb.ID, lb.LocationID, lb.ProviderID, lb.OwnerID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := port.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := updateEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, port.ID, msg.Message().SubjectID)
assert.Equal(t, updateEventType, msg.Message().EventType)
}

func Test_PortDeleteHook(t *testing.T) {
Expand All @@ -416,13 +350,7 @@ func Test_PortDeleteHook(t *testing.T) {
expectedAdditionalSubjectIDs := []gidx.PrefixedID{lb.OwnerID, lb.ID, lb.LocationID, lb.ProviderID}
actualAdditionalSubjectIDs := msg.Message().AdditionalSubjectIDs

expectedSubjectId := port.ID
actualSubjectId := msg.Message().SubjectID

expectedEventType := deleteEventType
actualEventType := msg.Message().EventType

assert.ElementsMatch(t, expectedAdditionalSubjectIDs, actualAdditionalSubjectIDs)
assert.Equal(t, expectedSubjectId, actualSubjectId)
assert.Equal(t, expectedEventType, actualEventType)
assert.Equal(t, port.ID, msg.Message().SubjectID)
assert.Equal(t, deleteEventType, msg.Message().EventType)
}

0 comments on commit 6c61616

Please sign in to comment.