Skip to content

Commit

Permalink
Add test coverage for new comment in frontmatter
Browse files Browse the repository at this point in the history
  • Loading branch information
guineveresaenger committed Oct 24, 2024
1 parent 1ffc289 commit dda50da
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/tfgen/installation_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,8 @@ func plainDocsParser(docFile *DocFile, g *Generator) ([]byte, error) {
// Determine if we should write an overview header.
overviewHeader := getOverviewHeader(content)

autoGenMessage := fmt.Sprint(
"<!-- *** WARNING: This file was auto-generated. " +
"Do not edit by hand unless you're certain you know what you are doing! *** -->\n")

// Add instructions to top of file
contentStr := frontMatter + autoGenMessage + installationInstructions + overviewHeader + string(content)
contentStr := frontMatter + installationInstructions + overviewHeader + string(content)

//Translate code blocks to Pulumi
contentStr, err = translateCodeBlocks(contentStr, g)
Expand Down Expand Up @@ -86,8 +82,9 @@ func writeFrontMatter(providerName string) string {
// Capitalize the package name
capitalize := cases.Title(language.English)
title := capitalize.String(providerName)

return fmt.Sprintf(delimiter+
"# *** WARNING: This file was auto-generated. "+
"Do not edit by hand unless you're certain you know what you are doing! ***\n"+
"title: %[1]s Provider\n"+
"meta_desc: Provides an overview on how to configure the Pulumi %[1]s provider.\n"+
"layout: package\n"+
Expand Down
2 changes: 2 additions & 0 deletions pkg/tfgen/installation_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,8 @@ func TestWriteFrontMatter(t *testing.T) {
name: "Generates Front Matter for installation-configuration.md",
providerName: "test",
expected: delimiter +
"# *** WARNING: This file was auto-generated. " +
"Do not edit by hand unless you're certain you know what you are doing! ***\n" +
"title: Test Provider\n" +
"meta_desc: Provides an overview on how to configure the Pulumi Test provider.\n" +
"layout: package\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# *** WARNING: This file was auto-generated. Do not edit by hand unless you're certain you know what you are doing! ***
title: Libvirt Provider
meta_desc: Provides an overview on how to configure the Pulumi Libvirt provider.
layout: package
Expand Down
1 change: 1 addition & 0 deletions pkg/tfgen/test_data/convert-index-file/expected.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
# *** WARNING: This file was auto-generated. Do not edit by hand unless you're certain you know what you are doing! ***
title: Libvirt Provider
meta_desc: Provides an overview on how to configure the Pulumi Libvirt provider.
layout: package
Expand Down

0 comments on commit dda50da

Please sign in to comment.