Skip to content

Commit

Permalink
fix mws workspaces mishandling empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
VenelinMartinov committed Jan 17, 2025
1 parent 6b9a584 commit 9e9c8d9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mws/data_mws_workspaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

func DataSourceMwsWorkspaces() common.Resource {
type mwsWorkspacesData struct {
Ids map[string]int64 `json:"ids,omitempty" tf:"computed"`
Ids map[string]int64 `json:"ids" tf:"computed"`
}
return common.DataResource(mwsWorkspacesData{}, func(ctx context.Context, e any, c *common.DatabricksClient) error {
data := e.(*mwsWorkspacesData)
Expand Down
20 changes: 20 additions & 0 deletions mws/data_mws_workspaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,23 @@ func TestCatalogsData_Error(t *testing.T) {
ID: "_",
}.ExpectError(t, "i'm a teapot")
}

func TestDataSourceMwsWorkspaces_Empty(t *testing.T) {
qa.ResourceFixture{
Fixtures: []qa.HTTPFixture{
{
Method: "GET",
Resource: "/api/2.0/accounts/abc/workspaces",

Response: []Workspace{},
},
},
AccountID: "abc",
Resource: DataSourceMwsWorkspaces(),
Read: true,
NonWritable: true,
ID: "_",
}.ApplyAndExpectData(t, map[string]any{
"ids": map[string]any{},
})
}

0 comments on commit 9e9c8d9

Please sign in to comment.