Skip to content

Conversation

@austinvalle
Copy link
Member

@austinvalle austinvalle commented Jun 16, 2023

  • Added a new test that runs off the main all command and compares a temporary test directory with the golden output directory in testdata. Moved the existing example/ir.json and used this as the first test entry.
  • Skipped comparing nested directory files in the test for now 👍🏻
  • Updated CLI parsing to use flagset to allow parallel tests to work

Example test failure if golden files mismatch with outputted files

Running tool: /opt/homebrew/bin/go test -timeout 30s -run ^TestAll$ github/hashicorp/terraform-provider-code-generator/internal/cmd

--- FAIL: TestAll (0.00s)
    --- FAIL: TestAll/basic (0.01s)
        /Users/austin.valle/code/terraform-plugin-codegen-framework/internal/cmd/cmd_test.go:46: unexpected difference in example_data_source_gen.go:   (
              	"""
              	... // 15 identical lines
              	var exampleDataSourceSchema = schema.Schema{
              		Attributes: map[string]schema.Attribute{
            + 			"fake_attribute": schema.BoolAttribute{
            + 				CustomType: my_boolattribute_type,
            + 				Optional:   true,
            + 			},
              			"bool_attribute": schema.BoolAttribute{
              				CustomType: my_boolattribute_type,
              	... // 76 identical lines
              	"""
              )
        /Users/austin.valle/code/terraform-plugin-codegen-framework/internal/cmd/cmd_test.go:46: unexpected difference in example_provider_gen.go:   (
              	"""
              	... // 7 identical lines
              	)
              	
            + 	// This comment doesn't belong here!
              	var exampleProviderSchema = schema.Schema{}
              	"""
              )
        /Users/austin.valle/code/terraform-plugin-codegen-framework/internal/cmd/cmd_test.go:46: unexpected difference in example_resource_gen.go:   (
              	"""
              	... // 13 identical lines
              	var exampleResourceSchema = schema.Schema{
              		Attributes: map[string]schema.Attribute{
            + 			"fake_attribute": schema.BoolAttribute{
            + 				CustomType: my_type,
            + 				Computed:   true,
            + 			},
              			"bool_attribute": schema.BoolAttribute{
              				CustomType: my_type,
              	... // 9 identical lines
              	"""
              )
FAIL
FAIL	github/hashicorp/terraform-provider-code-generator/internal/cmd	0.289s
FAIL

bendbennett and others added 30 commits June 6, 2023 15:40
…import is included in the top-level schema.gotmpl
Base automatically changed from schema-provider-resources to main June 21, 2023 06:59
@austinvalle austinvalle marked this pull request as ready for review June 21, 2023 13:32
@austinvalle austinvalle requested a review from a team as a code owner June 21, 2023 13:32
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

t.Parallel()

testOutputDir := t.TempDir()
mockUi := cli.NewMockUi()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. TIL there's a cli.NewMockUi().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to be updated after hashicorp/terraform-plugin-codegen-spec#26 is merged

@austinvalle austinvalle merged commit e96d729 into main Jun 21, 2023
@austinvalle austinvalle deleted the av/e2e-tests branch June 21, 2023 18:07
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants