Skip to content

Commit

Permalink
Adding tests for TestStepConfigFunc.Exec() method (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jul 24, 2023
1 parent 4aa11b7 commit 136e47e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions config/directory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package config_test

import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/config"
)

func TestTestStepConfigFunc_Exec(t *testing.T) {
t.Parallel()

testCases := map[string]struct {
testStepConfigFunc config.TestStepConfigFunc
testStepConfigRequest config.TestStepConfigRequest
expected string
}{
"static_directory": {
testStepConfigFunc: config.StaticDirectory("name_of_directory"),
expected: "name_of_directory",
},
"test_name_directory": {
testStepConfigFunc: config.TestNameDirectory(t),
expected: "TestTestStepConfigFunc_Exec",
},
"test_step_directory": {
testStepConfigFunc: config.TestStepDirectory(t),
testStepConfigRequest: config.TestStepConfigRequest{
StepNumber: 1,
},
expected: "TestTestStepConfigFunc_Exec/1",
},
}

for name, testCase := range testCases {
name, testCase := name, testCase

t.Run(name, func(t *testing.T) {
t.Parallel()

got := testCase.testStepConfigFunc.Exec(testCase.testStepConfigRequest)

if testCase.expected != got {
t.Errorf("expected %s, got %s", testCase.expected, got)
}
})
}
}

0 comments on commit 136e47e

Please sign in to comment.