Skip to content

feat(cli): validate name length on template create #3823

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
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
Next Next commit
feat(cli): add template create validation test
This adds a test to validate that `template create` prints an error
message if called with a template name exceeding the 32-char limit.
  • Loading branch information
jsjoeio committed Sep 2, 2022
commit 172647f065dbbb819f002d71ce005e838bb971d8
19 changes: 19 additions & 0 deletions cli/templatecreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,25 @@ func TestTemplateCreate(t *testing.T) {
err = create()
require.NoError(t, err, "Template must be recreated without error")
})

t.Run("WithParameterExceedingCharLimit", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerD: true})
coderdtest.CreateFirstUser(t, client)
// Template name "1234567890123456789012345678901234567890" exceeds 32 char limit
cmd, root := clitest.New(t, "templates", "create", "1234567890123456789012345678901234567890", "--test.provisioner", string(database.ProvisionerTypeEcho))
clitest.SetupConfig(t, client, root)
pty := ptytest.New(t)
cmd.SetIn(pty.Input())
cmd.SetOut(pty.Output())

execDone := make(chan error)
go func() {
execDone <- cmd.Execute()
}()

require.EqualError(t, <-execDone, "template name must be less than 32 characters")
})
}

func createTestParseResponse() []*proto.Parse_Response {
Expand Down