mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-02-25 05:53:09 -06:00
insert all the logic into a type switch
This commit is contained in:
parent
2b5fbea6db
commit
00e43c60e5
|
|
@ -540,19 +540,13 @@ func Test_register(t *testing.T) {
|
||||||
|
|
||||||
resp = Register(req, userAPI, &cfg.ClientAPI)
|
resp = Register(req, userAPI, &cfg.ClientAPI)
|
||||||
|
|
||||||
switch resp.JSON.(type) {
|
switch rr := resp.JSON.(type) {
|
||||||
case spec.InternalServerError, spec.MatrixError, util.JSONResponse:
|
case spec.InternalServerError, spec.MatrixError, util.JSONResponse:
|
||||||
if !reflect.DeepEqual(tc.wantResponse, resp) {
|
if !reflect.DeepEqual(tc.wantResponse, resp) {
|
||||||
t.Fatalf("unexpected response: %+v, want: %+v", resp, tc.wantResponse)
|
t.Fatalf("unexpected response: %+v, want: %+v", resp, tc.wantResponse)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
case registerResponse:
|
||||||
|
|
||||||
rr, ok := resp.JSON.(registerResponse)
|
|
||||||
if !ok {
|
|
||||||
t.Fatalf("expected a registerresponse, got %T", resp.JSON)
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate the response
|
// validate the response
|
||||||
if tc.forceEmpty {
|
if tc.forceEmpty {
|
||||||
// when not supplying a username, one will be generated. Given this _SHOULD_ be
|
// when not supplying a username, one will be generated. Given this _SHOULD_ be
|
||||||
|
|
@ -569,6 +563,9 @@ func Test_register(t *testing.T) {
|
||||||
if rr.AccessToken == "" {
|
if rr.AccessToken == "" {
|
||||||
t.Fatalf("missing accessToken in response")
|
t.Fatalf("missing accessToken in response")
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
t.Fatalf("expected one of internalservererror, matrixerror, jsonresponse, registerresponse, got %T", resp.JSON)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue