8
8
"net/url"
9
9
"strings"
10
10
"testing"
11
+ "time"
11
12
12
13
"github.com/google/uuid"
13
14
"github.com/stretchr/testify/assert"
@@ -25,6 +26,8 @@ func TestTaskCreate(t *testing.T) {
25
26
t .Parallel ()
26
27
27
28
var (
29
+ taskCreatedAt = time .Now ()
30
+
28
31
organizationID = uuid .New ()
29
32
templateID = uuid .New ()
30
33
templateVersionID = uuid .New ()
@@ -74,7 +77,8 @@ func TestTaskCreate(t *testing.T) {
74
77
}
75
78
76
79
httpapi .Write (ctx , w , http .StatusCreated , codersdk.Workspace {
77
- Name : "task-wild-goldfish-27" ,
80
+ Name : "task-wild-goldfish-27" ,
81
+ CreatedAt : taskCreatedAt ,
78
82
})
79
83
default :
80
84
t .Errorf ("unexpected path: %s" , r .URL .Path )
@@ -91,52 +95,52 @@ func TestTaskCreate(t *testing.T) {
91
95
}{
92
96
{
93
97
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 )),
95
99
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
96
100
return templateAndVersionFoundHandler (t , ctx , "my-template" , "my-template-version" , "" , "my custom prompt" )
97
101
},
98
102
},
99
103
{
100
104
args : []string {"my-template" , "--input" , "my custom prompt" },
101
105
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 )),
103
107
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
104
108
return templateAndVersionFoundHandler (t , ctx , "my-template" , "my-template-version" , "" , "my custom prompt" )
105
109
},
106
110
},
107
111
{
108
112
args : []string {"--input" , "my custom prompt" },
109
113
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 )),
111
115
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
112
116
return templateAndVersionFoundHandler (t , ctx , "my-template" , "my-template-version" , "" , "my custom prompt" )
113
117
},
114
118
},
115
119
{
116
120
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 )),
118
122
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
119
123
return templateAndVersionFoundHandler (t , ctx , "my-template" , "my-template-version" , "" , "my custom prompt" )
120
124
},
121
125
},
122
126
{
123
127
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 )),
125
129
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
126
130
return templateAndVersionFoundHandler (t , ctx , "my-template" , "" , "" , "my custom prompt" )
127
131
},
128
132
},
129
133
{
130
134
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 )),
132
136
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
133
137
return templateAndVersionFoundHandler (t , ctx , "my-template" , "" , "my-preset" , "my custom prompt" )
134
138
},
135
139
},
136
140
{
137
141
args : []string {"my-template" , "--input" , "my custom prompt" },
138
142
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 )),
140
144
handler : func (t * testing.T , ctx context.Context ) http.HandlerFunc {
141
145
return templateAndVersionFoundHandler (t , ctx , "my-template" , "" , "my-preset" , "my custom prompt" )
142
146
},
0 commit comments