Skip to content

Commit

Permalink
Merge pull request #74 from terraform-providers/svh/b-data-workspace
Browse files Browse the repository at this point in the history
Set the correct workspace ID
  • Loading branch information
Sander van Harmelen authored Apr 8, 2019
2 parents 3179be9 + 879d614 commit af9fd8e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion tfe/data_source_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,12 @@ func dataSourceTFEWorkspaceRead(d *schema.ResourceData, meta interface{}) error
}
d.Set("vcs_repo", vcsRepo)

d.SetId(workspace.ID)
id, err := packWorkspaceID(workspace)
if err != nil {
return fmt.Errorf("Error creating ID for workspace %s: %v", name, err)
}

d.SetId(id)

return nil
}
6 changes: 5 additions & 1 deletion tfe/data_source_workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ func TestAccTFEWorkspaceDataSource_basic(t *testing.T) {
{
Config: testAccTFEWorkspaceDataSourceConfig(rInt),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr(
"data.tfe_workspace.foobar",
"id",
fmt.Sprintf("terraform-test-%d/workspace-test-%d", rInt, rInt),
),
resource.TestCheckResourceAttr(
"data.tfe_workspace.foobar", "name", fmt.Sprintf("workspace-test-%d", rInt)),
resource.TestCheckResourceAttr(
Expand All @@ -31,7 +36,6 @@ func TestAccTFEWorkspaceDataSource_basic(t *testing.T) {
"data.tfe_workspace.foobar", "terraform_version", "0.11.1"),
resource.TestCheckResourceAttr(
"data.tfe_workspace.foobar", "working_directory", "terraform/test"),
resource.TestCheckResourceAttrSet("data.tfe_workspace.foobar", "id"),
resource.TestCheckResourceAttrSet("data.tfe_workspace.foobar", "external_id"),
),
},
Expand Down

0 comments on commit af9fd8e

Please sign in to comment.