Commit 2806fe81 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Use separate test file

parent 08ec1011
package main
import (
"testing"
)
func TestParseAuthBackend(t *testing.T) {
failures := []string{
"",
"ftp://localhost",
"https://example.com",
}
for _, example := range failures {
if _, err := parseAuthBackend(example); err == nil {
t.Errorf("error expected for %q", example)
}
}
successes := []struct{ input, host, scheme string }{
{"http://localhost:8080", "localhost:8080", "http"},
{"localhost:3000", "localhost:3000", "http"},
{"http://localhost", "localhost", "http"},
{"localhost", "localhost", "http"},
}
for _, example := range successes {
result, err := parseAuthBackend(example.input)
if err != nil {
t.Errorf("parse %q: %v", example.input, err)
break
}
if result.Host != example.host {
t.Errorf("expected %q, got %q", example.host, result.Host)
}
if result.Scheme != example.scheme {
t.Errorf("expected %q, got %q", example.scheme, result.Scheme)
}
}
}
......@@ -736,43 +736,6 @@ func TestGetGitPatch(t *testing.T) {
}
}
func TestParseAuthBackend(t *testing.T) {
failures := []string{
"",
"ftp://localhost",
"https://example.com",
}
for _, example := range failures {
if _, err := parseAuthBackend(example); err == nil {
t.Errorf("error expected for %q", example)
}
}
successes := []struct{ input, host, scheme string }{
{"http://localhost:8080", "localhost:8080", "http"},
{"localhost:3000", "localhost:3000", "http"},
{"http://localhost", "localhost", "http"},
{"localhost", "localhost", "http"},
}
for _, example := range successes {
result, err := parseAuthBackend(example.input)
if err != nil {
t.Errorf("parse %q: %v", example.input, err)
break
}
if result.Host != example.host {
t.Errorf("expected %q, got %q", example.host, result.Host)
}
if result.Scheme != example.scheme {
t.Errorf("expected %q, got %q", example.scheme, result.Scheme)
}
}
}
func setupStaticFile(fpath, content string) error {
cwd, err := os.Getwd()
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment