From 16323ae4b29277099e92a5f98506c9fc202233e0 Mon Sep 17 00:00:00 2001 From: ekarlso Date: Tue, 4 Feb 2025 21:56:28 +0100 Subject: [PATCH 1/3] Use testing.TB for UsingFlags Signed-off-by: ekarlso --- openfeature/testing/testprovider.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openfeature/testing/testprovider.go b/openfeature/testing/testprovider.go index fb42d3a3..584b9932 100644 --- a/openfeature/testing/testprovider.go +++ b/openfeature/testing/testprovider.go @@ -29,7 +29,7 @@ type TestProvider struct { } // UsingFlags sets flags for the scope of a test -func (tp TestProvider) UsingFlags(test *testing.T, flags map[string]memprovider.InMemoryFlag) { +func (tp TestProvider) UsingFlags(test testing.TB, flags map[string]memprovider.InMemoryFlag) { storeGoroutineLocal(test.Name()) tp.providers.Store(test.Name(), memprovider.NewInMemoryProvider(flags)) } From 2a4069dab42bf0ee2e6b8814d161ba7efe31a80c Mon Sep 17 00:00:00 2001 From: ekarlso Date: Tue, 4 Feb 2025 23:27:29 +0100 Subject: [PATCH 2/3] feat: loosen test instance interface to support various test frameworks (#317) Switch to `interface{ Name() string }` since testing.BB has `private` which blocks it from working. Signed-off-by: ekarlso --- openfeature/testing/testprovider.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openfeature/testing/testprovider.go b/openfeature/testing/testprovider.go index 584b9932..d36721d9 100644 --- a/openfeature/testing/testprovider.go +++ b/openfeature/testing/testprovider.go @@ -5,7 +5,6 @@ import ( "fmt" "runtime" "sync" - "testing" "github.com/open-feature/go-sdk/openfeature" "github.com/open-feature/go-sdk/openfeature/memprovider" @@ -29,7 +28,7 @@ type TestProvider struct { } // UsingFlags sets flags for the scope of a test -func (tp TestProvider) UsingFlags(test testing.TB, flags map[string]memprovider.InMemoryFlag) { +func (tp TestProvider) UsingFlags(test interface{ Name() string }, flags map[string]memprovider.InMemoryFlag) { storeGoroutineLocal(test.Name()) tp.providers.Store(test.Name(), memprovider.NewInMemoryProvider(flags)) } From e8cba5ecf82955b442d4f6dbddc4fdbd52543c2d Mon Sep 17 00:00:00 2001 From: Michael Beemer Date: Thu, 15 May 2025 13:08:47 -0400 Subject: [PATCH 3/3] Update openfeature/testing/testprovider.go Co-authored-by: Thomas Poignant Signed-off-by: Michael Beemer --- openfeature/testing/testprovider.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openfeature/testing/testprovider.go b/openfeature/testing/testprovider.go index d36721d9..551c411e 100644 --- a/openfeature/testing/testprovider.go +++ b/openfeature/testing/testprovider.go @@ -28,7 +28,9 @@ type TestProvider struct { } // UsingFlags sets flags for the scope of a test -func (tp TestProvider) UsingFlags(test interface{ Name() string }, flags map[string]memprovider.InMemoryFlag) { +type TestFramework = interface{ Name() string } + +func (tp TestProvider) UsingFlags(test TestFramework, flags map[string]memprovider.InMemoryFlag) { storeGoroutineLocal(test.Name()) tp.providers.Store(test.Name(), memprovider.NewInMemoryProvider(flags)) }