Guest User

Untitled

a guest
Nov 24th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. func TestCurrentUserGroupById(t *testing.T) {
  2. // get current user
  3. userObj, err := user.Current()
  4. if err != nil {
  5. t.Errorf("error trying to lookup current user: %s", err.Error())
  6. }
  7.  
  8. // now try to get the uid/gid via our API (via uid and gid)
  9. var uid, gid int
  10. if uid, err = GetUID(userObj.Uid); err != nil {
  11. t.Errorf("error trying to lookup current user UID: %s", err.Error())
  12. }
  13. if strconv.Itoa(uid) != userObj.Uid {
  14. t.Errorf("uid didn't match current user's: %s vs %s", strconv.Itoa(uid), userObj.Uid)
  15. }
  16.  
  17. if gid, err = GetGID(userObj.Gid); err != nil {
  18. t.Errorf("error trying to lookup current user UID: %s", err.Error())
  19. }
  20. if strconv.Itoa(gid) != userObj.Gid {
  21. t.Errorf("gid didn't match current user's: %s vs %s", strconv.Itoa(gid), useObj.Gid)
  22. }
  23. }
Add Comment
Please, Sign In to add comment