Skip to content

Commit

Permalink
Adding test coverage to verify package name can be overridden by supp…
Browse files Browse the repository at this point in the history
…lying --package flag (#20)
  • Loading branch information
bendbennett committed Sep 4, 2023
1 parent 0abce4a commit 5cc4e99
Show file tree
Hide file tree
Showing 8 changed files with 7,787 additions and 6 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ generate:
testdata:
go run ./cmd/terraform-plugin-codegen-framework generate all \
--input ./internal/cmd/testdata/custom_and_external/ir.json \
--package generated \
--output ./internal/cmd/testdata/custom_and_external/all_output
--package specified \
--output ./internal/cmd/testdata/custom_and_external/all_output/specified_pkg_name

go run ./cmd/terraform-plugin-codegen-framework generate all \
--input ./internal/cmd/testdata/custom_and_external/ir.json \
--output ./internal/cmd/testdata/custom_and_external/all_output/default_pkg_name

go run ./cmd/terraform-plugin-codegen-framework generate resources \
--input ./internal/cmd/testdata/custom_and_external/ir.json \
Expand Down
15 changes: 11 additions & 4 deletions internal/cmd/generate_all_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,27 @@ package cmd_test
import (
"testing"

"github.com/hashicorp/terraform-plugin-codegen-framework/internal/cmd"
"github.com/mitchellh/cli"

"github.com/hashicorp/terraform-plugin-codegen-framework/internal/cmd"
)

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

testCases := map[string]struct {
irInputPath string
pkgName string
goldenFileDir string
}{
"custom_and_external": {
"specified_pkg_name": {
irInputPath: "testdata/custom_and_external/ir.json",
pkgName: "specified",
goldenFileDir: "testdata/custom_and_external/all_output/specified_pkg_name",
},
"default_pkg_name": {
irInputPath: "testdata/custom_and_external/ir.json",
goldenFileDir: "testdata/custom_and_external/all_output",
goldenFileDir: "testdata/custom_and_external/all_output/default_pkg_name",
},
}
for name, testCase := range testCases {
Expand All @@ -35,7 +42,7 @@ func TestGenerateAllCommand(t *testing.T) {

args := []string{
"--input", testCase.irInputPath,
"--package", "generated",
"--package", testCase.pkgName,
"--output", testOutputDir,
}

Expand Down
Loading

0 comments on commit 5cc4e99

Please sign in to comment.