Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func TestCurrentUserGroupById(t *testing.T) {
- // get current user
- userObj, err := user.Current()
- if err != nil {
- t.Errorf("error trying to lookup current user: %s", err.Error())
- }
- // now try to get the uid/gid via our API (via uid and gid)
- var uid, gid int
- if uid, err = GetUID(userObj.Uid); err != nil {
- t.Errorf("error trying to lookup current user UID: %s", err.Error())
- }
- if strconv.Itoa(uid) != userObj.Uid {
- t.Errorf("uid didn't match current user's: %s vs %s", strconv.Itoa(uid), userObj.Uid)
- }
- if gid, err = GetGID(userObj.Gid); err != nil {
- t.Errorf("error trying to lookup current user UID: %s", err.Error())
- }
- if strconv.Itoa(gid) != userObj.Gid {
- t.Errorf("gid didn't match current user's: %s vs %s", strconv.Itoa(gid), useObj.Gid)
- }
- }
Add Comment
Please, Sign In to add comment