Skip to content

Commit 23cc0c3

Browse files
committed
tests: increase validation coverage
1 parent cc0d333 commit 23cc0c3

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

cmd/root_test.go

+37
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,43 @@ func Test_validate(t *testing.T) {
8888
}
8989
},
9090
},
91+
{
92+
name: "Successful validation template",
93+
args: args{
94+
config: formatter.Config{
95+
OutputFormat: formatter.MarkdownOutput,
96+
TemplatePath: path.Join(os.TempDir(), "formatter_template_valid"),
97+
InputFileConfig: formatter.InputFileConfig{
98+
Path: path.Join(os.TempDir(), "formatter_cmd_valid_template_3"),
99+
},
100+
},
101+
},
102+
wantErr: false,
103+
before: func(t *testing.T) {
104+
templatePath := path.Join(os.TempDir(), "formatter_template_valid")
105+
filePath := path.Join(os.TempDir(), "formatter_cmd_valid_template_3")
106+
_, err := os.Create(templatePath)
107+
if err != nil {
108+
t.Errorf("could not create temporary file: %s", templatePath)
109+
}
110+
_, err = os.Create(filePath)
111+
if err != nil {
112+
t.Errorf("could not create temporary file: %s", filePath)
113+
}
114+
},
115+
after: func(t *testing.T) {
116+
templatePath := path.Join(os.TempDir(), "formatter_template_valid")
117+
filePath := path.Join(os.TempDir(), "formatter_cmd_valid_template_3")
118+
err := os.Remove(templatePath)
119+
if err != nil {
120+
t.Logf("could not remove temporary file: %s", templatePath)
121+
}
122+
err = os.Remove(filePath)
123+
if err != nil {
124+
t.Logf("could not remove temporary file: %s", filePath)
125+
}
126+
},
127+
},
91128
}
92129
for _, tt := range tests {
93130
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)