Skip to content

Commit

Permalink
Merge pull request #861 from hashicorp/Netra2104/TF-11505-add-descrip…
Browse files Browse the repository at this point in the history
…tion-to-project-resource

TF-11505 Add description to project resource
  • Loading branch information
netramali committed Feb 29, 2024
2 parents 5acc29f + 97dd088 commit ab87915
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Unreleased

## Enhancements
* Adds `description` attribute to `Project` by @netramali [861](https://github.com/hashicorp/go-tfe/pull/861)

# v1.46.0

## Enhancements
Expand Down
11 changes: 11 additions & 0 deletions project.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type Project struct {
ID string `jsonapi:"primary,projects"`
Name string `jsonapi:"attr,name"`

// **Note: This field is still in BETA and subject to change.**
Description string `jsonapi:"attr,description"`

// Relations
Organization *Organization `jsonapi:"relation,organization"`
}
Expand Down Expand Up @@ -76,6 +79,10 @@ type ProjectCreateOptions struct {

// Required: A name to identify the project.
Name string `jsonapi:"attr,name"`

// Optional: A description for the project.
// **Note: This field is still in BETA and subject to change.**
Description *string `jsonapi:"attr,description,omitempty"`
}

// ProjectUpdateOptions represents the options for updating a project
Expand All @@ -88,6 +95,10 @@ type ProjectUpdateOptions struct {

// Optional: A name to identify the project
Name *string `jsonapi:"attr,name,omitempty"`

// Optional: A description for the project.
// **Note: This field is still in BETA and subject to change.**
Description *string `jsonapi:"attr,description,omitempty"`
}

// List all projects.
Expand Down
10 changes: 8 additions & 2 deletions projects_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,10 @@ func TestProjectsCreate(t *testing.T) {
defer orgTestCleanup()

t.Run("with valid options", func(t *testing.T) {
skipUnlessBeta(t)
options := ProjectCreateOptions{
Name: "foo",
Name: "foo",
Description: String("qux"),
}

w, err := client.Projects.Create(ctx, orgTest.Name, options)
Expand All @@ -118,6 +120,7 @@ func TestProjectsCreate(t *testing.T) {
} {
assert.NotEmpty(t, item.ID)
assert.Equal(t, options.Name, item.Name)
assert.Equal(t, *options.Description, item.Description)
}
})

Expand Down Expand Up @@ -152,16 +155,19 @@ func TestProjectsUpdate(t *testing.T) {
defer orgTestCleanup()

t.Run("with valid options", func(t *testing.T) {
skipUnlessBeta(t)
kBefore, kTestCleanup := createProject(t, client, orgTest)
defer kTestCleanup()

kAfter, err := client.Projects.Update(ctx, kBefore.ID, ProjectUpdateOptions{
Name: String("new project name"),
Name: String("new project name"),
Description: String("updated description"),
})
require.NoError(t, err)

assert.Equal(t, kBefore.ID, kAfter.ID)
assert.NotEqual(t, kBefore.Name, kAfter.Name)
assert.NotEqual(t, kBefore.Description, kAfter.Description)
})

t.Run("when updating with invalid name", func(t *testing.T) {
Expand Down

0 comments on commit ab87915

Please sign in to comment.