MCPcopy
hub / github.com/kubeedge/kubeedge / TestRunE_TearDownError

Function TestRunE_TearDownError

keadm/cmd/keadm/app/cmd/cloud/reset_test.go:333–360  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

331}
332
333func TestRunE_TearDownError(t *testing.T) {
334 assert := assert.New(t)
335
336 patches := gomonkey.NewPatches()
337 defer patches.Reset()
338
339 patches.ApplyFunc(TearDownCloudCore,
340 func(_ string) error {
341 return errors.New("teardown failed")
342 })
343
344 cleanDirCalled := false
345 patches.ApplyFunc(util.CleanDirectories,
346 func(_ bool) error {
347 cleanDirCalled = true
348 return nil
349 })
350
351 cmd := NewCloudReset()
352 err := cmd.Flags().Set("force", "true")
353 assert.NoError(err)
354
355 err = cmd.RunE(cmd, []string{})
356
357 assert.Error(err)
358 assert.Contains(err.Error(), "teardown failed")
359 assert.False(cleanDirCalled)
360}
361
362func TestRunE_CleanDirectoriesError(t *testing.T) {
363 assert := assert.New(t)

Callers

nothing calls this directly

Calls 6

NewCloudResetFunction · 0.85
ErrorMethod · 0.65
NewMethod · 0.45
ResetMethod · 0.45
SetMethod · 0.45
FlagsMethod · 0.45

Tested by

no test coverage detected