public async Task FolderKeysAreIgnoredWhenObservedViaKeysRecursive() { List <KeyRecursiveObservation> observations = new List <KeyRecursiveObservation>(); _observableConsul.ObserveKeyRecursive("apps/myapp").Subscribe(o => { observations.Add(o); }); await _consulClient.CompleteListAsync("apps/myapp", new QueryResult <KVPair[]> { StatusCode = HttpStatusCode.OK, Response = new KVPair[] { new KVPair("apps/myapp/folder") { Value = null }, new KVPair("apps/myapp/folder/key1") { Value = Encoding.UTF8.GetBytes("val1") }, } }); observations.Should().HaveCount(1); var kvNodes = observations[0].ToKeyValueNodes(); kvNodes.Should().HaveCount(1); kvNodes.Should().ContainSingle(n => n.FullKey == "apps/myapp/folder/key1").Which.Value.Should().Be("val1"); }
private async Task CompleteListAsync(string keyPrefix, QueryResult <KVPair[]> result) { await Task.WhenAll( _consulStateObservations.WaitForAddAsync(), _consulClient.CompleteListAsync(keyPrefix, result) ); }
public async Task SettingsSuccessfullyRetrievedFromConsulAreCachedInLocalCache() { var configProvider = (ConsulConfigurationProvider)_configSource.Build(_consul); await Task.WhenAll(configProvider.LoadAsync(), _consulClient.CompleteListAsync("apps/myapp", new QueryResult <KVPair[]> { StatusCode = HttpStatusCode.OK, Response = _successfulValues })); _cache.CachedSettings.Should().NotBeNull(); _cache.CachedSettings.Should().NotBeEmpty(); _cache.CachedSettings.Should().Contain("consul:folder1:item1", "value1"); _cache.CachedSettings.Should().Contain("consul:folder1:item2", "value2"); _cache.CachedSettings.Should().Contain("consul:folder2:item1", "value3"); }