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 return templateAndVersionFoundHandler (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 return templateAndVersionFoundHandler (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 return templateAndVersionFoundHandler (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 return templateAndVersionFoundHandler (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 return templateAndVersionFoundHandler (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 return templateAndVersionFoundHandler (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 return templateAndVersionFoundHandler (t , ctx , "my-template" , "" , "my-preset" , "my custom prompt" )
142146 },
0 commit comments