Refactor template_test.go to enable an individual run for each test case
@@ -30,13 +30,11 @@ import (
"sigs.k8s.io/yaml"
)
-type testCase struct {
+func Test_RenderCloudformation(t *testing.T) {
+ cases := []struct {
fixture string
template func() Template
-}
-
-func Test_RenderCloudformation(t *testing.T) {
- cases := []testCase{
+ }{
{
fixture: "default",
template: NewTemplate,
@@ -170,6 +168,7 @@ func Test_RenderCloudformation(t *testing.T) {
}
for _, c := range cases {
+ t.Run(c.fixture, func(t *testing.T) {
cfn := cloudformation.Template{}
data, err := os.ReadFile(path.Join("fixtures", c.fixture+".yaml"))
if err != nil {
@@ -192,5 +191,6 @@ func Test_RenderCloudformation(t *testing.T) {
out := dmp.DiffPrettyText(diffs)
t.Fatal(fmt.Sprintf("Differing output (%s):\n%s", c.fixture, out))
}
+ })
}
}
