def test_all(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', workspace='test', var='myvar=hello', var_file='vars.tf', backend_config='bucket=mybucket,password=secret', backend_config_file='backend.tf' ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan in __/test/terraform__ in the __test__ workspace With backend config: `bucket=mybucket` With backend config files: `backend.tf` With vars: `myvar=hello` With var files: `vars.tf` ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected
def test_path_only(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan in __/test/terraform__ ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected
def test_nondefault_workspace(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', workspace='myworkspace' ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan in __/test/terraform__ in the __myworkspace__ workspace ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected
def test_var_file(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', var_file='vars.tf' ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan in __/test/terraform__ With var files: `vars.tf` ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected
def test_backend_config_file(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', backend_config_file='backend.tf' ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan in __/test/terraform__ With backend config files: `backend.tf` ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected
def test_backend_config_bad_words(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', backend_config='bucket=test,password=secret,key=backend,token=secret' ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan in __/test/terraform__ With backend config: `bucket=test,key=backend` ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected
def test_label(monkeypatch): setup_comment(monkeypatch, path='/test/terraform', workspace='test', var='myvar=hello', var_file='vars.tf', backend_config='bucket=mybucket,password=secret', backend_config_file='backend.tf', label='test_label' ) comment = TerraformComment() comment.plan = 'Hello, this is my plan' comment.status = 'Testing' expected = '''Terraform plan for __test_label__ ```hcl Hello, this is my plan ``` Testing''' assert comment.body() == expected