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) {
2526t .Parallel ()
2627
2728var (
29+ taskCreatedAt = time .Now ()
30+
2831organizationID = uuid .New ()
2932templateID = uuid .New ()
3033templateVersionID = uuid .New ()
@@ -74,7 +77,8 @@ func TestTaskCreate(t *testing.T) {
7477}
7578
7679httpapi .Write (ctx ,w ,http .StatusCreated , codersdk.Workspace {
77- Name :"task-wild-goldfish-27" ,
80+ Name :"task-wild-goldfish-27" ,
81+ CreatedAt :taskCreatedAt ,
7882})
7983default :
8084t .Errorf ("unexpected path: %s" ,r .URL .Path )
@@ -91,52 +95,52 @@ func TestTaskCreate(t *testing.T) {
9195}{
9296{
9397args : []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 )),
9599handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
96100return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"my-template-version" ,"" ,"my custom prompt" )
97101},
98102},
99103{
100104args : []string {"my-template" ,"--input" ,"my custom prompt" },
101105env : []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 )),
103107handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
104108return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"my-template-version" ,"" ,"my custom prompt" )
105109},
106110},
107111{
108112args : []string {"--input" ,"my custom prompt" },
109113env : []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 )),
111115handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
112116return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"my-template-version" ,"" ,"my custom prompt" )
113117},
114118},
115119{
116120env : []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 )),
118122handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
119123return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"my-template-version" ,"" ,"my custom prompt" )
120124},
121125},
122126{
123127args : []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 )),
125129handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
126130return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"" ,"" ,"my custom prompt" )
127131},
128132},
129133{
130134args : []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 )),
132136handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
133137return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"" ,"my-preset" ,"my custom prompt" )
134138},
135139},
136140{
137141args : []string {"my-template" ,"--input" ,"my custom prompt" },
138142env : []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 )),
140144handler :func (t * testing.T ,ctx context.Context ) http.HandlerFunc {
141145return templateAndVersionFoundHandler (t ,ctx ,"my-template" ,"" ,"my-preset" ,"my custom prompt" )
142146},