Improve qsdiff error reporting
This commit is contained in:
parent
9abe509f66
commit
e057f2d63a
@ -157,8 +157,9 @@ func TestGetLoginURL(t *testing.T) {
|
||||
"state": []string{"nonce:http://example.com/hello"},
|
||||
}
|
||||
if !reflect.DeepEqual(qs, expectedQs) {
|
||||
t.Error("Incorrect login query string:")
|
||||
qsDiff(expectedQs, qs)
|
||||
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -209,8 +210,9 @@ func TestGetLoginURL(t *testing.T) {
|
||||
"state": []string{"nonce:http://example.com/hello"},
|
||||
}
|
||||
if !reflect.DeepEqual(qs, expectedQs) {
|
||||
t.Error("Incorrect login query string:")
|
||||
qsDiff(expectedQs, qs)
|
||||
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -261,10 +263,13 @@ func TestGetLoginURL(t *testing.T) {
|
||||
"state": []string{"nonce:http://example.com/hello"},
|
||||
"prompt": []string{"consent select_account"},
|
||||
}
|
||||
qsDiff(expectedQs, qs)
|
||||
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(qs, expectedQs) {
|
||||
t.Error("Incorrect login query string:")
|
||||
qsDiff(expectedQs, qs)
|
||||
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@ -301,10 +306,13 @@ func TestGetLoginURL(t *testing.T) {
|
||||
"state": []string{"nonce:http://another.com/hello"},
|
||||
"prompt": []string{"consent select_account"},
|
||||
}
|
||||
qsDiff(expectedQs, qs)
|
||||
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||
t.Error(err)
|
||||
}
|
||||
if !reflect.DeepEqual(qs, expectedQs) {
|
||||
t.Error("Incorrect login query string:")
|
||||
qsDiff(expectedQs, qs)
|
||||
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -75,20 +75,22 @@ func newHttpRequest(uri string) *http.Request {
|
||||
return r
|
||||
}
|
||||
|
||||
func qsDiff(one, two url.Values) {
|
||||
func qsDiff(t *testing.T, one, two url.Values) []string {
|
||||
errs := make([]string, 0)
|
||||
for k := range one {
|
||||
if two.Get(k) == "" {
|
||||
fmt.Printf("Key missing: %s\n", k)
|
||||
errs = append(errs, fmt.Sprintf("Key missing: %s", k))
|
||||
}
|
||||
if one.Get(k) != two.Get(k) {
|
||||
fmt.Printf("Value different for %s: expected: '%s' got: '%s'\n", k, one.Get(k), two.Get(k))
|
||||
errs = append(errs, fmt.Sprintf("Value different for %s: expected: '%s' got: '%s'", k, one.Get(k), two.Get(k)))
|
||||
}
|
||||
}
|
||||
for k := range two {
|
||||
if one.Get(k) == "" {
|
||||
fmt.Printf("Extra key: %s\n", k)
|
||||
errs = append(errs, fmt.Sprintf("Extra key: %s", k))
|
||||
}
|
||||
}
|
||||
return errs
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user