- Notifications
You must be signed in to change notification settings - Fork1.1k
feat(cli): display template version name in push output#21192
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -106,7 +106,7 @@ func TestTemplatePush(t *testing.T) { | ||
| inv = inv.WithContext(ctx) | ||
| w := clitest.StartWithWaiter(t, inv) | ||
| pty.ExpectNoMatchBefore(ctx, "Template message is longer than 72 characters", "Updated version") | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Can we make sure that the template version matches the one exposed via API, and match the whole phrase EDIT: | ||
| w.RequireSuccess() | ||
| @@ -1302,6 +1302,87 @@ cli_overrides_file_var: from-file`) | ||
| require.Equal(t, "from-cli-override", varMap["cli_overrides_file_var"]) | ||
| }) | ||
| }) | ||
| t.Run("DisplayAutogeneratedVersionName", func(t *testing.T) { | ||
| t.Parallel() | ||
| client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) | ||
| owner := coderdtest.CreateFirstUser(t, client) | ||
| templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin()) | ||
| version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil) | ||
| _ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) | ||
| template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID) | ||
| // Test the cli command without --name flag (autogenerated name). | ||
| source := clitest.CreateTemplateVersionSource(t, &echo.Responses{ | ||
| Parse: echo.ParseComplete, | ||
| ProvisionApply: echo.ApplyComplete, | ||
| }) | ||
| inv, root := clitest.New(t, "templates", "push", template.Name, "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--yes") | ||
| clitest.SetupConfig(t, templateAdmin, root) | ||
| pty := ptytest.New(t).Attach(inv) | ||
| ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) | ||
| defer cancel() | ||
| inv = inv.WithContext(ctx) | ||
| w := clitest.StartWithWaiter(t, inv) | ||
| // Expect the output to contain "Updated version" followed by the version name. | ||
| pty.ExpectMatchContext(ctx, "Updated version") | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Same | ||
| w.RequireSuccess() | ||
| // Verify the autogenerated template version was created. | ||
| templateVersions, err := client.TemplateVersionsByTemplate(context.Background(), codersdk.TemplateVersionsByTemplateRequest{ | ||
| TemplateID: template.ID, | ||
| }) | ||
| require.NoError(t, err) | ||
| assert.Len(t, templateVersions, 2) | ||
| assert.NotEqual(t, template.ActiveVersionID, templateVersions[1].ID) | ||
| // Verify the autogenerated name is not empty (it should be something like "fervent_austin5"). | ||
| assert.NotEmpty(t, templateVersions[1].Name) | ||
| }) | ||
| t.Run("DisplayUserSpecifiedVersionName", func(t *testing.T) { | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I guess we don't need a separate case for that, just modify "OK" test case :) | ||
| t.Parallel() | ||
| client := coderdtest.New(t, &coderdtest.Options{IncludeProvisionerDaemon: true}) | ||
| owner := coderdtest.CreateFirstUser(t, client) | ||
| templateAdmin, _ := coderdtest.CreateAnotherUser(t, client, owner.OrganizationID, rbac.RoleTemplateAdmin()) | ||
| version := coderdtest.CreateTemplateVersion(t, client, owner.OrganizationID, nil) | ||
| _ = coderdtest.AwaitTemplateVersionJobCompleted(t, client, version.ID) | ||
| template := coderdtest.CreateTemplate(t, client, owner.OrganizationID, version.ID) | ||
| // Test the cli command with --name flag. | ||
| source := clitest.CreateTemplateVersionSource(t, &echo.Responses{ | ||
| Parse: echo.ParseComplete, | ||
| ProvisionApply: echo.ApplyComplete, | ||
| }) | ||
| versionName := "my-custom-version" | ||
| inv, root := clitest.New(t, "templates", "push", template.Name, "--directory", source, "--test.provisioner", string(database.ProvisionerTypeEcho), "--name", versionName, "--yes") | ||
| clitest.SetupConfig(t, templateAdmin, root) | ||
| pty := ptytest.New(t).Attach(inv) | ||
| ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) | ||
| defer cancel() | ||
| inv = inv.WithContext(ctx) | ||
| w := clitest.StartWithWaiter(t, inv) | ||
| // Expect the output to contain "Updated version my-custom-version". | ||
| pty.ExpectMatchContext(ctx, "Updated version "+versionName) | ||
| w.RequireSuccess() | ||
| // Assert that the template version has the correct name. | ||
| templateVersions, err := client.TemplateVersionsByTemplate(context.Background(), codersdk.TemplateVersionsByTemplateRequest{ | ||
| TemplateID: template.ID, | ||
| }) | ||
| require.NoError(t, err) | ||
| assert.Len(t, templateVersions, 2) | ||
| require.Equal(t, versionName, templateVersions[1].Name) | ||
| }) | ||
| } | ||
| func createEchoResponsesWithTemplateVariables(templateVariables []*proto.TemplateVariable) *echo.Responses { | ||
Uh oh!
There was an error while loading.Please reload this page.