forked from open-feature/flagd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: remove protobuf dependency from eval package (open-feature#701
) Signed-off-by: James Milligan <[email protected]>
- Loading branch information
1 parent
56df71a
commit 34ffafd
Showing
12 changed files
with
161 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
"github.com/open-feature/flagd/core/pkg/logger" | ||
"github.com/open-feature/flagd/core/pkg/model" | ||
"github.com/open-feature/flagd/core/pkg/store" | ||
"google.golang.org/protobuf/types/known/structpb" | ||
) | ||
|
||
func TestFractionalEvaluation(t *testing.T) { | ||
|
@@ -58,7 +57,7 @@ func TestFractionalEvaluation(t *testing.T) { | |
tests := map[string]struct { | ||
flags Flags | ||
flagKey string | ||
context *structpb.Struct | ||
context map[string]any | ||
expectedValue string | ||
expectedVariant string | ||
expectedReason string | ||
|
@@ -67,47 +66,39 @@ func TestFractionalEvaluation(t *testing.T) { | |
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "yellow", | ||
expectedValue: "#FFFF00", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "blue", | ||
expectedValue: "#0000FF", | ||
expectedReason: model.TargetingMatchReason, | ||
|
@@ -154,11 +145,9 @@ func TestFractionalEvaluation(t *testing.T) { | |
}, | ||
}, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.TargetingMatchReason, | ||
|
@@ -200,7 +189,7 @@ func TestFractionalEvaluation(t *testing.T) { | |
}, | ||
}, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{}, | ||
context: map[string]any{}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.DefaultReason, | ||
|
@@ -230,11 +219,9 @@ func TestFractionalEvaluation(t *testing.T) { | |
}, | ||
}, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.DefaultReason, | ||
|
@@ -268,11 +255,9 @@ func TestFractionalEvaluation(t *testing.T) { | |
}, | ||
}, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.DefaultReason, | ||
|
@@ -364,7 +349,7 @@ func BenchmarkFractionalEvaluation(b *testing.B) { | |
tests := map[string]struct { | ||
flags Flags | ||
flagKey string | ||
context *structpb.Struct | ||
context map[string]any | ||
expectedValue string | ||
expectedVariant string | ||
expectedReason string | ||
|
@@ -373,47 +358,39 @@ func BenchmarkFractionalEvaluation(b *testing.B) { | |
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "yellow", | ||
expectedValue: "#FFFF00", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "red", | ||
expectedValue: "#FF0000", | ||
expectedReason: model.TargetingMatchReason, | ||
}, | ||
"[email protected]": { | ||
flags: flags, | ||
flagKey: "headerColor", | ||
context: &structpb.Struct{Fields: map[string]*structpb.Value{ | ||
"email": {Kind: &structpb.Value_StringValue{ | ||
StringValue: "[email protected]", | ||
}}, | ||
}}, | ||
context: map[string]any{ | ||
"email": "[email protected]", | ||
}, | ||
expectedVariant: "blue", | ||
expectedValue: "#0000FF", | ||
expectedReason: model.TargetingMatchReason, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.