Improve qsdiff error reporting
This commit is contained in:
parent
091590d391
commit
daec9f591a
@ -157,8 +157,9 @@ func TestGetLoginURL(t *testing.T) {
|
|||||||
"state": []string{"nonce:http://example.com/hello"},
|
"state": []string{"nonce:http://example.com/hello"},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(qs, expectedQs) {
|
if !reflect.DeepEqual(qs, expectedQs) {
|
||||||
t.Error("Incorrect login query string:")
|
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||||
qsDiff(expectedQs, qs)
|
t.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -209,8 +210,9 @@ func TestGetLoginURL(t *testing.T) {
|
|||||||
"state": []string{"nonce:http://example.com/hello"},
|
"state": []string{"nonce:http://example.com/hello"},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(qs, expectedQs) {
|
if !reflect.DeepEqual(qs, expectedQs) {
|
||||||
t.Error("Incorrect login query string:")
|
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||||
qsDiff(expectedQs, qs)
|
t.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -261,10 +263,13 @@ func TestGetLoginURL(t *testing.T) {
|
|||||||
"state": []string{"nonce:http://example.com/hello"},
|
"state": []string{"nonce:http://example.com/hello"},
|
||||||
"prompt": []string{"consent select_account"},
|
"prompt": []string{"consent select_account"},
|
||||||
}
|
}
|
||||||
qsDiff(expectedQs, qs)
|
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(qs, expectedQs) {
|
if !reflect.DeepEqual(qs, expectedQs) {
|
||||||
t.Error("Incorrect login query string:")
|
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||||
qsDiff(expectedQs, qs)
|
t.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -301,10 +306,13 @@ func TestGetLoginURL(t *testing.T) {
|
|||||||
"state": []string{"nonce:http://another.com/hello"},
|
"state": []string{"nonce:http://another.com/hello"},
|
||||||
"prompt": []string{"consent select_account"},
|
"prompt": []string{"consent select_account"},
|
||||||
}
|
}
|
||||||
qsDiff(expectedQs, qs)
|
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
if !reflect.DeepEqual(qs, expectedQs) {
|
if !reflect.DeepEqual(qs, expectedQs) {
|
||||||
t.Error("Incorrect login query string:")
|
for _, err := range qsDiff(t, expectedQs, qs) {
|
||||||
qsDiff(expectedQs, qs)
|
t.Error(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,20 +75,22 @@ func newHttpRequest(uri string) *http.Request {
|
|||||||
return r
|
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 {
|
for k := range one {
|
||||||
if two.Get(k) == "" {
|
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) {
|
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 {
|
for k := range two {
|
||||||
if one.Get(k) == "" {
|
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