(t *testing.T)
| 344 | } |
| 345 | |
| 346 | func TestUserCheckApply_ModifyShell(t *testing.T) { |
| 347 | f := &fakeUserFuncs{} |
| 348 | f.addUser(newTestUser("james", 1000, 1000, "/home/james/"), nil, "/bin/bash") |
| 349 | f.addGroup(&user.Group{Gid: "1000", Name: "james"}) |
| 350 | f.install(t) |
| 351 | |
| 352 | res := &UserRes{State: "exists", Shell: strPtr("/bin/msh")} |
| 353 | res.SetName("james") |
| 354 | res.SetKind("user") |
| 355 | if err := res.Init(fakeUserInit(t)); err != nil { |
| 356 | t.Fatal(err) |
| 357 | } |
| 358 | |
| 359 | checkOK, err := res.CheckApply(context.Background(), true) |
| 360 | if err != nil { |
| 361 | t.Fatalf("func CheckApply: %v", err) |
| 362 | } |
| 363 | if checkOK { |
| 364 | t.Errorf("expected checkOK=false (shell differs)") |
| 365 | } |
| 366 | if len(f.cmds) != 1 || f.cmds[0].Name != "usermod" { |
| 367 | t.Fatalf("expected one usermod, got %v", f.cmds) |
| 368 | } |
| 369 | want := []string{"--shell", "/bin/msh", "james"} |
| 370 | if !reflect.DeepEqual(f.cmds[0].Args, want) { |
| 371 | t.Errorf("args mismatch:\n got: %v\nwant: %v", f.cmds[0].Args, want) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | func TestUserCheckApply_Delete(t *testing.T) { |
| 376 | f := &fakeUserFuncs{} |
nothing calls this directly
no test coverage detected