Skip to content

feat: add selector tests #221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions flags/selector-flags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"flags": {
"selector-flag": {
"state": "ENABLED",
"variants": {
"foo": "foo",
"bar": "bar"
},
"defaultVariant": "foo"
}
}
}
23 changes: 23 additions & 0 deletions gherkin/selector.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@in-process
Feature: flagd selector

Background:
Given an option "selector" of type "String" with value "rawflags/selector-flags.json"
And a stable flagd provider

Scenario Outline: Flags not found
Given a <type>-flag with key "<key>" and a default value "<default>"
When the flag was evaluated with details
Then the reason should be "ERROR"

Examples:
| key | type | default |
| boolean-flag | Boolean | false |
| string-flag | String | bye |
| integer-flag | Integer | 1 |
| float-flag | Float | 0.1 |

Scenario: Resolve values
Given a String-flag with key "selector-flag" and a default value "foo"
When the flag was evaluated with details
Then the reason should be "STATIC"
4 changes: 4 additions & 0 deletions launchpad/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
{
"uri": "flags/allFlags.json",
"provider": "file"
},
{
"uri": "rawflags/selector-flags.json",
"provider": "file"
}
]
}
4 changes: 4 additions & 0 deletions launchpad/configs/ssl.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
{
"uri": "flags/allFlags.json",
"provider": "file"
},
{
"uri": "rawflags/selector-flags.json",
"provider": "file"
}
]
}
2 changes: 1 addition & 1 deletion launchpad/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func CombineJSONFiles() error {

for _, file := range files {
fmt.Printf("read JSON %s\n", file.Name())
if filepath.Ext(file.Name()) == ".json" {
if filepath.Ext(file.Name()) == ".json" && file.Name() != "selector-flags.json" {
filePath := filepath.Join(inputDir, file.Name())
content, err := ioutil.ReadFile(filePath)
if err != nil {
Expand Down