mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #876 from ceh/command-win-tests
command: fix test failures on OpenBSD, Windows
This commit is contained in:
commit
f742ccb606
@ -1124,7 +1124,7 @@ func TestApply_disableBackup(t *testing.T) {
|
||||
}
|
||||
|
||||
func testHttpServer(t *testing.T) net.Listener {
|
||||
ln, err := net.Listen("tcp", ":0")
|
||||
ln, err := net.Listen("tcp", "127.0.0.1:0")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
@ -1142,7 +1142,7 @@ func testHttpServer(t *testing.T) net.Listener {
|
||||
func testHttpHandlerHeader(w http.ResponseWriter, r *http.Request) {
|
||||
var url url.URL
|
||||
url.Scheme = "file"
|
||||
url.Path = testFixturePath("init")
|
||||
url.Path = filepath.ToSlash(testFixturePath("init"))
|
||||
|
||||
w.Header().Add("X-Terraform-Get", url.String())
|
||||
w.WriteHeader(200)
|
||||
|
@ -38,10 +38,10 @@ func Detect(src string, pwd string) (string, error) {
|
||||
// Separate out the subdir if there is one, we don't pass that to detect
|
||||
getSrc, subDir := getDirSubdir(getSrc)
|
||||
|
||||
u, err := url.Parse(getSrc)
|
||||
u, err := urlParse(getSrc)
|
||||
if err == nil && u.Scheme != "" {
|
||||
// Valid URL
|
||||
return src, nil
|
||||
return u.String(), nil
|
||||
}
|
||||
|
||||
for _, d := range Detectors {
|
||||
|
@ -9,8 +9,13 @@ import (
|
||||
|
||||
func urlParse(rawURL string) (*url.URL, error) {
|
||||
if runtime.GOOS == "windows" {
|
||||
// Make sure we're using "/" on Windows. URLs are "/"-based.
|
||||
rawURL = filepath.ToSlash(rawURL)
|
||||
if len(rawURL) > 1 && rawURL[1] == ':' {
|
||||
// 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)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user