@@ -56,12 +56,18 @@ func TestExpTaskDelete(t *testing.T) {
5656 taskID := uuid .MustParse (id1 )
5757 return func (w http.ResponseWriter , r * http.Request ) {
5858 switch {
59- case r .Method == http .MethodGet && r .URL .Path == "/api/v2/users/me/workspace/exists " :
59+ case r .Method == http .MethodGet && r .URL .Path == "/api/experimental/tasks" && r . URL . Query (). Get ( "owner" ) == "me " :
6060 c .nameResolves .Add (1 )
61- httpapi .Write (r .Context (), w , http .StatusOK , codersdk.Workspace {
62- ID : taskID ,
63- Name : "exists" ,
64- OwnerName : "me" ,
61+ httpapi .Write (r .Context (), w , http .StatusOK , struct {
62+ Tasks []codersdk.Task `json:"tasks"`
63+ Count int `json:"count"`
64+ }{
65+ Tasks : []codersdk.Task {{
66+ ID : taskID ,
67+ Name : "exists" ,
68+ OwnerName : "me" ,
69+ }},
70+ Count : 1 ,
6571 })
6672 case r .Method == http .MethodDelete && r .URL .Path == "/api/experimental/tasks/me/" + id1 :
6773 c .deleteCalls .Add (1 )
@@ -104,12 +110,18 @@ func TestExpTaskDelete(t *testing.T) {
104110 firstID := uuid .MustParse (id3 )
105111 return func (w http.ResponseWriter , r * http.Request ) {
106112 switch {
107- case r .Method == http .MethodGet && r .URL .Path == "/api/v2/users/me/workspace/first " :
113+ case r .Method == http .MethodGet && r .URL .Path == "/api/experimental/tasks" && r . URL . Query (). Get ( "owner" ) == "me " :
108114 c .nameResolves .Add (1 )
109- httpapi .Write (r .Context (), w , http .StatusOK , codersdk.Workspace {
110- ID : firstID ,
111- Name : "first" ,
112- OwnerName : "me" ,
115+ httpapi .Write (r .Context (), w , http .StatusOK , struct {
116+ Tasks []codersdk.Task `json:"tasks"`
117+ Count int `json:"count"`
118+ }{
119+ Tasks : []codersdk.Task {{
120+ ID : firstID ,
121+ Name : "first" ,
122+ OwnerName : "me" ,
123+ }},
124+ Count : 1 ,
113125 })
114126 case r .Method == http .MethodGet && r .URL .Path == "/api/experimental/tasks/me/" + id4 :
115127 httpapi .Write (r .Context (), w , http .StatusOK , codersdk.Task {
@@ -139,8 +151,14 @@ func TestExpTaskDelete(t *testing.T) {
139151 buildHandler : func (_ * testCounters ) http.HandlerFunc {
140152 return func (w http.ResponseWriter , r * http.Request ) {
141153 switch {
142- case r .Method == http .MethodGet && r .URL .Path == "/api/v2/users/me/workspace/doesnotexist" :
143- httpapi .ResourceNotFound (w )
154+ case r .Method == http .MethodGet && r .URL .Path == "/api/experimental/tasks" && r .URL .Query ().Get ("owner" ) == "me" :
155+ httpapi .Write (r .Context (), w , http .StatusOK , struct {
156+ Tasks []codersdk.Task `json:"tasks"`
157+ Count int `json:"count"`
158+ }{
159+ Tasks : []codersdk.Task {},
160+ Count : 0 ,
161+ })
144162 default :
145163 httpapi .InternalServerError (w , xerrors .New ("unwanted path: " + r .Method + " " + r .URL .Path ))
146164 }
@@ -156,12 +174,18 @@ func TestExpTaskDelete(t *testing.T) {
156174 taskID := uuid .MustParse (id5 )
157175 return func (w http.ResponseWriter , r * http.Request ) {
158176 switch {
159- case r .Method == http .MethodGet && r .URL .Path == "/api/v2/users/me/workspace/bad " :
177+ case r .Method == http .MethodGet && r .URL .Path == "/api/experimental/tasks" && r . URL . Query (). Get ( "owner" ) == "me " :
160178 c .nameResolves .Add (1 )
161- httpapi .Write (r .Context (), w , http .StatusOK , codersdk.Workspace {
162- ID : taskID ,
163- Name : "bad" ,
164- OwnerName : "me" ,
179+ httpapi .Write (r .Context (), w , http .StatusOK , struct {
180+ Tasks []codersdk.Task `json:"tasks"`
181+ Count int `json:"count"`
182+ }{
183+ Tasks : []codersdk.Task {{
184+ ID : taskID ,
185+ Name : "bad" ,
186+ OwnerName : "me" ,
187+ }},
188+ Count : 1 ,
165189 })
166190 case r .Method == http .MethodDelete && r .URL .Path == "/api/experimental/tasks/me/" + id5 :
167191 httpapi .InternalServerError (w , xerrors .New ("boom" ))
0 commit comments