generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "feat: simplify config/secret API (#1241)"
This reverts commit 2f3fc07.
- Loading branch information
1 parent
2f3fc07
commit f8e6d30
Showing
6 changed files
with
44 additions
and
68 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,17 +1,27 @@ | ||
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) { | ||
t.Setenv("FTL_CONFIG", "testdata/ftl-project.toml") | ||
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) | ||
type C struct { | ||
One string | ||
Two string | ||
} | ||
config := Config[C]("test") | ||
assert.Equal(t, C{"one", "two"}, config.Get()) | ||
assert.Equal(t, C{"one", "two"}, config.Get(ctx)) | ||
} |
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,17 +1,25 @@ | ||
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) { | ||
t.Setenv("FTL_CONFIG", "testdata/ftl-project.toml") | ||
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) | ||
type C struct { | ||
One string | ||
Two string | ||
} | ||
config := Secret[C]("secret") | ||
assert.Equal(t, C{"one", "two"}, config.Get()) | ||
assert.Equal(t, C{"one", "two"}, config.Get(ctx)) | ||
} |