generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rather than `ftl.Config[string]("foo").Get(ctx)` it is now `ftl.Config[string]("foo")`.
- Loading branch information
1 parent
8ca5926
commit 6f68fb4
Showing
6 changed files
with
68 additions
and
44 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
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
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 |
---|---|---|
@@ -1,27 +1,17 @@ | ||
package ftl | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
|
||
"github.com/TBD54566975/ftl/common/configuration" | ||
"github.com/TBD54566975/ftl/common/projectconfig" | ||
"github.com/TBD54566975/ftl/internal/log" | ||
) | ||
|
||
func TestConfig(t *testing.T) { | ||
ctx := log.ContextWithNewDefaultLogger(context.Background()) | ||
cr := configuration.ProjectConfigResolver[configuration.Configuration]{Config: []string{"testdata/ftl-project.toml"}} | ||
assert.Equal(t, []string{"testdata/ftl-project.toml"}, projectconfig.ConfigPaths(cr.Config)) | ||
cm, err := configuration.NewConfigurationManager(ctx, cr) | ||
assert.NoError(t, err) | ||
ctx = configuration.ContextWithConfig(ctx, cm) | ||
t.Setenv("FTL_CONFIG", "testdata/ftl-project.toml") | ||
type C struct { | ||
One string | ||
Two string | ||
} | ||
config := Config[C]("test") | ||
assert.Equal(t, C{"one", "two"}, config.Get(ctx)) | ||
assert.Equal(t, C{"one", "two"}, config.Get()) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,17 @@ | ||
package ftl | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/alecthomas/assert/v2" | ||
|
||
"github.com/TBD54566975/ftl/common/configuration" | ||
"github.com/TBD54566975/ftl/internal/log" | ||
) | ||
|
||
func TestSecret(t *testing.T) { | ||
ctx := log.ContextWithNewDefaultLogger(context.Background()) | ||
sr := configuration.ProjectConfigResolver[configuration.Secrets]{Config: []string{"testdata/ftl-project.toml"}} | ||
sm, err := configuration.NewSecretsManager(ctx, sr) | ||
assert.NoError(t, err) | ||
ctx = configuration.ContextWithSecrets(ctx, sm) | ||
t.Setenv("FTL_CONFIG", "testdata/ftl-project.toml") | ||
type C struct { | ||
One string | ||
Two string | ||
} | ||
config := Secret[C]("secret") | ||
assert.Equal(t, C{"one", "two"}, config.Get(ctx)) | ||
assert.Equal(t, C{"one", "two"}, config.Get()) | ||
} |