Skip to content

Commit

Permalink
service/dap: fix test failure with 1.24 (#3805)
Browse files Browse the repository at this point in the history
Encoding/json changed some error messages in 1.24, fix the tests.
  • Loading branch information
aarzilli authored Sep 4, 2024
1 parent 7857f23 commit c2dc6ed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions service/dap/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6511,7 +6511,7 @@ func TestBadLaunchRequests(t *testing.T) {
// Bad "backend"
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "backend": 123})
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"})
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
Expand All @@ -6520,7 +6520,7 @@ func TestBadLaunchRequests(t *testing.T) {
// Bad "substitutePath"
client.LaunchRequestWithArgs(map[string]interface{}{"mode": "debug", "program": fixture.Source, "substitutePath": 123})
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}})
checkFailedToLaunchWithMessage(client.ExpectVisibleErrorResponse(t),
Expand Down Expand Up @@ -6714,7 +6714,7 @@ func TestBadAttachRequest(t *testing.T) {
// Bad "backend"
client.AttachRequest(map[string]interface{}{"mode": "local", "processId": 1, "backend": 123})
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"})
checkFailedToAttachWithMessage(client.ExpectVisibleErrorResponse(t),
Expand Down Expand Up @@ -7675,5 +7675,8 @@ func checkErrorMessageId(er *dap.ErrorMessage, id int) 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
}

0 comments on commit c2dc6ed

Please sign in to comment.