Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Test fails on Windows in router_test.go #295

Closed
as27 opened this issue Mar 18, 2017 · 0 comments
Closed

Test fails on Windows in router_test.go #295

as27 opened this issue Mar 18, 2017 · 0 comments
Labels
os-specific This issue is OS-specific

Comments

@as27
Copy link
Contributor

as27 commented Mar 18, 2017

When running go test on a windows machine, the test fails in router_test.go

--- FAIL: Test_Resource (0.00s)
Error Trace: router_test.go:198
Error: Received unexpected error "parse http://127.0.0.1:50094\\users: invalid character "\\" in host name"

Looking inside the test shows, that the bug is inside the test. A url is joined using filepath.Join() That may work on linux or mac, but not on windows:

	for _, path := range []string{"/users", "/api/v1/users"} {
		for _, test := range tests {
			u := ts.URL + filepath.Join(path, test.Path)
			req, err := http.NewRequest(test.Method, u, nil)

After correcting the path, there are still bugs inside the test cases. Everywhere "/" is called gives then a 404. That is because the filepath.Join() did not add a backslash in that case.
If the path is "/" like here:

{
	Method: "GET",
	Path:   "/",
	Result: "list",
}

The path needs to be "". So also the testcases are not correct at that part.

@markbates markbates added the os-specific This issue is OS-specific label Mar 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
os-specific This issue is OS-specific
Projects
None yet
Development

No branches or pull requests

2 participants