Skip to content

Commit e01b2d8

Browse files
askptweyert
authored andcommitted
test: Fix flagd test shutdown (open-feature#404)
Signed-off-by: André Silva <2493377+askpt@users.noreply.github.com> Signed-off-by: Weyert de Boer <weyert@innerfuse.biz>
1 parent b8df337 commit e01b2d8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/OpenFeature.Contrib.Providers.Flagd.Test/FlagdProviderTest.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ public async Task TestResolveBooleanValueAsync()
205205
var val = await flagdProvider.ResolveBooleanValueAsync("my-key", false);
206206

207207
Assert.True(val.Value);
208+
209+
await flagdProvider.ShutdownAsync();
208210
}
209211

210212
[Fact]
@@ -231,6 +233,8 @@ public async Task TestResolveStringValue()
231233
var val = await flagdProvider.ResolveStringValueAsync("my-key", "");
232234

233235
Assert.Equal("my-value", val.Value);
236+
237+
await flagdProvider.ShutdownAsync();
234238
}
235239

236240
[Fact]
@@ -258,6 +262,8 @@ public async Task TestResolveIntegerValue()
258262
var val = await flagdProvider.ResolveIntegerValueAsync("my-key", 0);
259263

260264
Assert.Equal(10, val.Value);
265+
266+
await flagdProvider.ShutdownAsync();
261267
}
262268

263269
[Fact]
@@ -285,6 +291,8 @@ public async Task TestResolveDoubleValue()
285291
var val = await flagdProvider.ResolveDoubleValueAsync("my-key", 0.0);
286292

287293
Assert.Equal(10.0, val.Value);
294+
295+
await flagdProvider.ShutdownAsync();
288296
}
289297

290298
[Fact]
@@ -315,6 +323,8 @@ public async Task TestResolveStructureValue()
315323
var val = await flagdProvider.ResolveStructureValueAsync("my-key", null);
316324

317325
Assert.True(val.Value.AsStructure.ContainsKey("my-key"));
326+
327+
await flagdProvider.ShutdownAsync();
318328
}
319329

320330
[Fact]
@@ -347,6 +357,8 @@ public async Task TestResolveFlagNotFound()
347357
Assert.Equal(ErrorType.FlagNotFound, ex.ErrorType);
348358
Assert.Equal(ErrorType.FlagNotFound.ToString(), ex.Message);
349359
});
360+
361+
await flagdProvider.ShutdownAsync();
350362
}
351363

352364
[Fact]
@@ -380,6 +392,8 @@ public async Task TestResolveGrpcHostUnavailable()
380392
Assert.Equal(ErrorType.ProviderNotReady, ex.ErrorType);
381393
Assert.Equal(ErrorType.ProviderNotReady.ToString(), ex.Message);
382394
});
395+
396+
await flagdProvider.ShutdownAsync();
383397
}
384398

385399
[Fact]
@@ -413,6 +427,8 @@ public async Task TestResolveTypeMismatch()
413427
Assert.Equal(ErrorType.TypeMismatch, ex.ErrorType);
414428
Assert.Equal(ErrorType.TypeMismatch.ToString(), ex.Message);
415429
});
430+
431+
await flagdProvider.ShutdownAsync();
416432
}
417433

418434
[Fact]
@@ -446,6 +462,8 @@ public async Task TestResolveUnknownError()
446462
Assert.Equal(ErrorType.General, ex.ErrorType);
447463
Assert.Equal(ErrorType.General.ToString(), ex.Message);
448464
});
465+
466+
await flagdProvider.ShutdownAsync();
449467
}
450468

451469
[Fact]
@@ -523,6 +541,8 @@ public async Task TestCacheAsync()
523541
mockCache.Received(1).TryGet(Arg.Is<string>(s => s == "my-key"));
524542
mockCache.Received(1).Add(Arg.Is<string>(s => s == "my-key"), Arg.Any<object>());
525543
mockGrpcClient.Received(Quantity.AtLeastOne()).EventStream(Arg.Any<EventStreamRequest>(), null, null, CancellationToken.None);
544+
545+
await flagdProvider.ShutdownAsync();
526546
}
527547

528548
[Fact]
@@ -587,6 +607,8 @@ public async Task TestCacheHitAsync()
587607
Assert.True(_autoResetEvent.WaitOne(10000));
588608
mockCache.Received(1).TryGet("my-key");
589609
mockGrpcClient.Received(Quantity.AtLeastOne()).EventStream(Arg.Any<EventStreamRequest>(), null, null, CancellationToken.None);
610+
611+
await flagdProvider.ShutdownAsync();
590612
}
591613

592614
[Fact]
@@ -691,6 +713,8 @@ public async Task TestCacheInvalidationAsync()
691713
mockCache.Received(2).Add("my-key", Arg.Any<object>());
692714
mockCache.Received().Delete("my-key");
693715
mockGrpcClient.Received(Quantity.AtLeastOne()).EventStream(Arg.Any<EventStreamRequest>(), null, null, CancellationToken.None);
716+
717+
await flagdProvider.ShutdownAsync();
694718
}
695719

696720
[Fact]
@@ -749,6 +773,8 @@ await Utils.AssertUntilAsync(
749773
});
750774

751775
mockGrpcClient.Received(Quantity.AtLeastOne()).SyncFlags(Arg.Is<SyncFlagsRequest>(req => req.Selector == "source-selector"), null, null, CancellationToken.None);
776+
777+
await flagdProvider.ShutdownAsync();
752778
}
753779

754780
[Fact]
@@ -807,5 +833,7 @@ await Utils.AssertUntilAsync(
807833
});
808834

809835
mockGrpcClient.Received(Quantity.AtLeastOne()).SyncFlags(Arg.Is<SyncFlagsRequest>(req => req.Selector == "source-selector"), null, null, CancellationToken.None);
836+
837+
await flagdProvider.ShutdownAsync();
810838
}
811839
}

0 commit comments

Comments
 (0)