Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes project names being validated as IDs #608

Merged
merged 1 commit into from Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
@@ -1,7 +1,9 @@
# Unreleased
# v1.15.1

## Bug Fixes

* Project names were being incorrectly validated as ID's @brandonc [#608](https://github.com/hashicorp/go-tfe/pull/608)

## Enhancements

# v1.15.0
Expand Down
7 changes: 0 additions & 7 deletions project.go
Expand Up @@ -203,16 +203,9 @@ func (o ProjectCreateOptions) valid() error {
if !validString(&o.Name) {
return ErrRequiredName
}

if !validStringID(&o.Name) {
return ErrInvalidName
}
return nil
}

func (o ProjectUpdateOptions) valid() error {
if o.Name != nil && !validStringID(o.Name) {
return ErrInvalidName
}
return nil
}
6 changes: 3 additions & 3 deletions projects_integration_test.go
Expand Up @@ -123,7 +123,7 @@ func TestProjectsCreate(t *testing.T) {
Name: badIdentifier,
})
assert.Nil(t, w)
assert.EqualError(t, err, ErrInvalidName.Error())
assert.Contains(t, err.Error(), "invalid attribute\n\nName may only contain")
uturunku1 marked this conversation as resolved.
Show resolved Hide resolved
})

t.Run("when options has an invalid organization", func(t *testing.T) {
Expand All @@ -149,7 +149,7 @@ func TestProjectsUpdate(t *testing.T) {
defer kTestCleanup()

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

Expand All @@ -165,7 +165,7 @@ func TestProjectsUpdate(t *testing.T) {
Name: String(badIdentifier),
})
assert.Nil(t, kAfter)
assert.EqualError(t, err, ErrInvalidName.Error())
assert.Contains(t, err.Error(), "invalid attribute\n\nName may only contain")
})

t.Run("without a valid projects ID", func(t *testing.T) {
Expand Down