Skip to content

Commit

Permalink
Workspace object includes project
Browse files Browse the repository at this point in the history
  • Loading branch information
mwudka authored and hs26gill committed Nov 1, 2022
1 parent aeb3807 commit 9055a41
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions workspace.go
Expand Up @@ -157,6 +157,7 @@ type Workspace struct {
Organization *Organization `jsonapi:"relation,organization"`
SSHKey *SSHKey `jsonapi:"relation,ssh-key"`
Outputs []*WorkspaceOutputs `jsonapi:"relation,outputs"`
Project *Project `jsonapi:"relation,project"`
Tags []*Tag `jsonapi:"relation,tags"`
}

Expand Down
34 changes: 34 additions & 0 deletions workspace_integration_test.go
Expand Up @@ -2097,3 +2097,37 @@ func TestWorkspacesRunTasksPermission(t *testing.T) {
assert.True(t, w.Permissions.CanManageRunTasks)
})
}

func TestWorkspacesProjects(t *testing.T) {
skipIfNotCINode(t)
skipIfBeta(t)
client := testClient(t)
ctx := context.Background()

orgTest, orgTestCleanup := createOrganization(t, client)
defer orgTestCleanup()

wTest, wTestCleanup := createWorkspace(t, client, orgTest)
defer wTestCleanup()

// TODO: Assert specific project ID once we can read the org default project

t.Run("created workspace includes project ID", func(t *testing.T) {
assert.NotNil(t, wTest.Project.ID)
})

t.Run("read workspace includes project ID", func(t *testing.T) {
workspace, err := client.Workspaces.ReadByID(ctx, wTest.ID)
assert.NoError(t, err)
assert.NotNil(t, workspace.Project.ID)
})

t.Run("list workspace includes project ID", func(t *testing.T) {
workspaces, err := client.Workspaces.List(ctx, orgTest.Name, &WorkspaceListOptions{})
assert.NoError(t, err)
for idx, item := range workspaces.Items {
assert.NotNil(t, item.Project.ID, "No project ID set on workspace %s at idx %d", item.ID, idx)
}
})

}

0 comments on commit 9055a41

Please sign in to comment.