Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add acceptance tests and ignore no such file or directory errors in cleaning rendered website dir #296

Merged
merged 15 commits into from
Nov 15, 2023

Conversation

SBGoods
Copy link
Contributor

@SBGoods SBGoods commented Nov 8, 2023

  1. Adds testscript acceptance tests for tfplugindocs generate subcommand:
  • null_provider_success: successful run of tfplugindocs on a stripped-down version of the Null provider with pre-exiting templates, examples, docs, and non-tfplugindocs managed docs (docs/cdktf subdirectory).
  • framework_provider_success_no_templates: successful run of tfplugindocs on a Framework provider with examples but no templates or pre-exiting docs.
  • framework_provider_success_named_templates: Successful run of tfplugindocs on a Framework provider with "named" template paths (i.e. templates/resources/.md.tmpl). Templates test all implemented data fields and functions.
  • framework_provider_success_generic_templates: Successful run of tfplugindocs on a Framework provider with "generic" template paths (i.e. templates/resources.md.tmpl). Templates test all implemented data fields and functions.
  1. Ignore no such file or directory errors in cleaning rendered website directory: the acceptance tests revealed a bug introduced in generate: Remove only tfplugindocs managed files and subdirectories from rendered website directory #267 where providers with no existing docs would return early with an error when deleting the rendered website directory before generation.
failing test output

[stdout]
        rendering website for provider "terraform-provider-scaffolding" (as "terraform-provider-scaffolding")
        exporting schema from Terraform
        compiling provider "scaffolding"
        using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
        running terraform init
        getting provider schema
        rendering missing docs
        generating missing resource content
        generating template for "scaffolding_example"
        generating missing data source content
        generating template for "scaffolding_example"
        generating missing provider content
        generating template for "terraform-provider-scaffolding"
        rendering static website
        cleaning rendered website dir
        [stderr]
        Error executing command: unable to generate website: open $WORK/docs: no such file or directory
        
        [exit status 1]
        FAIL: testdata/scripts/generate/framework_provider_success_no_templates.txtar:4: unexpected command failure
        
    --- FAIL: Test_GenerateAcceptanceTests/framework_provider_success_no_templates (21.02s)

This PR includes a fix to ignore that specific error and not return early.

  1. Add unit tests to test resourceTemplate.Render and providerTemplate.Render

@SBGoods SBGoods requested a review from a team as a code owner November 8, 2023 21:58
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Please reach out with any questions!

GNUmakefile Show resolved Hide resolved
cmd/build/version.go Outdated Show resolved Hide resolved
cmd/tfplugindocs/main_test.go Show resolved Hide resolved
cmd/tfplugindocs/main_test.go Show resolved Hide resolved
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

After this should be good to go!

@bflad bflad added this to the v0.17.0 milestone Nov 10, 2023
@SBGoods SBGoods requested a review from bflad November 14, 2023 17:56
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Looks good to me 🚀

@@ -146,6 +146,7 @@ using the following data fields and functions:
| `.ProviderName` | string | Canonical provider name (ex. `terraform-provider-random`) |
| `.ProviderShortName` | string | Short version of the provider name (ex. `random`) |
| `.RenderedProviderName` | string | Value provided via argument `--rendered-provider-name`, otherwise same as `.ProviderName` |
| `.SchemaMarkdown` | string | a Markdown formatted Provider Schema definition |
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@@ -170,6 +172,7 @@ using the following data fields and functions:
| `lower` | Equivalent to [`strings.ToLower`](https://pkg.go.dev/strings#ToLower). |
| `plainmarkdown` | Render Markdown content as plaintext. |
| `prefixlines` | Add a prefix to all (newline-separated) lines in a string. |
| `printf` | Equivalent to [`fmt.Printf`](https://pkg.go.dev/fmt#Printf). |
Copy link
Contributor

Choose a reason for hiding this comment

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

❤️

@SBGoods SBGoods merged commit 177a0a2 into main Nov 15, 2023
5 checks passed
@SBGoods SBGoods deleted the SBGoods/acceptance-tests branch November 15, 2023 17:01
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