Test cleanup

This commit is contained in:
Andrew Block 2019-12-22 00:02:08 -05:00
parent 48954ca716
commit 5881a2cfca
No known key found for this signature in database
GPG key ID: 02DFE631AEF35EBC

View file

@ -2,7 +2,6 @@ package openshift
import ( import (
"context" "context"
"crypto/tls"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/http" "net/http"
@ -19,7 +18,6 @@ import (
) )
func TestOpen(t *testing.T) { func TestOpen(t *testing.T) {
s := newTestServer(map[string]interface{}{}) s := newTestServer(map[string]interface{}{})
defer s.Close() defer s.Close()
@ -180,7 +178,7 @@ func newTestServer(responses map[string]interface{}) *httptest.Server {
s = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { s = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
responses["/.well-known/oauth-authorization-server"] = map[string]interface{}{ responses["/.well-known/oauth-authorization-server"] = map[string]interface{}{
"issuer": fmt.Sprintf("%s", s.URL), "issuer": s.URL,
"authorization_endpoint": fmt.Sprintf("%s/oauth/authorize", s.URL), "authorization_endpoint": fmt.Sprintf("%s/oauth/authorize", s.URL),
"token_endpoint": fmt.Sprintf("%s/oauth/token", s.URL), "token_endpoint": fmt.Sprintf("%s/oauth/token", s.URL),
"scopes_supported": []string{"user:full", "user:info", "user:check-access", "user:list-scoped-projects", "user:list-projects"}, "scopes_supported": []string{"user:full", "user:info", "user:check-access", "user:list-scoped-projects", "user:list-projects"},
@ -197,25 +195,12 @@ func newTestServer(responses map[string]interface{}) *httptest.Server {
return s return s
} }
func newClient() *http.Client {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
return &http.Client{Transport: tr}
}
func expectNil(t *testing.T, a interface{}) { func expectNil(t *testing.T, a interface{}) {
if a != nil { if a != nil {
t.Errorf("Expected %+v to equal nil", a) t.Errorf("Expected %+v to equal nil", a)
} }
} }
func expectNotNil(t *testing.T, a interface{}, msg string) {
if a == nil {
t.Errorf("Expected %+v to not to be nil", msg)
}
}
func expectEquals(t *testing.T, a interface{}, b interface{}) { func expectEquals(t *testing.T, a interface{}, b interface{}) {
if !reflect.DeepEqual(a, b) { if !reflect.DeepEqual(a, b) {
t.Errorf("Expected %+v to equal %+v", a, b) t.Errorf("Expected %+v to equal %+v", a, b)