Skip to content

Commit

Permalink
adds mirroring test for kv
Browse files Browse the repository at this point in the history
  • Loading branch information
grimmjo committed Feb 8, 2024
1 parent 02640e8 commit 2b8d972
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,38 @@ class KeyValueSpec extends AbstractJetstreamTest {
applicationContext.close()
}

void "mirroring key value"() {
given:
ApplicationContext context = startContext([
"nats.default.jetstream.keyvalue.m-examplebucket.storage-type": "Memory",
"nats.default.jetstream.keyvalue.m-examplebucket.mirror.name": "examplebucket",
])
KeyValueManagement kvm = context.getBean(KeyValueManagement, Qualifiers.byName(NatsConnection.DEFAULT_CONNECTION))
KeyValueHolder kvHolder = context.getBean(KeyValueHolder)

when:
kvHolder.keyValueBucket.put("hello", "world")

then:
kvHolder.mirror.get("hello").valueAsString == "world"

cleanup:
kvm.delete("examplebucket")
kvm.delete("m-examplebucket")
context.close()
}



@Requires(property = 'spec.name', value = 'KeyValueSpec')
@Singleton
static class KeyValueHolder {
@Inject
@KeyValueStore('examplebucket')
KeyValue keyValueBucket;
KeyValue keyValueBucket

@Inject
@KeyValueStore('m-examplebucket')
KeyValue mirror;
}
}

0 comments on commit 2b8d972

Please sign in to comment.