Skip to content

Commit 8270780

Browse files
committed
fix test
1 parent c8d9e7c commit 8270780

File tree

1 file changed

+142
-39
lines changed

1 file changed

+142
-39
lines changed

internal/provider/profiles_warehouse_resource_test.go

Lines changed: 142 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -277,42 +277,43 @@ func TestAccProfilesWarehouseResource_SchemaNameHandling(t *testing.T) {
277277
} else if req.URL.Path == "/spaces/my-space-id/profiles-warehouses/my-warehouse-id" && req.Method == http.MethodPatch {
278278
// Update response - schemaName should only be sent when it changes.
279279
updateCount++
280-
payload = `
281-
{
282-
"data": {
283-
"profilesWarehouse": {
284-
"id": "my-warehouse-id",
285-
"spaceId": "my-space-id",
286-
"workspaceId": "my-workspace-id",
287-
"enabled": false,
288-
"metadata": {
289-
"id": "my-metadata-id",
290-
"slug": "snowflake",
291-
"name": "Snowflake",
292-
"description": "Data warehouse built for the cloud",
293-
"logos": {
294-
"default": "https://cdn.filepicker.io/api/file/JrQWOYvMRRCVvSHp4HL0",
295-
"mark": "https://cdn.filepicker.io/api/file/OBhrGoCRKaSyvAhDX3fw",
296-
"alt": ""
280+
if updateCount == 1 {
281+
// First update: name changes, schema_name stays the same
282+
payload = `
283+
{
284+
"data": {
285+
"profilesWarehouse": {
286+
"id": "my-warehouse-id",
287+
"spaceId": "my-space-id",
288+
"workspaceId": "my-workspace-id",
289+
"enabled": false,
290+
"metadata": {
291+
"id": "my-metadata-id",
292+
"slug": "snowflake",
293+
"name": "Snowflake",
294+
"description": "Data warehouse built for the cloud",
295+
"logos": {
296+
"default": "https://cdn.filepicker.io/api/file/JrQWOYvMRRCVvSHp4HL0",
297+
"mark": "https://cdn.filepicker.io/api/file/OBhrGoCRKaSyvAhDX3fw",
298+
"alt": ""
299+
},
300+
"options": []
297301
},
298-
"options": []
299-
},
300-
"settings": {
301-
"name": "My new warehouse name",
302-
"token": "my-other-token"
303-
},
304-
"schemaName": "my-new-schema-name"
302+
"settings": {
303+
"name": "My updated warehouse name",
304+
"token": "my-other-token"
305+
},
306+
"schemaName": "my-schema-name"
307+
}
305308
}
306309
}
307-
}
308-
`
309-
} else if req.URL.Path == "/spaces/my-space-id/profiles-warehouses" && req.Method == http.MethodGet {
310-
// Read response.
311-
payload = `
312-
{
313-
"data": {
314-
"profilesWarehouses": [
315-
{
310+
`
311+
} else {
312+
// Second update: schema_name changes
313+
payload = `
314+
{
315+
"data": {
316+
"profilesWarehouse": {
316317
"id": "my-warehouse-id",
317318
"spaceId": "my-space-id",
318319
"workspaceId": "my-workspace-id",
@@ -330,15 +331,117 @@ func TestAccProfilesWarehouseResource_SchemaNameHandling(t *testing.T) {
330331
"options": []
331332
},
332333
"settings": {
333-
"name": "My warehouse name",
334-
"token": "my-token"
334+
"name": "My final warehouse name",
335+
"token": "my-final-token"
335336
},
336-
"schemaName": "my-schema-name"
337+
"schemaName": "my-new-schema-name"
337338
}
338-
]
339+
}
339340
}
340-
}
341-
`
341+
`
342+
}
343+
} else if req.URL.Path == "/spaces/my-space-id/profiles-warehouses" && req.Method == http.MethodGet {
344+
// Read response - return current state based on update count.
345+
if updateCount == 0 {
346+
// Initial state
347+
payload = `
348+
{
349+
"data": {
350+
"profilesWarehouses": [
351+
{
352+
"id": "my-warehouse-id",
353+
"spaceId": "my-space-id",
354+
"workspaceId": "my-workspace-id",
355+
"enabled": true,
356+
"metadata": {
357+
"id": "my-metadata-id",
358+
"slug": "snowflake",
359+
"name": "Snowflake",
360+
"description": "Data warehouse built for the cloud",
361+
"logos": {
362+
"default": "https://cdn.filepicker.io/api/file/JrQWOYvMRRCVvSHp4HL0",
363+
"mark": "https://cdn.filepicker.io/api/file/OBhrGoCRKaSyvAhDX3fw",
364+
"alt": ""
365+
},
366+
"options": []
367+
},
368+
"settings": {
369+
"name": "My warehouse name",
370+
"token": "my-token"
371+
},
372+
"schemaName": "my-schema-name"
373+
}
374+
]
375+
}
376+
}
377+
`
378+
} else if updateCount == 1 {
379+
// After first update: name changed, schema_name same
380+
payload = `
381+
{
382+
"data": {
383+
"profilesWarehouses": [
384+
{
385+
"id": "my-warehouse-id",
386+
"spaceId": "my-space-id",
387+
"workspaceId": "my-workspace-id",
388+
"enabled": false,
389+
"metadata": {
390+
"id": "my-metadata-id",
391+
"slug": "snowflake",
392+
"name": "Snowflake",
393+
"description": "Data warehouse built for the cloud",
394+
"logos": {
395+
"default": "https://cdn.filepicker.io/api/file/JrQWOYvMRRCVvSHp4HL0",
396+
"mark": "https://cdn.filepicker.io/api/file/OBhrGoCRKaSyvAhDX3fw",
397+
"alt": ""
398+
},
399+
"options": []
400+
},
401+
"settings": {
402+
"name": "My updated warehouse name",
403+
"token": "my-other-token"
404+
},
405+
"schemaName": "my-schema-name"
406+
}
407+
]
408+
}
409+
}
410+
`
411+
} else {
412+
// After second update: schema_name changed
413+
payload = `
414+
{
415+
"data": {
416+
"profilesWarehouses": [
417+
{
418+
"id": "my-warehouse-id",
419+
"spaceId": "my-space-id",
420+
"workspaceId": "my-workspace-id",
421+
"enabled": true,
422+
"metadata": {
423+
"id": "my-metadata-id",
424+
"slug": "snowflake",
425+
"name": "Snowflake",
426+
"description": "Data warehouse built for the cloud",
427+
"logos": {
428+
"default": "https://cdn.filepicker.io/api/file/JrQWOYvMRRCVvSHp4HL0",
429+
"mark": "https://cdn.filepicker.io/api/file/OBhrGoCRKaSyvAhDX3fw",
430+
"alt": ""
431+
},
432+
"options": []
433+
},
434+
"settings": {
435+
"name": "My final warehouse name",
436+
"token": "my-final-token"
437+
},
438+
"schemaName": "my-new-schema-name"
439+
}
440+
]
441+
}
442+
}
443+
`
444+
}
342445
}
343446

344447
_, _ = w.Write([]byte(payload))

0 commit comments

Comments
 (0)