Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
remove trailing slashes on targets
Browse files Browse the repository at this point in the history
Signed-off-by: Jason McCallister <[email protected]>
  • Loading branch information
jasonmccallister committed Apr 16, 2020
1 parent 3704451 commit 18d028d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions internal/nitro/mount_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func MountDir(name, source, target string) (*Action, error) {
target = "/" + target
}

if strings.HasSuffix(source, "/") {
source = strings.TrimRight(source, "/")
}

return &Action{
Type: "mount",
UseSyscall: false,
Expand Down
18 changes: 16 additions & 2 deletions internal/nitro/mount_dir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ func TestMountDir(t *testing.T) {
},
wantErr: false,
},
{
name: "mounts a directory and removes the trailing slash",
args: args{
name: "somename",
source: "./testdata/source-folder/",
target: "/home/ubuntu/sites",
},
want: &Action{
Type: "mount",
UseSyscall: false,
Args: []string{"mount", "./testdata/source-folder", "somename:/home/ubuntu/sites"},
},
wantErr: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -40,8 +54,8 @@ func TestMountDir(t *testing.T) {
return
}
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("MountDir() got = %v, want %v", got, tt.want)
t.Errorf("MountDir() got = \n%v, \nwant \n%v", got, tt.want)
}
})
}
}
}

0 comments on commit 18d028d

Please sign in to comment.