-
Notifications
You must be signed in to change notification settings - Fork 103
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
Allow FileTriggersEnabled to be set to false when Git tags are present #468
Conversation
a9a5f59
to
ce28630
Compare
workspace.go
Outdated
if o.VCSRepo != nil && o.VCSRepo.TagsRegex != nil && | ||
o.FileTriggersEnabled != nil && *o.FileTriggersEnabled { | ||
if o.VCSRepo != nil && o.VCSRepo.TagsRegex != nil && *o.VCSRepo.TagsRegex != "" && | ||
o.FileTriggersEnabled != nil && *o.FileTriggersEnabled == true { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not just leave it as *o.FileTriggersEnabled
@@ -414,6 +413,18 @@ func TestWorkspacesCreate(t *testing.T) { | |||
assert.EqualError(t, err, ErrUnsupportedBothTagsRegexAndFileTriggersEnabled.Error()) | |||
}) | |||
|
|||
t.Run("when options include both non-empty tags-regex and file-triggers-enabled as false an error is not returned", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: We could use table driven tests and merge together this and the above 3 tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hashimoon We're good with adding table driven tests here - agree that it would help readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the rest of the file is not utilizing table driven tests and the style is consistent with what is already present, can we add them in a future refactor? @annawinkler
@@ -890,6 +900,18 @@ func TestWorkspacesUpdate(t *testing.T) { | |||
assert.EqualError(t, err, ErrUnsupportedBothTagsRegexAndFileTriggersEnabled.Error()) | |||
}) | |||
|
|||
t.Run("when options include both non-empty tags-regex and file-triggers-enabled an error is returned", func(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one could be a table driven test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to clarify with the CLI team how we'd like to handle beta features because I think there have been some inconsistencies in the past. It was my understanding we don't want to include features until they are GA.
Could you please add a few steps to the test plan so someone unfamiliar with this change can test/verify locally? Thank you! ⭐
5f392a8
to
2fa1542
Compare
07c9486
to
6e9d327
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm OK with refactoring the tests in a separate PR.
Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes. |
Description
File triggers must be disabled when enabling Git tags, so both
FileTriggersEnabled
andTagsRegex
need to support being configured at the same time.Testing plan
Creating A Workspace
WorkspaceCreateOptions
structFileTriggersEnabled
totrue
VCSRepoOptions
structTagsRegex
to "v-1"WorkspaceCreateOptions
struct, setVCSRepo
equal toVCSRepoOptions
FileTriggersEnabled
tofalse
Updating A Workspace
WorkspaceUpdateOptions
structFileTriggersEnabled
totrue
VCSRepoOptions
structTagsRegex
to "v-1"WorkspaceUpdateOptions
struct, setVCSRepo
equal toVCSRepoOptions
FileTriggersEnabled
tofalse
External links
Output from tests
Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.