Skip to content

Commit

Permalink
only add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tejal29 committed Nov 7, 2019
1 parent 334f0c7 commit f36dd40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions pkg/commands/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ func addDefaultHOME(u string, envs []string) []string {
home := fmt.Sprintf("%s=/", constants.HOME)
userObj, err := userLookup(u)
if err == nil {
u = userObj.HomeDir
if u == "" {
u = userObj.Username
}
u = userObj.Username
home = fmt.Sprintf("%s=/home/%s", constants.HOME, u)
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/commands/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func Test_addDefaultHOME(t *testing.T) {
},
},
{
name: "HOME isn't set, user isn't set",
name: "HOME not set, user not set",
user: "",
initial: []string{
"PATH=/something/else",
Expand All @@ -54,7 +54,7 @@ func Test_addDefaultHOME(t *testing.T) {
},
},
{
name: "HOME isn't set, user and homedir for the user set",
name: "HOME not set, user and homedir for the user set",
user: "www-add",
mockUser: &user.User{
Username: "www-add",
Expand All @@ -65,11 +65,11 @@ func Test_addDefaultHOME(t *testing.T) {
},
expected: []string{
"PATH=/something/else",
"HOME=/home/some-other",
"HOME=/home/www-add",
},
},
{
name: "HOME isn't set, user set",
name: "HOME not set, user set",
user: "www-add",
mockUser: &user.User{
Username: "www-add",
Expand All @@ -83,7 +83,7 @@ func Test_addDefaultHOME(t *testing.T) {
},
},
{
name: "HOME isn't set, user is set",
name: "HOME not set, user is set",
user: "newuser",
mockUser: &user.User{
Username: "newuser",
Expand All @@ -97,7 +97,7 @@ func Test_addDefaultHOME(t *testing.T) {
},
},
{
name: "HOME isn't set, user is set to root",
name: "HOME not set, user is set to root",
user: "root",
mockUser: &user.User{
Username: "root",
Expand Down

0 comments on commit f36dd40

Please sign in to comment.