-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: add list caches API #35
Conversation
src/androidInstrumentedTest/kotlin/software/momento/kotlin/sdk/CacheClientControlTest.kt
Show resolved
Hide resolved
@@ -0,0 +1,18 @@ | |||
package software.momento.kotlin.sdk.responses.cache.control | |||
/** Information about a cache. */ | |||
public class CacheInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be a data class, and name
can be a public val
so it doesn't need a getter.
src/commonMain/kotlin/software/momento/kotlin/sdk/responses/cache/control/CacheInfo.kt
Outdated
Show resolved
Hide resolved
* copy of the message of the cause. | ||
*/ | ||
public class Error | ||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this comment so it matches the formatting of the other Error responses.
/** Response for a list caches operation. */ | ||
public sealed interface CacheListResponse { | ||
/** A successful list caches operation. Contains the discovered caches. */ | ||
public class Success(caches: List<CacheInfo>) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be a data class with caches
as a public val
. The internal field, init block, and getter can be removed. I think IntelliJ can autogenerate an equals and hashCode to properly do a list comparison.
src/jvmTest/kotlin/software/momento/kotlin/sdk/CacheClientControlTest.kt
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor test issues. Looks good otherwise.
val cacheNames = caches.map { it.name } | ||
assert(cacheNames.contains(cacheName)) | ||
|
||
var deleteResponse = cacheClient.deleteCache(cacheName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you do this in a finally block? The cache won't be deleted if there is a transient error with list caches.
assert(listCachesResponse is CacheListResponse.Success) | ||
|
||
val caches = (listCachesResponse as CacheListResponse.Success).caches | ||
assertTrue(caches.size > 1, "There should be exactly 2 caches in the response") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the assertion is correct, but we don't know that there will be only two caches.
val cacheNames = caches.map { it.name } | ||
assertTrue(cacheName in cacheNames, "$cacheName should be one of the cache names") | ||
|
||
var deleteResponse = cacheClient.deleteCache(cacheName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be in a finally as well.
Added list caches API