Skip to content

Commit

Permalink
fix(redis): get num marked resources uses correct call (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns authored Nov 7, 2018
1 parent 8e654cb commit 30d25a3
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RedisResourceTrackingRepository(

override fun getNumMarkedResources(): Long {
return redisClientDelegate.withCommandsClient<Long> { client ->
client.hlen(DELETE_KEY)
client.zcard(DELETE_KEY)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,44 @@ object RedisResourceTrackingRepositoryTest {
result.size shouldMatch equalTo(1)
}
}

@Test
fun `fetch num resources should work`() {
val configuration = WorkConfiguration(
namespace = "configId",
account = SpinnakerAccount(
name = "test",
accountId = "id",
type = "type",
edda = "",
regions = emptyList(),
eddaEnabled = false,
environment = "test"
),
location = "us-east-1",
cloudProvider = AWS,
resourceType = "testResourceType",
retention = 14,
softDelete = SoftDelete(),
exclusions = emptyList(),
maxAge = 1
)

val markedResource = MarkedResource(
resource = TestResource("marked resourceHash due for deletion now"),
summaries = listOf(Summary("invalid resourceHash 1", "rule 1")),
namespace = configuration.namespace,
projectedDeletionStamp = 0,
projectedSoftDeletionStamp = 0,
notificationInfo = NotificationInfo(
recipient = "yolo@netflixcom",
notificationType = "Email",
notificationStamp = clock.instant().toEpochMilli()
)
)

resourceRepository.upsert(markedResource)

resourceRepository.getNumMarkedResources() shouldMatch equalTo(1L)
}
}

0 comments on commit 30d25a3

Please sign in to comment.