Skip to content

Commit

Permalink
Fix integration tests gitlab template (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
avnerenv0 committed Feb 23, 2022
1 parent 5a2ce2a commit 9f3612b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ Afterwards, when cleanup is required, just set `DESTROY_MODE` to `DESTROY_ONLY`
#### Integration Test Prerequisites
- An env0 organization
- An API Key
- A Github.com integrated template name `Github Integrated Template` for suite 004_template
- A Github.com integrated template name `Github Integrated Template` for https://github.com/env0/templates
- A Gitlab.com integrated template name `Gitlab Integrated Template` for https://gitlab.com/env0/gitlab-vcs-integration-tests

### Unit Testing
#### How to run tests
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/004_template/expected_outputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"tested2_template_type": "terraform",
"tested2_template_name": "tested1",
"tested2_template_repository": "https://github.com/env0/templates",
"tested1_template_repository": "https://gitlab.com/eran.elbaz/templates.git",
"tested1_template_repository": "https://gitlab.com/env0/gitlab-vcs-integration-tests.git",
"tested2_template_path": "second"
}
}
14 changes: 11 additions & 3 deletions tests/integration/004_template/main.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
# Github Integration must be done manually - so we expect an existing Github Template with this name -
# It must be for https://github.com/env0/templates - We validate that in the outputs
data "env0_template" "github_template" {
name = "Github Integrated Template"
}

# Gitlab Integration must be done manually - so we expect an existing Gitlab Template with this name
# It must be for https://gitlab.com/env0/gitlab-vcs-integration-tests - the gitlab_project_id is still static
data "env0_template" "gitlab_template" {
name = "Gitlab Integrated Template"
}

resource "env0_template" "tested1" {
name = "tested1"
description = "Tested 1 description"
Expand All @@ -20,9 +27,9 @@ resource "env0_template" "tested2" {
name = "GitLab Test"
description = "Tested 2 description - Gitlab"
type = "terraform"
repository = "https://gitlab.com/eran.elbaz/templates.git"
token_id = "6be35256-b685-4e92-8f6b-a332f5832c06"
gitlab_project_id = 28713760
repository = data.env0_template.gitlab_template.repository
token_id = data.env0_template.gitlab_template.token_id
gitlab_project_id = 32315446
path = var.second_run ? "second" : "misc/null-resource"
retries_on_deploy = 3
retry_on_deploy_only_when_matches_regex = "abc"
Expand Down Expand Up @@ -75,3 +82,4 @@ output "tested2_template_path" {
data "env0_template" "tested3" {
id = env0_template.tested1.id
}

0 comments on commit 9f3612b

Please sign in to comment.