service/dap: fix test failure with 1.24 (#3805)
Encoding/json changed some error messages in 1.24, fix the tests.
This commit is contained in:
parent
7857f233ad
commit
c2dc6edcfc
@ -6511,7 +6511,7 @@ func TestBadLaunchRequests(t *testing.T) {
|
|||||||
// Bad "backend"
|
// Bad "backend"
|
||||||
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "backend": 123})
|
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "backend": 123})
|
||||||
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
||||||
"Failed to launch: invalid debug configuration - cannot unmarshal number into \"backend\" of type string")
|
"Failed to launch: invalid debug configuration - cannot unmarshal number …")
|
||||||
|
|
||||||
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "backend": "foo"})
|
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "backend": "foo"})
|
||||||
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
||||||
@ -6520,7 +6520,7 @@ func TestBadLaunchRequests(t *testing.T) {
|
|||||||
// Bad "substitutePath"
|
// Bad "substitutePath"
|
||||||
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "substitutePath": 123})
|
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "substitutePath": 123})
|
||||||
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
||||||
"Failed to launch: invalid debug configuration - cannot unmarshal number into \"substitutePath\" of type {\"from\":string, \"to\":string}")
|
"Failed to launch: invalid debug configuration - cannot unmarshal number into …")
|
||||||
|
|
||||||
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "substitutePath": []interface{}{123}})
|
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "substitutePath": []interface{}{123}})
|
||||||
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
|
||||||
@ -6714,7 +6714,7 @@ func TestBadAttachRequest(t *testing.T) {
|
|||||||
// Bad "backend"
|
// Bad "backend"
|
||||||
client.AttachRequest(map[string]interface{}{"mode": "local", "processId": 1, "backend": 123})
|
client.AttachRequest(map[string]interface{}{"mode": "local", "processId": 1, "backend": 123})
|
||||||
checkFailedToAttachWithMessage(client.ExpectVisibleErrorResponse(t),
|
checkFailedToAttachWithMessage(client.ExpectVisibleErrorResponse(t),
|
||||||
"Failed to attach: invalid debug configuration - cannot unmarshal number into \"backend\" of type string")
|
"Failed to attach: invalid debug configuration - cannot unmarshal number into …")
|
||||||
|
|
||||||
client.AttachRequest(map[string]interface{}{"mode": "local", "processId": 1, "backend": "foo"})
|
client.AttachRequest(map[string]interface{}{"mode": "local", "processId": 1, "backend": "foo"})
|
||||||
checkFailedToAttachWithMessage(client.ExpectVisibleErrorResponse(t),
|
checkFailedToAttachWithMessage(client.ExpectVisibleErrorResponse(t),
|
||||||
@ -7675,5 +7675,8 @@ func checkErrorMessageId(er *dap.ErrorMessage, id int) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func checkErrorMessageFormat(er *dap.ErrorMessage, fmt string) bool {
|
func checkErrorMessageFormat(er *dap.ErrorMessage, fmt string) bool {
|
||||||
|
if dotdotdot := strings.Index(fmt, "…"); dotdotdot > 0 {
|
||||||
|
return er != nil && strings.HasPrefix(er.Format, fmt[:dotdotdot])
|
||||||
|
}
|
||||||
return er != nil && er.Format == fmt
|
return er != nil && er.Format == fmt
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user