config/module: fix test failures on Windows

When parsing URLs on Windows, assume it is a drive letter path
if the second element is a ':' character. Format the drive letter
path as a "file:///"-path prior to parsing the URL.

Fixes test failures of the following form in command on Windows:

=== RUN TestApply_plan
--- FAIL: TestApply_plan (0.00s)
        apply_test.go:379: bad: 1

		module download not supported for scheme 'c'
This commit is contained in:
Emil Hessman 2015-01-28 07:21:05 +01:00
parent b40c2fe997
commit 65177edd1e
1 changed files with 7 additions and 2 deletions

View File

@ -9,8 +9,13 @@ import (
func urlParse(rawURL string) (*url.URL, error) { func urlParse(rawURL string) (*url.URL, error) {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
// Make sure we're using "/" on Windows. URLs are "/"-based. if len(rawURL) > 1 && rawURL[1] == ':' {
rawURL = filepath.ToSlash(rawURL) // Assume we're dealing with a file path.
rawURL = fmtFileURL(rawURL)
} else {
// Make sure we're using "/" on Windows. URLs are "/"-based.
rawURL = filepath.ToSlash(rawURL)
}
} }
u, err := url.Parse(rawURL) u, err := url.Parse(rawURL)
if err != nil { if err != nil {