Skip to content

Commit bdd6cd3

Browse files
committed
RHINENG-19880: update tests for system delete event
systems are marked as stale and culled instead of being removed from database
1 parent 7c5755c commit bdd6cd3

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

listener/common_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ func assertSystemInDB(t *testing.T, inventoryID string, rhAccountID *int, report
6363
assert.True(t, system.LastUpload.After(now), "Last upload")
6464
}
6565

66-
func assertSystemNotInDB(t *testing.T) {
66+
func assertSystemStaleAndCulled(t *testing.T) {
6767
var systemCount int64
68+
now := time.Now()
6869
assert.Nil(t, database.DB.Model(models.SystemPlatform{}).
70+
Where("stale = true AND stale_timestamp < ? AND culled_timestamp < ?", now, now).
6971
Where("inventory_id = ?::uuid", id).Count(&systemCount).Error)
7072

7173
assert.Equal(t, int(systemCount), 0)

listener/events_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestDeleteSystem(t *testing.T) {
4949

5050
deleteEvent := createTestDeleteEvent(id)
5151
err := HandleDelete(deleteEvent)
52-
assertSystemNotInDB(t)
52+
assertSystemStaleAndCulled(t)
5353
assert.NoError(t, err)
5454
}
5555

@@ -107,7 +107,7 @@ func TestUploadAfterDelete(t *testing.T) {
107107
uploadEvent := createTestUploadEvent("1", id, "puptoo", true, false)
108108
err := HandleUpload(uploadEvent)
109109
assert.NoError(t, err)
110-
assertSystemNotInDB(t)
110+
assertSystemStaleAndCulled(t)
111111
}
112112

113113
func TestDeleteCleanup(t *testing.T) {

0 commit comments

Comments
 (0)