-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9377652
commit 27bf553
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}) | ||
} | ||
} |