Modified common/download_test.go to not test the smb:// uri on platforms other than windows. Added an immediate platform error to SMBDownloader.Download as opposed to letting .toPath return it (which would have left the structure partially initialized).

This commit is contained in:
Ali Rizvi-Santiago 2017-03-23 15:29:38 -05:00
parent 4783b6508e
commit 5a4ce2165c
2 changed files with 20 additions and 10 deletions

View File

@ -637,6 +637,12 @@ func (d *SMBDownloader) toPath(base string, uri url.URL) (string, error) {
} }
func (d *SMBDownloader) Download(dst *os.File, src *url.URL) error { func (d *SMBDownloader) Download(dst *os.File, src *url.URL) error {
/* first we warn the world if we're not running windows */
if runtime.GOOS != "windows" {
return fmt.Errorf("Support for SMB based uri's are not supported on %s", runtime.GOOS)
}
d.active = false d.active = false
/* convert the uri using the net/url module to a UNC path */ /* convert the uri using the net/url module to a UNC path */

View File

@ -483,15 +483,19 @@ func TestFileUriTransforms(t *testing.T) {
t.Logf("TestFileUriTransforms : Result Path '%s'", res) t.Logf("TestFileUriTransforms : Result Path '%s'", res)
} }
// ...and finally the oddball windows native path // smb protocol depends on platform support which currently
// smb://host/sharename/file -> \\host\sharename\file // only exists on windows.
testcase := host + "/" + share + "/" + cwd[1:] + "/%s" if runtime.GOOS == "windows" {
uri := "smb://" + fmt.Sprintf(testcase, testpath) // ...and finally the oddball windows native path
t.Logf("TestFileUriTransforms : Trying Uri '%s'", uri) // smb://host/sharename/file -> \\host\sharename\file
res, err := SimulateFileUriDownload(t, uri) testcase := host + "/" + share + "/" + cwd[1:] + "/%s"
if err != nil { uri := "smb://" + fmt.Sprintf(testcase, testpath)
t.Errorf("Unable to transform uri '%s' into a path", uri) t.Logf("TestFileUriTransforms : Trying Uri '%s'", uri)
return res, err := SimulateFileUriDownload(t, uri)
if err != nil {
t.Errorf("Unable to transform uri '%s' into a path", uri)
return
}
t.Logf("TestFileUriTransforms : Result Path '%s'", res)
} }
t.Logf("TestFileUriTransforms : Result Path '%s'", res)
} }