Skip to content

Commit

Permalink
Update generate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SBGoods committed Oct 16, 2024
1 parent b514f03 commit 426f4c8
Show file tree
Hide file tree
Showing 9 changed files with 1,021 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ generating new template for "scaffolding_example"
generating missing data source content
generating missing function content
generating new template for function "scaffolding"
generating missing ephemeral resource content
generating missing provider content
generating new template for "terraform-provider-scaffolding"
rendering static website
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ cmpenv docs/index.md expected-index.md
cmpenv docs/data-sources/example.md expected-datasource.md
cmpenv docs/resources/example.md expected-resource.md
cmpenv docs/functions/example.md expected-function.md
cmpenv docs/ephemeral-resources/example.md expected-ephemeral-resource.md


-- expected-output.txt --
Expand All @@ -24,12 +25,15 @@ generating missing data source content
data-source "scaffolding_example" fallback template exists, creating template
generating missing function content
function "example" fallback template exists, creating template
generating missing ephemeral resource content
ephemeral resource "scaffolding_example" fallback template exists, creating template
generating missing provider content
provider "terraform-provider-scaffolding" template exists, skipping
rendering static website
cleaning rendered website dir
rendering templated website to static markdown
rendering "data-sources/example.md.tmpl"
rendering "ephemeral-resources/example.md.tmpl"
rendering "functions/example.md.tmpl"
rendering "index.md.tmpl"
rendering "resources/example.md.tmpl"
Expand Down Expand Up @@ -239,6 +243,63 @@ Import is supported using the following syntax:
terraform import scaffolding_example.example
```

tffile:
## Example Usage

```terraform
resource "scaffolding_example" "example" {
configurable_attribute = "some-value"
}
```
-- expected-ephemeral-resource.md --
# Data Fields

Name: scaffolding_example
Type: Ephemeral Resource
Description: Example ephemeral resource
HasExample: true
ExampleFile: $WORK/examples/ephemeral-resources/scaffolding_example/ephemeral-resource.tf
HasImport: false
ProviderName: terraform-provider-scaffolding
ProviderShortName: scaffolding
RenderedProviderName: terraform-provider-scaffolding
SchemaMarkdown: <!-- schema generated by tfplugindocs -->
## Schema

### Optional

- `configurable_attribute` (String) Example configurable attribute
- `defaulted` (String) Example configurable attribute with default value

### Read-Only

- `id` (String) Example identifier



# Functions

lower: ephemeral resource
plainmarkdown: Ephemeral Resource
prefixlines: Prefix: Ephemeral Resource
split: [scaffolding example]
title: Ephemeral Resource
trimspace: Ephemeral Resource
upper: EPHEMERAL RESOURCE

# Conditionals and File Functions

printf codefile:


printf tffile:
## Example Usage

{{tffile "$WORK/examples/ephemeral-resources/scaffolding_example/ephemeral-resource.tf"}}

codefile:


tffile:
## Example Usage

Expand Down Expand Up @@ -438,6 +499,63 @@ tffile:
{{ if .HasExample -}}
## Example Usage

{{tffile .ExampleFile }}
{{- end }}
-- templates/ephemeral-resources.md.tmpl --
# Data Fields

Name: {{.Name}}
Type: {{.Type}}
Description: {{.Description}}
HasExample: {{.HasExample}}
ExampleFile: {{.ExampleFile}}
HasImport: {{.HasImport}}
ProviderName: {{.ProviderName}}
ProviderShortName: {{.ProviderShortName}}
RenderedProviderName: {{.RenderedProviderName}}
SchemaMarkdown: {{.SchemaMarkdown}}

# Functions

lower: {{ .Type | lower }}
plainmarkdown: {{ .Type | plainmarkdown }}
prefixlines: {{ .Type | prefixlines "Prefix: " }}
split: {{ split .Name "_" }}
title: {{ .Type | title }}
trimspace: {{ .Type | trimspace }}
upper: {{ .Type | upper }}

# Conditionals and File Functions

printf codefile:
{{ if .HasImport -}}
## Import

Import is supported using the following syntax:

{{ printf "{{codefile \"shell\" %q}}" .ImportFile }}
{{- end }}

printf tffile:
{{ if .HasExample -}}
## Example Usage

{{ printf "{{tffile %q}}" .ExampleFile }}
{{- end }}

codefile:
{{ if .HasImport -}}
## Import

Import is supported using the following syntax:

{{codefile "shell" .ImportFile }}
{{- end }}

tffile:
{{ if .HasExample -}}
## Example Usage

{{tffile .ExampleFile }}
{{- end }}
-- examples/README.md --
Expand Down Expand Up @@ -468,98 +586,132 @@ resource "scaffolding_example" "example" {
}
-- examples/resources/scaffolding_example/import.sh --
terraform import scaffolding_example.example
-- examples/ephemeral-resources/scaffolding_example/ephemeral-resource.tf --
resource "scaffolding_example" "example" {
configurable_attribute = "some-value"
}
-- schema.json --
{
"format_version": "1.0",
"provider_schemas": {
"registry.terraform.io/hashicorp/scaffolding": {
"provider": {
"version": 0,
"block": {
"attributes": {
"endpoint": {
"type": "string",
"description": "Example provider attribute",
"description_kind": "markdown",
"optional": true
}
},
"description": "Example provider",
"description_kind": "markdown"
}
},
"resource_schemas": {
"scaffolding_example": {
"version": 0,
"block": {
"attributes": {
"configurable_attribute": {
"type": "string",
"description": "Example configurable attribute",
"description_kind": "markdown",
"optional": true
},
"defaulted": {
"type": "string",
"description": "Example configurable attribute with default value",
"description_kind": "markdown",
"optional": true,
"computed": true
},
"id": {
"type": "string",
"description": "Example identifier",
"description_kind": "markdown",
"computed": true
}
"format_version": "1.0",
"provider_schemas": {
"registry.terraform.io/hashicorp/scaffolding": {
"provider": {
"version": 0,
"block": {
"attributes": {
"endpoint": {
"type": "string",
"description": "Example provider attribute",
"description_kind": "markdown",
"optional": true
}
},
"description": "Example provider",
"description_kind": "markdown"
}
},
"description": "Example resource",
"description_kind": "markdown"
}
}
},
"data_source_schemas": {
"scaffolding_example": {
"version": 0,
"block": {
"attributes": {
"configurable_attribute": {
"type": "string",
"description": "Example configurable attribute",
"description_kind": "markdown",
"optional": true
},
"id": {
"type": "string",
"description": "Example identifier",
"description_kind": "markdown",
"computed": true
}
"resource_schemas": {
"scaffolding_example": {
"version": 0,
"block": {
"attributes": {
"configurable_attribute": {
"type": "string",
"description": "Example configurable attribute",
"description_kind": "markdown",
"optional": true
},
"defaulted": {
"type": "string",
"description": "Example configurable attribute with default value",
"description_kind": "markdown",
"optional": true,
"computed": true
},
"id": {
"type": "string",
"description": "Example identifier",
"description_kind": "markdown",
"computed": true
}
},
"description": "Example resource",
"description_kind": "markdown"
}
}
},
"description": "Example data source",
"description_kind": "markdown"
}
}
},
"functions": {
"example": {
"description": "Given a string value, returns the same value.",
"summary": "Echo a string",
"return_type": "string",
"parameters": [
{
"name": "input",
"description": "Value to echo.",
"type": "string"
"ephemeral_resource_schemas": {
"scaffolding_example": {
"version": 0,
"block": {
"attributes": {
"configurable_attribute": {
"type": "string",
"description": "Example configurable attribute",
"description_kind": "markdown",
"optional": true
},
"defaulted": {
"type": "string",
"description": "Example configurable attribute with default value",
"description_kind": "markdown",
"optional": true,
"computed": true
},
"id": {
"type": "string",
"description": "Example identifier",
"description_kind": "markdown",
"computed": true
}
},
"description": "Example ephemeral resource",
"description_kind": "markdown"
}
}
},
"data_source_schemas": {
"scaffolding_example": {
"version": 0,
"block": {
"attributes": {
"configurable_attribute": {
"type": "string",
"description": "Example configurable attribute",
"description_kind": "markdown",
"optional": true
},
"id": {
"type": "string",
"description": "Example identifier",
"description_kind": "markdown",
"computed": true
}
},
"description": "Example data source",
"description_kind": "markdown"
}
}
},
"functions": {
"example": {
"description": "Given a string value, returns the same value.",
"summary": "Echo a string",
"return_type": "string",
"parameters": [
{
"name": "input",
"description": "Value to echo.",
"type": "string"
}
],
"variadic_parameter": {
"name": "variadicInput",
"description": "Variadic input to echo.",
"type": "string"
}
}
}
],
"variadic_parameter": {
"name": "variadicInput",
"description": "Variadic input to echo.",
"type": "string"
}
}
}
}
}
}
Loading

0 comments on commit 426f4c8

Please sign in to comment.