generated from masterpointio/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add remaining VCS integrations #98
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
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,183 @@ | ||
| mock_provider "spacelift" { | ||
| mock_data "spacelift_spaces" { | ||
| defaults = { | ||
| spaces = [] | ||
| } | ||
| } | ||
|
|
||
| mock_data "spacelift_worker_pools" { | ||
| defaults = { | ||
| worker_pools = [] | ||
| } | ||
| } | ||
|
|
||
| mock_data "spacelift_aws_integrations" { | ||
| defaults = { | ||
| integrations = [] | ||
| } | ||
| } | ||
| } | ||
|
|
||
| mock_provider "jsonschema" { | ||
| mock_data "jsonschema_validator" { | ||
| defaults = { | ||
| validated = "{}" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| variables { | ||
| root_modules_path = "./tests/fixtures/multi-instance" | ||
| common_config_file = "common.yaml" | ||
| repository = "terraform-spacelift-automation" | ||
| all_root_modules_enabled = true | ||
| aws_integration_enabled = false | ||
| } | ||
|
|
||
| # Test github_enterprise dynamic block is created correctly | ||
| run "test_github_enterprise_integration" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| github_enterprise = { | ||
| namespace = "masterpointio" | ||
| id = "test-gh-enterprise-id" | ||
| } | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].github_enterprise[0].namespace == "masterpointio" | ||
| error_message = "GitHub Enterprise namespace was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].github_enterprise)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].github_enterprise[0].id == "test-gh-enterprise-id" | ||
| error_message = "GitHub Enterprise id was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].github_enterprise)}" | ||
| } | ||
| } | ||
|
|
||
| # Test raw_git dynamic block is created correctly | ||
| run "test_raw_git_integration" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| raw_git = { | ||
| namespace = "my-git-namespace" | ||
| url = "https://git.example.com/repo.git" | ||
| } | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].raw_git[0].namespace == "my-git-namespace" | ||
| error_message = "Raw Git namespace was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].raw_git)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].raw_git[0].url == "https://git.example.com/repo.git" | ||
| error_message = "Raw Git url was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].raw_git)}" | ||
| } | ||
| } | ||
|
|
||
| # Test gitlab dynamic block is created correctly | ||
| run "test_gitlab_integration" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| gitlab = { | ||
| namespace = "my-gitlab-group" | ||
| id = "test-gitlab-id" | ||
| } | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].gitlab[0].namespace == "my-gitlab-group" | ||
| error_message = "GitLab namespace was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].gitlab)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].gitlab[0].id == "test-gitlab-id" | ||
| error_message = "GitLab id was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].gitlab)}" | ||
| } | ||
| } | ||
|
|
||
| # Test bitbucket_cloud dynamic block is created correctly | ||
| run "test_bitbucket_cloud_integration" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| bitbucket_cloud = { | ||
| namespace = "my-bitbucket-project" | ||
| id = "test-bb-cloud-id" | ||
| } | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].bitbucket_cloud[0].namespace == "my-bitbucket-project" | ||
| error_message = "Bitbucket Cloud namespace was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].bitbucket_cloud)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].bitbucket_cloud[0].id == "test-bb-cloud-id" | ||
| error_message = "Bitbucket Cloud id was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].bitbucket_cloud)}" | ||
| } | ||
| } | ||
|
|
||
| # Test bitbucket_datacenter dynamic block is created correctly | ||
| run "test_bitbucket_datacenter_integration" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| bitbucket_datacenter = { | ||
| namespace = "my-bitbucket-dc-project" | ||
| id = "test-bb-dc-id" | ||
| } | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].bitbucket_datacenter[0].namespace == "my-bitbucket-dc-project" | ||
| error_message = "Bitbucket Data Center namespace was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].bitbucket_datacenter)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = spacelift_stack.default["root-module-a-test"].bitbucket_datacenter[0].id == "test-bb-dc-id" | ||
| error_message = "Bitbucket Data Center id was not set correctly: ${jsonencode(spacelift_stack.default["root-module-a-test"].bitbucket_datacenter)}" | ||
| } | ||
| } | ||
|
|
||
| # Test that VCS blocks are empty when variables are null | ||
| run "test_vcs_blocks_empty_when_null" { | ||
| command = plan | ||
|
|
||
| variables { | ||
| github_enterprise = null | ||
| raw_git = null | ||
| gitlab = null | ||
| bitbucket_cloud = null | ||
| bitbucket_datacenter = null | ||
| } | ||
|
|
||
| assert { | ||
| condition = length(spacelift_stack.default["root-module-a-test"].github_enterprise) == 0 | ||
| error_message = "GitHub Enterprise block should be empty when variable is null: ${jsonencode(spacelift_stack.default["root-module-a-test"].github_enterprise)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = length(spacelift_stack.default["root-module-a-test"].raw_git) == 0 | ||
| error_message = "Raw Git block should be empty when variable is null: ${jsonencode(spacelift_stack.default["root-module-a-test"].raw_git)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = length(spacelift_stack.default["root-module-a-test"].gitlab) == 0 | ||
| error_message = "GitLab block should be empty when variable is null: ${jsonencode(spacelift_stack.default["root-module-a-test"].gitlab)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = length(spacelift_stack.default["root-module-a-test"].bitbucket_cloud) == 0 | ||
| error_message = "Bitbucket Cloud block should be empty when variable is null: ${jsonencode(spacelift_stack.default["root-module-a-test"].bitbucket_cloud)}" | ||
| } | ||
|
|
||
| assert { | ||
| condition = length(spacelift_stack.default["root-module-a-test"].bitbucket_datacenter) == 0 | ||
| error_message = "Bitbucket Data Center block should be empty when variable is null: ${jsonencode(spacelift_stack.default["root-module-a-test"].bitbucket_datacenter)}" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
PR looks good. Hmm I'm just thinking about the tests. I'm not sure how much to justify it because it is mostly just declarative (as there's not much to test, just that namespace = github.lab["namespace"], and it's the same for GitHub, BitBucket, etc. Since the code is kinda just replicating the Terraform Spacelift provider directly, it's not really validating anything I'm thinking?
I guess it doesn't hurt and it's easy to generate, prevents breaking things in the future?
What are your thoughts?
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 had a similar question. I think there are 2 things worth testing,
idfield is correctly handled (see thetest_gitlab_integration_id_is_nulltest)