Skip to content

Commit

Permalink
test: update config/secrets to test structs
Browse files Browse the repository at this point in the history
  • Loading branch information
alecthomas committed Jan 19, 2024
1 parent 6ebb4b6 commit 7f3a79e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
10 changes: 7 additions & 3 deletions go-runtime/sdk/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import (
)

func TestConfig(t *testing.T) {
t.Setenv("FTL_CONFIG_TESTING_TEST", `["one", "two", "three"]`)
config := Config[[]string]("test")
assert.Equal(t, []string{"one", "two", "three"}, config.Get())
type C struct {
One string
Two string
}
t.Setenv("FTL_CONFIG_TESTING_TEST", `{"one": "one", "two": "two"}`)
config := Config[C]("test")
assert.Equal(t, C{"one", "two"}, config.Get())
}
17 changes: 17 additions & 0 deletions go-runtime/sdk/secrets_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package sdk

import (
"testing"

"github.com/alecthomas/assert/v2"
)

func TestSecret(t *testing.T) {
type C struct {
One string
Two string
}
t.Setenv("FTL_SECRET_TESTING_TEST", `{"one": "one", "two": "two"}`)
config := Secret[C]("test")
assert.Equal(t, C{"one", "two"}, config.Get())
}

0 comments on commit 7f3a79e

Please sign in to comment.