Skip to content

Commit

Permalink
correct and enhance tests
Browse files Browse the repository at this point in the history
Signed-off-by: Kavindu Dodanduwa <[email protected]>
  • Loading branch information
Kavindu-Dodan committed Jul 17, 2023
1 parent 1573977 commit f15945a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions pkg/openfeature/testing/in_memory_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ func TestInMemoryProvider_Float(t *testing.T) {
ctx := context.Background()

t.Run("test float success", func(t *testing.T) {
evaluation := memoryProvider.FloatEvaluation(ctx, "fOne", 1.0, nil)
evaluation := memoryProvider.FloatEvaluation(ctx, "floatFlag", 1.0, nil)

if evaluation.Value != 1.0 {
t.Errorf("incorect evaluation, expected %f, got %f", 1.0, evaluation.Value)
if evaluation.Value != 1.1 {
t.Errorf("incorect evaluation, expected %f, got %f", 1.1, evaluation.Value)
}
})
}
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestInMemoryProvider_TypeMismatch(t *testing.T) {

ctx := context.Background()

t.Run("test missing flag", func(t *testing.T) {
t.Run("test type mismatch flag", func(t *testing.T) {
evaluation := memoryProvider.StringEvaluation(ctx, "boolFlag", "GoodBye", nil)

if evaluation.Value != "GoodBye" {
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestInMemoryProvider_Disabled(t *testing.T) {

ctx := context.Background()

t.Run("test missing flag", func(t *testing.T) {
t.Run("test disabled flag", func(t *testing.T) {
evaluation := memoryProvider.BooleanEvaluation(ctx, "boolFlag", false, nil)

if evaluation.Value != false {
Expand All @@ -245,3 +245,17 @@ func TestInMemoryProvider_Disabled(t *testing.T) {
}
})
}

func TestInMemoryProvider_Metadata(t *testing.T) {
memoryProvider := NewInMemoryProvider(map[string]InMemoryFlag{})

metadata := memoryProvider.Metadata()

if metadata.Name == "" {
t.Errorf("expected non-empty name for in-memory provider")
}

if metadata.Name != "InMemoryProvider" {
t.Errorf("incorrect name for in-memory provider")
}
}

0 comments on commit f15945a

Please sign in to comment.