Skip to content

Commit

Permalink
feat: add selector tests (#221)
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Schrottner <simon.schrottner@dynatrace.com>
  • Loading branch information
aepfli authored Feb 13, 2025
1 parent cbb1563 commit 813011d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
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

0 comments on commit 813011d

Please sign in to comment.