@@ -210,6 +210,51 @@ func Test_ConfigDumpCommand(t *testing.T) {
210210 }))
211211}
212212
213+ func Test_ConfigDestroyCommand (t * testing.T ) {
214+ path := "/tmp/test_config_destroy/"
215+
216+ t .Run ("Simple" , core .Test (& core.TestConfig {
217+ Commands : GetCommands (),
218+ BeforeFunc : beforeFuncCreateFullConfig (),
219+ Cmd : "scw config destroy" ,
220+ Check : core .TestCheckCombine (
221+ core .TestCheckExitCode (0 ),
222+ core .TestCheckGolden (),
223+ ),
224+ TmpHomeDir : true ,
225+ }))
226+
227+ t .Run ("Check Config File" , core .Test (& core.TestConfig {
228+ Commands : GetCommands (),
229+ BeforeFunc : core .BeforeFuncCombine (
230+ func (ctx * core.BeforeFuncCtx ) error {
231+ err := os .MkdirAll (path , os .ModePerm )
232+ if err != nil {
233+ t .Fatalf ("MkdirAll %q: %s" , path , err )
234+ }
235+ return nil
236+ },
237+ beforeFuncCreateFullConfig (),
238+ core .ExecStoreBeforeCmd (
239+ "Destroy" ,
240+ "scw config destroy" ,
241+ ),
242+ ),
243+ Cmd : "scw config dump" ,
244+ Check : core .TestCheckCombine (
245+ core .TestCheckExitCode (1 ),
246+ core .TestCheckGolden (),
247+ ),
248+ OverrideEnv : map [string ]string {
249+ "HOME" : path ,
250+ },
251+ AfterFunc : func (ctx * core.AfterFuncCtx ) error {
252+ _ = os .RemoveAll (path )
253+ return nil
254+ },
255+ }))
256+ }
257+
213258func checkConfig (f func (t * testing.T , config * scw.Config )) core.TestCheck {
214259 return func (t * testing.T , ctx * core.CheckFuncCtx ) {
215260 homeDir := ctx .OverrideEnv ["HOME" ]
0 commit comments