8000 feat!: Validate monotonic numbers for rich parameters by mtojek · Pull Request #6046 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

feat!: Validate monotonic numbers for rich parameters #6046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 7, 2023
Merged
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
workspaces_test
  • Loading branch information
mtojek committed Feb 6, 2023
commit 6715d27d9b9dbba0ef559341ff2e77c34a516ecb
27 changes: 22 additions & 5 deletions coderd/workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1788,12 +1788,15 @@ func TestWorkspaceWithRichParameters(t *testing.T) {

const (
firstParameterName = "first_parameter"
firstParameterType = "string"
firstParameterDescription = "This is first parameter"
firstParameterValue = "1"

secondParameterName = "second_parameter"
secondParameterDescription = "This is second parameter"
secondParameterValue = "2"
secondParameterName = "second_parameter"
secondParameterType = "number"
secondParameterDescription = "This is second parameter"
secondParameterValue = "2"
secondParameterValidationMonotonic = codersdk.MonotonicOrderIncreasing
)

client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true})
Expand All @@ -1805,8 +1808,17 @@ func TestWorkspaceWithRichParameters(t *testing.T) {
Type: &proto.Provision_Response_Complete{
Complete: &proto.Provision_Complete{
Parameters: []*proto.RichParameter{
{Name: firstParameterName, Description: firstParameterDescription},
{Name: secondParameterName, Description: secondParameterDescription},
{
Name: firstParameterName,
Type: firstParameterType,
Description: firstParameterDescription,
},
{
Name: secondParameterName,
Type: secondParameterType,
Description: secondParameterDescription,
ValidationMonotonic: string(secondParameterValidationMonotonic),
},
},
},
},
Expand All @@ -1826,7 +1838,12 @@ func TestWorkspaceWithRichParameters(t *testing.T) {
require.NoError(t, err)
require.Len(t, templateRichParameters, 2)
require.Equal(t, templateRichParameters[0].Name, firstParameterName)
require.Equal(t, templateRichParameters[0].Type, firstParameterType)
require.Equal(t, templateRichParameters[0].ValidationMonotonic, codersdk.ValidationMonotonicOrder("")) // no validation for string

require.Equal(t, templateRichParameters[1].Name, secondParameterName)
require.Equal(t, templateRichParameters[1].Type, secondParameterType)
require.Equal(t, templateRichParameters[1].ValidationMonotonic, secondParameterValidationMonotonic)

expectedBuildParameters := []codersdk.WorkspaceBuildParameter{
{Name: firstParameterName, Value: firstParameterValue},
Expand Down
0