Skip to content

Commit

Permalink
Add unit test for resourceName
Browse files Browse the repository at this point in the history
  • Loading branch information
bendbennett committed Jun 6, 2022
1 parent 9377652 commit 27bf553
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions internal/provider/util_test.go
@@ -0,0 +1,38 @@
package provider

import (
"testing"

"github.com/google/go-cmp/cmp"
)

func Test_resourceName(t *testing.T) {
cases := []struct {
name string
providerShortName string
templateFileName string
expectedResourceName string
}{
{
"provider short name same as template file name",
"http",
"http.md.tmpl",
"http",
},
{
"provider short name different to template file name",
"tls",
"cert_request.md.tmpl",
"tls_cert_request",
},
}

for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
actualResourceName := resourceName(c.providerShortName, c.templateFileName)
if !cmp.Equal(c.expectedResourceName, actualResourceName) {
t.Errorf("expected: %s, got: %s", c.expectedResourceName, actualResourceName)
}
})
}
}

0 comments on commit 27bf553

Please sign in to comment.