Skip to content

Commit 348148e

Browse files
committed
chore: add message describing used template and template-version
1 parent 37c1960 commit 348148e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

cli/templatepresets.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ func (r *RootCmd) templatePresetsList() *serpent.Command {
105105
inv.Stdout,
106106
"No presets found for template %q and template-version %q.\n", template.Name, version.Name,
107107
)
108+
return nil
108109
}
109110

111+
cliui.Infof(
112+
inv.Stdout,
113+
"Showing presets for template %q and template version %q.\n", template.Name, version.Name,
114+
)
110115
rows := templatePresetsToRows(presets...)
111116
out, err := formatter.Format(inv.Context(), rows)
112117
if err != nil {

cli/templatepresets_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,15 @@ import (
44
"fmt"
55
"testing"
66

7-
"github.com/coder/coder/v2/codersdk"
8-
"github.com/coder/coder/v2/testutil"
9-
10-
"github.com/coder/coder/v2/provisioner/echo"
11-
"github.com/coder/coder/v2/provisionersdk/proto"
12-
137
"github.com/stretchr/testify/require"
148

159
"github.com/coder/coder/v2/cli/clitest"
1610
"github.com/coder/coder/v2/coderd/coderdtest"
11+
"github.com/coder/coder/v2/codersdk"
12+
"github.com/coder/coder/v2/provisioner/echo"
13+
"github.com/coder/coder/v2/provisionersdk/proto"
1714
"github.com/coder/coder/v2/pty/ptytest"
15+
"github.com/coder/coder/v2/testutil"
1816
)
1917

2018
func TestTemplatePresets(t *testing.T) {
@@ -114,6 +112,8 @@ func TestTemplatePresets(t *testing.T) {
114112
require.NoError(t, runErr)
115113

116114
// Should: return the active version's presets sorted by name
115+
message := fmt.Sprintf("Showing presets for template %q and template version %q.", template.Name, version.Name)
116+
pty.ExpectMatch(message)
117117
pty.ExpectRegexMatch(`preset-default\s+k1=v2\s+true\s+0`)
118118
// The parameter order is not guaranteed in the output, so we match both possible orders
119119
pty.ExpectRegexMatch(`preset-multiple-params\s+(k1=v1,k2=v2)|(k2=v2,k1=v1)\s+false\s+-`)
@@ -203,6 +203,8 @@ func TestTemplatePresets(t *testing.T) {
203203
require.NoError(t, runErr)
204204

205205
// Should: return the specified version's presets sorted by name
206+
message := fmt.Sprintf("Showing presets for template %q and template version %q.", template.Name, version.Name)
207+
pty.ExpectMatch(message)
206208
pty.ExpectRegexMatch(`preset-default\s+k1=v2\s+true\s+0`)
207209
// The parameter order is not guaranteed in the output, so we match both possible orders
208210
pty.ExpectRegexMatch(`preset-multiple-params\s+(k1=v1,k2=v2)|(k2=v2,k1=v1)\s+false\s+-`)

0 commit comments

Comments
 (0)