Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added go test for new param
  • Loading branch information
Kira-Pilot committed Oct 16, 2023
commit 776356ef83153e996b39f296b26c8faf343d5846
22 changes: 22 additions & 0 deletions coderd/experiments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,26 @@ func Test_Experiments(t *testing.T) {
require.Error(t, err)
require.ErrorContains(t, err, httpmw.SignedOutErrorMessage)
})

t.Run("include_all query param", func(t *testing.T) {
t.Parallel()
cfg := coderdtest.DeploymentValues(t)
cfg.Experiments = []string{"foo", "BAR"}
codersdk.ExperimentsAll = []codersdk.Experiment{"bat", "fizz", "foo", "BAR"}
client := coderdtest.New(t, &coderdtest.Options{
DeploymentValues: cfg,
})
_ = coderdtest.CreateFirstUser(t, client)

ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong)
defer cancel()

experiments, err := client.Experiments(ctx, codersdk.ExperimentOptions{IncludeAll: true})
require.NoError(t, err)
require.NotNil(t, experiments)
require.ElementsMatch(t, []codersdk.Experiment{"bat", "fizz", "foo", "BAR"}, experiments)

require.True(t, codersdk.Experiments{"foo", "BAR"}.Enabled("foo"))
require.True(t, codersdk.Experiments{"foo", "BAR"}.Enabled("BAR"))
})
}
3 changes: 2 additions & 1 deletion codersdk/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2013,12 +2013,13 @@ var ExperimentsAll = Experiments{
ExperimentSingleTailnet,
}

// Experiments is a list of experiments that are enabled for the deployment.
// Experiments is a list of experiments.
// Multiple experiments may be enabled at the same time.
// Experiments are not safe for production use, and are not guaranteed to
// be backwards compatible. They may be removed or renamed at any time.
type Experiments []Experiment

// Returns a list of experiments that are enabled for the deployment.
func (e Experiments) Enabled(ex Experiment) bool {
for _, v := range e {
if v == ex {
Expand Down