@@ -115,7 +115,6 @@ func TestEditApp(t *testing.T) {
115115 httpClient := GetHttpclient (t )
116116
117117 appName := "test-app-to-edit"
118- var updatedAppId string
119118 createResp , err := httpClient .CreateAppWithResponse (
120119 t .Context (),
121120 & client.CreateAppParams {SkipSketch : f .Ptr (true )},
@@ -132,29 +131,25 @@ func TestEditApp(t *testing.T) {
132131
133132 t .Run ("EditAllFields_Success" , func (t * testing.T ) {
134133 renamedApp := appName + "-renamed"
134+ modifedIcon := "🌟"
135135 editResp , err := httpClient .EditAppWithResponse (
136136 t .Context (),
137137 validAppId ,
138138 client.EditRequest {
139139 Description : f .Ptr ("new-description" ),
140- Icon : f .Ptr ("🌟" ),
140+ Icon : f .Ptr (modifedIcon ),
141141 Name : f .Ptr (renamedApp ),
142142 },
143143 )
144144 require .NoError (t , err )
145145 require .Equal (t , http .StatusOK , editResp .StatusCode ())
146-
147- appList , err := httpClient .GetAppsWithResponse (t .Context (), & client.GetAppsParams {})
146+ require .NotNil (t , editResp .JSON200 )
147+ require .NotNil (t , editResp .JSON200 .Id )
148+ detailsResp , err := httpClient .GetAppDetailsWithResponse (t .Context (), editResp .JSON200 .Id )
148149 require .NoError (t , err )
149- require .Equal (t , http .StatusOK , appList .StatusCode ())
150- require .NotEmpty (t , appList .JSON200 .Apps )
151- require .Len (t , * appList .JSON200 .Apps , 1 )
152-
153- app := (* appList .JSON200 .Apps )[0 ]
154- require .Equal (t , renamedApp , * app .Name )
155- require .Equal (t , "new-description" , * app .Description )
156- require .Equal (t , "🌟" , * app .Icon )
157- updatedAppId = * app .Id
150+ require .Equal (t , http .StatusOK , detailsResp .StatusCode ())
151+ require .Equal (t , renamedApp , detailsResp .JSON200 .Name )
152+ require .Equal (t , modifedIcon , * detailsResp .JSON200 .Icon )
158153 })
159154
160155 t .Run ("InvalidAppId_Fail" , func (t * testing.T ) {
@@ -216,11 +211,25 @@ func TestEditApp(t *testing.T) {
216211 })
217212
218213 t .Run ("InvalidRequestBody_Fail" , func (t * testing.T ) {
214+ createResp , err := httpClient .CreateAppWithResponse (
215+ t .Context (),
216+ & client.CreateAppParams {SkipSketch : f .Ptr (true )},
217+ client.CreateAppRequest {
218+ Icon : f .Ptr ("💻" ),
219+ Name : "new-valid-app" ,
220+ },
221+ )
222+ require .NoError (t , err )
223+ require .Equal (t , http .StatusCreated , createResp .StatusCode ())
224+ require .NotNil (t , createResp .JSON201 )
225+
226+ validAppId := * createResp .JSON201 .Id
227+
219228 var actualResponseBody models.ErrorResponse
220229 malformedBody := `{"name": "test" "icon": "💻"}`
221230 editResp , err := httpClient .EditAppWithBody (
222231 t .Context (),
223- updatedAppId ,
232+ validAppId ,
224233 "application/json" ,
225234 strings .NewReader (malformedBody ),
226235 )
0 commit comments