@@ -88,6 +88,64 @@ func Test_validate(t *testing.T) {
88
88
}
89
89
},
90
90
},
91
+ {
92
+ name : "Successful validation output file" ,
93
+ args : args {
94
+ config : formatter.Config {
95
+ OutputFormat : formatter .ExcelOutput ,
96
+ InputFileConfig : formatter.InputFileConfig {
97
+ Path : path .Join (os .TempDir (), "formatter_cmd_valid_output" ),
98
+ },
99
+ OutputFile : formatter .OutputFile ("output.xlsx" ),
100
+ },
101
+ },
102
+ wantErr : false ,
103
+ before : func (t * testing.T ) {
104
+ path := path .Join (os .TempDir (), "formatter_cmd_valid_output" )
105
+ _ , err := os .Create (path )
106
+ if err != nil {
107
+ t .Errorf ("could not create input file: %s" , path )
108
+ }
109
+ },
110
+ after : func (t * testing.T ) {},
111
+ },
112
+ {
113
+ name : "Successful validation template" ,
114
+ args : args {
115
+ config : formatter.Config {
116
+ OutputFormat : formatter .MarkdownOutput ,
117
+ TemplatePath : path .Join (os .TempDir (), "formatter_template_valid" ),
118
+ InputFileConfig : formatter.InputFileConfig {
119
+ Path : path .Join (os .TempDir (), "formatter_cmd_valid_template_3" ),
120
+ },
121
+ },
122
+ },
123
+ wantErr : false ,
124
+ before : func (t * testing.T ) {
125
+ templatePath := path .Join (os .TempDir (), "formatter_template_valid" )
126
+ filePath := path .Join (os .TempDir (), "formatter_cmd_valid_template_3" )
127
+ _ , err := os .Create (templatePath )
128
+ if err != nil {
129
+ t .Errorf ("could not create temporary file: %s" , templatePath )
130
+ }
131
+ _ , err = os .Create (filePath )
132
+ if err != nil {
133
+ t .Errorf ("could not create temporary file: %s" , filePath )
134
+ }
135
+ },
136
+ after : func (t * testing.T ) {
137
+ templatePath := path .Join (os .TempDir (), "formatter_template_valid" )
138
+ filePath := path .Join (os .TempDir (), "formatter_cmd_valid_template_3" )
139
+ err := os .Remove (templatePath )
140
+ if err != nil {
141
+ t .Logf ("could not remove temporary file: %s" , templatePath )
142
+ }
143
+ err = os .Remove (filePath )
144
+ if err != nil {
145
+ t .Logf ("could not remove temporary file: %s" , filePath )
146
+ }
147
+ },
148
+ },
91
149
}
92
150
for _ , tt := range tests {
93
151
t .Run (tt .name , func (t * testing.T ) {
0 commit comments