Skip to content

Commit

Permalink
sftpd_test: use path.Join for SFTP/SCP path
Browse files Browse the repository at this point in the history
filepath.Join could use an OS dependent separator
  • Loading branch information
drakkan committed Oct 16, 2019
1 parent 8682ae4 commit 44d403c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sftpd/sftpd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,23 +399,23 @@ func TestRemove(t *testing.T) {
if err != nil {
t.Errorf("unable to create test file: %v", err)
}
err = sftpUploadFile(testFilePath, filepath.Join("/test", testFileName), testFileSize, client)
err = sftpUploadFile(testFilePath, path.Join("/test", testFileName), testFileSize, client)
if err != nil {
t.Errorf("file upload error: %v", err)
}
err = client.Remove("/test")
if err == nil {
t.Errorf("remove non empty dir must fail")
}
err = client.RemoveDirectory(filepath.Join("/test", testFileName))
err = client.RemoveDirectory(path.Join("/test", testFileName))
if err == nil {
t.Errorf("remove directory as file must fail")
}
err = client.Remove(filepath.Join("/test", testFileName))
err = client.Remove(path.Join("/test", testFileName))
if err != nil {
t.Errorf("remove file error: %v", err)
}
err = client.Remove(filepath.Join("/test", testFileName))
err = client.Remove(path.Join("/test", testFileName))
if err == nil {
t.Errorf("remove missing file must fail")
}
Expand Down Expand Up @@ -580,7 +580,7 @@ func TestEscapeHomeDir(t *testing.T) {
if err != nil {
t.Errorf("unable to create test file: %v", err)
}
remoteDestPath := filepath.Join("..", "..", testFileName)
remoteDestPath := path.Join("..", "..", testFileName)
err = sftpUploadFile(testFilePath, remoteDestPath, testFileSize, client)
if err != nil {
t.Errorf("file upload error: %v", err)
Expand Down Expand Up @@ -1728,7 +1728,7 @@ func TestSCPUploadFileOverwrite(t *testing.T) {
if err != nil {
t.Errorf("unable to create test file: %v", err)
}
remoteUpPath := fmt.Sprintf("%[email protected]:%v", user.Username, filepath.Join("/", testFileName))
remoteUpPath := fmt.Sprintf("%[email protected]:%v", user.Username, path.Join("/", testFileName))
err = scpUpload(testFilePath, remoteUpPath, true, false)
if err != nil {
t.Errorf("error uploading file via scp: %v", err)
Expand Down

0 comments on commit 44d403c

Please sign in to comment.