Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions samples/go/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ func (c *Client) doRequest(req interface{}, resp *models.JSONRPCResponse) error
}

// Copy the basic fields
resp.JSONRPCMessage.JSONRPC = rawResp.JSONRPC
resp.JSONRPCMessage.JSONRPCMessageIdentifier.ID = rawResp.ID
resp.JSONRPC = rawResp.JSONRPC
resp.ID = rawResp.ID
resp.Error = rawResp.Error

// If there's a result, try to decode it as a Task
Expand Down
22 changes: 15 additions & 7 deletions samples/go/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func TestSendTask(t *testing.T) {
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
if err := json.NewEncoder(w).Encode(resp); err != nil {
t.Fatal(err)
}
}))
defer server.Close()

Expand Down Expand Up @@ -97,7 +99,9 @@ func TestGetTask(t *testing.T) {
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
if err := json.NewEncoder(w).Encode(resp); err != nil {
t.Fatal(err)
}
}))
defer server.Close()

Expand Down Expand Up @@ -153,7 +157,9 @@ func TestCancelTask(t *testing.T) {
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
if err := json.NewEncoder(w).Encode(resp); err != nil {
t.Fatal(err)
}
}))
defer server.Close()

Expand Down Expand Up @@ -182,7 +188,7 @@ func TestCancelTask(t *testing.T) {
}

func TestErrorResponse(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
resp := models.JSONRPCResponse{
JSONRPCMessage: models.JSONRPCMessage{
JSONRPC: "2.0",
Expand All @@ -194,7 +200,9 @@ func TestErrorResponse(t *testing.T) {
}

w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(resp)
if err := json.NewEncoder(w).Encode(resp); err != nil {
t.Fatal(err)
}
}))
defer server.Close()

Expand Down Expand Up @@ -231,8 +239,8 @@ func TestSendTaskStreaming(t *testing.T) {
t.Fatal(err)
}

if req.Method != "message/send" {
t.Errorf("expected method message/send, got %s", req.Method)
if expectedMethod := "message/stream"; req.Method != expectedMethod {
t.Errorf("expected method %s, got %s", expectedMethod, req.Method)
}

// Set response headers for streaming
Expand Down