|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "testing" |
| 6 | + |
| 7 | + basev0 "github.com/codefly-dev/core/generated/go/codefly/base/v0" |
| 8 | + runtimev0 "github.com/codefly-dev/core/generated/go/codefly/services/runtime/v0" |
| 9 | + "github.com/codefly-dev/core/resources" |
| 10 | + "github.com/stretchr/testify/require" |
| 11 | +) |
| 12 | + |
| 13 | +func TestWorkspaceConfigurationReachesServiceProcess(t *testing.T) { |
| 14 | + runtime, env, req := initStartTestRuntime(t) |
| 15 | + req.WorkspaceConfigurations = []*basev0.Configuration{{ |
| 16 | + Origin: resources.ConfigurationWorkspace, |
| 17 | + Infos: []*basev0.ConfigurationInformation{{ |
| 18 | + Name: "gateway", |
| 19 | + ConfigurationValues: []*basev0.ConfigurationValue{ |
| 20 | + {Key: "profile", Value: "local/fake-text"}, |
| 21 | + {Key: "token", Value: "synthetic-test-token", Secret: true}, |
| 22 | + }, |
| 23 | + }}, |
| 24 | + }} |
| 25 | + initialized, err := runtime.Init(context.Background(), req) |
| 26 | + require.NoError(t, err) |
| 27 | + require.Equal(t, runtimev0.InitStatus_READY, initialized.GetStatus().GetState()) |
| 28 | + started, err := runtime.Start(context.Background(), &runtimev0.StartRequest{}) |
| 29 | + require.NoError(t, err) |
| 30 | + require.Equal(t, runtimev0.StartStatus_STARTED, started.GetStatus().GetState()) |
| 31 | + t.Cleanup(func() { _, _ = runtime.Stop(context.Background(), &runtimev0.StopRequest{}) }) |
| 32 | + values := map[string]string{} |
| 33 | + for _, variable := range uvicornProc(t, env).envs { |
| 34 | + values[variable.Key] = variable.ValueAsString() |
| 35 | + } |
| 36 | + require.Equal(t, "local/fake-text", values["CODEFLY__WORKSPACE_CONFIGURATION__GATEWAY__PROFILE"]) |
| 37 | + require.Equal(t, "synthetic-test-token", values["CODEFLY__WORKSPACE_SECRET_CONFIGURATION__GATEWAY__TOKEN"]) |
| 38 | +} |
0 commit comments