Gitea host renamed (infra ADR-0004); the mcp-chassis dep already migrated
(3329ff3), so the sequencing gate is clear. `go mod edit -module` + bulk import
rewrite across all .go files. gitea-mcp is a server binary (not an imported
library), so no downstream consumers break. build + task check green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
30 lines
881 B
Go
30 lines
881 B
Go
package mcp_test
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"git.d-ma.be/mathias/gitea-mcp/internal/mcp"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestRequestUnmarshal(t *testing.T) {
|
|
raw := []byte(`{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}`)
|
|
var req mcp.Request
|
|
require.NoError(t, json.Unmarshal(raw, &req))
|
|
assert.Equal(t, "2.0", req.JSONRPC)
|
|
assert.Equal(t, "initialize", req.Method)
|
|
// ID is opaque; encoding/json decodes JSON numbers into float64 by default.
|
|
// We don't type-assert in the server — we echo it back unchanged.
|
|
assert.Equal(t, float64(1), req.ID)
|
|
}
|
|
|
|
func TestErrorResponseShape(t *testing.T) {
|
|
resp := mcp.NewErrorResponse(1, mcp.CodePermissionDenied, "no", nil)
|
|
b, _ := json.Marshal(resp)
|
|
assert.JSONEq(t,
|
|
`{"jsonrpc":"2.0","id":1,"error":{"code":-32001,"message":"no"}}`,
|
|
string(b))
|
|
}
|