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

[TF-7737] Add fields for Registry Module Testing #781

Merged
merged 5 commits into from
Oct 6, 2023

Conversation

hashimoon
Copy link
Contributor

@hashimoon hashimoon commented Sep 28, 2023

Description

These changes are to support testing functionality for the Private Module Registry.

  • Receive the TestConfig object on the RegistryModule
  • Enable tests for a new RegistryModule by passing a TestConfig object with TestsEnabled set to true
  • Enable tests for an existing RegistryModule by passing a TestConfig object with TestsEnabled set to true
  • Enable switching a RegistryModule between git_tag and branch based publishing

Testing plan

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.

$ TFE_ADDRESS="https://example" TFE_TOKEN="example" go test ./... -v -run TestFunctionsAffectedByChange


=== RUN   TestRegistryModuleUpdatePrivateRegistry
=== RUN   TestRegistryModuleUpdatePrivateRegistry/enable_no-code
2023/09/29 12:39:31 [WARN] Support for using the NoCode field is deprecated as of release 1.22.0 and may be removed in a future version. The preferred way to update a no-code module is with the registryNoCodeModules.Update method.
=== RUN   TestRegistryModuleUpdatePrivateRegistry/disable_no-code
2023/09/29 12:39:31 [WARN] Support for using the NoCode field is deprecated as of release 1.22.0 and may be removed in a future version. The preferred way to update a no-code module is with the registryNoCodeModules.Update method.
=== RUN   TestRegistryModuleUpdatePrivateRegistry/toggle_between_git_tag-based_and_branch-based_publishing
--- PASS: TestRegistryModuleUpdatePrivateRegistry (5.97s)
    --- PASS: TestRegistryModuleUpdatePrivateRegistry/enable_no-code (0.30s)
    --- PASS: TestRegistryModuleUpdatePrivateRegistry/disable_no-code (0.25s)
    --- PASS: TestRegistryModuleUpdatePrivateRegistry/toggle_between_git_tag-based_and_branch-based_publishing (0.84s)
PASS
ok  	github.com/hashicorp/go-tfe	6.419s

=== RUN   TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting
=== RUN   TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_valid_options
=== RUN   TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_valid_options/tests_are_enabled
=== RUN   TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_invalid_options
=== RUN   TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_invalid_options/when_the_the_module_is_not_branch_based_and_test_are_enabled
--- PASS: TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting (5.88s)
    --- PASS: TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_valid_options (2.51s)
        --- PASS: TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_valid_options/tests_are_enabled (0.00s)
    --- PASS: TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_invalid_options (0.00s)
        --- PASS: TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting/with_invalid_options/when_the_the_module_is_not_branch_based_and_test_are_enabled (0.00s)
PASS
ok  	github.com/hashicorp/go-tfe	6.233s
...

@hashimoon hashimoon force-pushed the hashimoon/TF-7737-pmr-tests branch from 46ce2ff to c06df8b Compare September 29, 2023 16:33
@hashimoon hashimoon force-pushed the hashimoon/TF-7737-pmr-tests branch from c06df8b to e07b673 Compare September 29, 2023 19:44
@hashimoon hashimoon marked this pull request as ready for review September 29, 2023 19:45
@hashimoon hashimoon requested a review from a team as a code owner September 29, 2023 19:45
@hashimoon hashimoon force-pushed the hashimoon/TF-7737-pmr-tests branch from 3ef7098 to bfc640a Compare October 4, 2023 20:03
@uturunku1 uturunku1 dismissed nfagerlund’s stale review October 6, 2023 17:40

I'm dismissing Nick's request for changes as is blocking the PR from being merged. They are not available today. But I have taken look this PR to made sure that Joseph addressed the changes requested by Nick

@hashimoon hashimoon merged commit bd95d23 into main Oct 6, 2023
@hashimoon hashimoon deleted the hashimoon/TF-7737-pmr-tests branch October 6, 2023 17:42
@github-actions
Copy link

github-actions bot commented Oct 6, 2023

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.

Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some test failures I got locally:

2023/10/06 13:23:11 [WARN] Support for using the NoCode field is deprecated as of release 1.22.0 and may be removed in a future version. The preferred way to create a no-code module is with the registryNoCodeModules.Create method.
    registry_module_integration_test.go:157:
                Error Trace:    /Users/sebastianrivera/hashicorp/go-tfe/registry_module_integration_test.go:157
                Error:          Received unexpected error:
                                resource not found
                Test:           TestRegistryModulesCreate/with_valid_options/with_no-code_attribute
 2023/10/06 13:23:11 [WARN] Support for using the NoCode field is deprecated as of release 1.22.0 and may be removed in a future version. The preferred way to create a no-code module is with the registryNoCodeModules.Create method.
    registry_module_integration_test.go:157:
                Error Trace:    /Users/sebastianrivera/hashicorp/go-tfe/registry_module_integration_test.go:157
                Error:          Received unexpected error:
                                resource not found
                Test:           TestRegistryModulesCreate/with_valid_options/with_no-code_attribute
 2023/10/06 13:23:13 [WARN] Support for using the NoCode field is deprecated as of release 1.22.0 and may be removed in a future version. The preferred way to update a no-code module is with the registryNoCodeModules.Update method.
    registry_module_integration_test.go:283:
                Error Trace:    /Users/sebastianrivera/hashicorp/go-tfe/registry_module_integration_test.go:283
                Error:          Received unexpected error:
                                Bad jsonapi struct tag format
                Test:           TestRegistryModuleUpdate/enable_no-code
=== RUN   TestRegistryModuleUpdate/disable_no-code
2023/10/06 13:23:13 [WARN] Support for using the NoCode field is deprecated as of release 1.22.0 and may be removed in a future version. The preferred way to update a no-code module is with the registryNoCodeModules.Update method.
    registry_module_integration_test.go:298:
                Error Trace:    /Users/sebastianrivera/hashicorp/go-tfe/registry_module_integration_test.go:298
                Error:          Received unexpected error:
                                Bad jsonapi struct tag format
                Test:           TestRegistryModuleUpdate/disable_no-code

RegistryName: rm.RegistryName,
}, options)
require.NoError(t, err)
assert.Equal(t, "branch", rm.PublishingMechanism)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Equal(t, "branch", rm.PublishingMechanism)
assert.Equal(t, PublishingMechanismBranch, rm.PublishingMechanism)

💅 same for "git_tag" below.

// **Note: This field is still in BETA and subject to change.**
TestConfig *RegistryModuleTestConfigOptions `jsonapi:"attr,test-config,omitempty"`

VCSRepo *RegistryModuleVCSRepoUpdateOptions `jsonapi:"attr-vcs-repo,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
VCSRepo *RegistryModuleVCSRepoUpdateOptions `jsonapi:"attr-vcs-repo,omitempty"`
VCSRepo *RegistryModuleVCSRepoUpdateOptions `jsonapi:"attr,vcs-repo,omitempty"`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants