Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denis256 committed Oct 5, 2023
1 parent 4ce45e1 commit 86c5f64
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion modules/terraform/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package terraform
import (
"fmt"
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/files"
Expand Down Expand Up @@ -79,8 +80,10 @@ func TestInitAndPlanWithPlanFile(t *testing.T) {

out, err := InitAndPlanE(t, options)
require.NoError(t, err)
// clean output to be consistent in checks
out = strings.ReplaceAll(out, "\n", "")
assert.Contains(t, out, "1 to add, 0 to change, 0 to destroy.")
assert.Contains(t, out, fmt.Sprintf("Saved the plan to: %s", planFilePath))
assert.Contains(t, out, fmt.Sprintf("Saved the plan to:%s", planFilePath))
assert.FileExists(t, planFilePath, "Plan file was not saved to expected location:", planFilePath)
}

Expand Down
7 changes: 5 additions & 2 deletions modules/terraform/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package terraform
import (
"fmt"
"path/filepath"
"strings"
"testing"

"github.com/gruntwork-io/terratest/modules/files"
Expand All @@ -25,7 +26,8 @@ func TestShowWithInlinePlan(t *testing.T) {
}

out := InitAndPlan(t, options)
require.Contains(t, out, fmt.Sprintf("Saved the plan to: %s", planFilePath))
out = strings.ReplaceAll(out, "\n", "")
require.Contains(t, out, fmt.Sprintf("Saved the plan to:%s", planFilePath))
require.FileExists(t, planFilePath, "Plan file was not saved to expected location:", planFilePath)

// show command does not accept Vars
Expand Down Expand Up @@ -55,7 +57,8 @@ func TestShowWithStructInlinePlan(t *testing.T) {
}

out := InitAndPlan(t, options)
require.Contains(t, out, fmt.Sprintf("Saved the plan to: %s", planFilePath))
out = strings.ReplaceAll(out, "\n", "")
require.Contains(t, out, fmt.Sprintf("Saved the plan to:%s", planFilePath))
require.FileExists(t, planFilePath, "Plan file was not saved to expected location:", planFilePath)

// show command does not accept Vars
Expand Down

0 comments on commit 86c5f64

Please # to comment.