go-http-tunnel/auth_test.go
2017-02-08 14:26:32 +01:00

24 lines
465 B
Go

package tunnel
import (
"reflect"
"testing"
)
func TestNewAuth(t *testing.T) {
tests := []struct {
actual string
expected *Auth
}{
{"", nil},
{"user", &Auth{User: "user"}},
{"user:password", &Auth{User: "user", Password: "password"}},
{"user:pass:word", &Auth{User: "user", Password: "pass:word"}},
}
for _, tt := range tests {
if !reflect.DeepEqual(NewAuth(tt.actual), tt.expected) {
t.Errorf("Invalid auth for %s", tt.actual)
}
}
}