MCPcopy
hub / github.com/purpleidea/mgmt / TestUserCheckApply_Delete

Function TestUserCheckApply_Delete

engine/resources/user_test.go:375–398  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

373}
374
375func TestUserCheckApply_Delete(t *testing.T) {
376 f := &fakeUserFuncs{}
377 f.addUser(newTestUser("james", 1000, 1000, "/home/james/"), nil, "/bin/bash")
378 f.install(t)
379
380 res := &UserRes{State: "absent"}
381 res.SetName("james")
382 res.SetKind("user")
383 if err := res.Init(fakeUserInit(t)); err != nil {
384 t.Fatal(err)
385 }
386
387 checkOK, err := res.CheckApply(context.Background(), true)
388 if err != nil {
389 t.Fatalf("func CheckApply: %v", err)
390 }
391 if checkOK {
392 t.Errorf("expected checkOK=false on delete")
393 }
394 want := fakeUserCmd{Name: "userdel", Args: []string{"james"}}
395 if len(f.cmds) != 1 || !reflect.DeepEqual(f.cmds[0], want) {
396 t.Errorf("expected userdel james, got %v", f.cmds)
397 }
398}
399
400func TestUserCheckApply_UIDConflict(t *testing.T) {
401 f := &fakeUserFuncs{}

Callers

nothing calls this directly

Calls 9

addUserMethod · 0.95
installMethod · 0.95
InitMethod · 0.95
CheckApplyMethod · 0.95
newTestUserFunction · 0.85
fakeUserInitFunction · 0.85
SetNameMethod · 0.65
SetKindMethod · 0.65
BackgroundMethod · 0.65

Tested by

no test coverage detected