Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc19f430

Browse files
fix(cli): display workspace created at time instead of current time (#19553)
Applying a suggestion from#19492 (comment)
1 parentef0d74f commitc19f430

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

‎cli/exp_taskcreate.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package cli
33
import (
44
"fmt"
55
"strings"
6-
"time"
76

87
"github.com/google/uuid"
98
"golang.org/x/xerrors"
@@ -118,7 +117,7 @@ func (r *RootCmd) taskCreate() *serpent.Command {
118117
inv.Stdout,
119118
"The task %s has been created at %s!\n",
120119
cliui.Keyword(workspace.Name),
121-
cliui.Timestamp(time.Now()),
120+
cliui.Timestamp(workspace.CreatedAt),
122121
)
123122

124123
returnnil

‎cli/exp_taskcreate_test.go‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net/url"
99
"strings"
1010
"testing"
11+
"time"
1112

1213
"github.com/google/uuid"
1314
"github.com/stretchr/testify/assert"
@@ -25,6 +26,8 @@ func TestTaskCreate(t *testing.T) {
2526
t.Parallel()
2627

2728
var (
29+
taskCreatedAt=time.Now()
30+
2831
organizationID=uuid.New()
2932
templateID=uuid.New()
3033
templateVersionID=uuid.New()
@@ -74,7 +77,8 @@ func TestTaskCreate(t *testing.T) {
7477
}
7578

7679
httpapi.Write(ctx,w,http.StatusCreated, codersdk.Workspace{
77-
Name:"task-wild-goldfish-27",
80+
Name:"task-wild-goldfish-27",
81+
CreatedAt:taskCreatedAt,
7882
})
7983
default:
8084
t.Errorf("unexpected path: %s",r.URL.Path)
@@ -91,52 +95,52 @@ func TestTaskCreate(t *testing.T) {
9195
}{
9296
{
9397
args: []string{"my-template@my-template-version","--input","my custom prompt"},
94-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
98+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
9599
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
96100
returntemplateAndVersionFoundHandler(t,ctx,"my-template","my-template-version","","my custom prompt")
97101
},
98102
},
99103
{
100104
args: []string{"my-template","--input","my custom prompt"},
101105
env: []string{"CODER_TASK_TEMPLATE_VERSION=my-template-version"},
102-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
106+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
103107
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
104108
returntemplateAndVersionFoundHandler(t,ctx,"my-template","my-template-version","","my custom prompt")
105109
},
106110
},
107111
{
108112
args: []string{"--input","my custom prompt"},
109113
env: []string{"CODER_TASK_TEMPLATE_NAME=my-template","CODER_TASK_TEMPLATE_VERSION=my-template-version"},
110-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
114+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
111115
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
112116
returntemplateAndVersionFoundHandler(t,ctx,"my-template","my-template-version","","my custom prompt")
113117
},
114118
},
115119
{
116120
env: []string{"CODER_TASK_TEMPLATE_NAME=my-template","CODER_TASK_TEMPLATE_VERSION=my-template-version","CODER_TASK_INPUT=my custom prompt"},
117-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
121+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
118122
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
119123
returntemplateAndVersionFoundHandler(t,ctx,"my-template","my-template-version","","my custom prompt")
120124
},
121125
},
122126
{
123127
args: []string{"my-template","--input","my custom prompt"},
124-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
128+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
125129
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
126130
returntemplateAndVersionFoundHandler(t,ctx,"my-template","","","my custom prompt")
127131
},
128132
},
129133
{
130134
args: []string{"my-template","--input","my custom prompt","--preset","my-preset"},
131-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
135+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
132136
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
133137
returntemplateAndVersionFoundHandler(t,ctx,"my-template","","my-preset","my custom prompt")
134138
},
135139
},
136140
{
137141
args: []string{"my-template","--input","my custom prompt"},
138142
env: []string{"CODER_TASK_PRESET_NAME=my-preset"},
139-
expectOutput:fmt.Sprintf("The task %s has been created",cliui.Keyword("task-wild-goldfish-27")),
143+
expectOutput:fmt.Sprintf("The task %s has been created at %s!",cliui.Keyword("task-wild-goldfish-27"),cliui.Timestamp(taskCreatedAt)),
140144
handler:func(t*testing.T,ctx context.Context) http.HandlerFunc {
141145
returntemplateAndVersionFoundHandler(t,ctx,"my-template","","my-preset","my custom prompt")
142146
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp