1
0
Fork 0
mirror of https://github.com/laravel-ls/protocol.git synced 2026-06-18 04:50:05 +02:00

add tests

This commit is contained in:
Henrik Hautakoski 2026-03-01 22:57:28 +01:00
parent 5049160990
commit be37cd5a53
20 changed files with 755 additions and 1 deletions

View file

@ -0,0 +1,26 @@
package protocol_test
import (
"encoding/json"
"testing"
"github.com/laravel-ls/protocol"
)
func Test_DocumentDiagnostic_StructsUnmarshalValidJSON(t *testing.T) {
var params protocol.DocumentDiagnosticParams
if err := json.Unmarshal([]byte(`{"textDocument":{"uri":"file:///tmp/main.go"},"identifier":"go","previousResultId":"r1"}`), &params); err != nil {
t.Fatalf("unmarshal DocumentDiagnosticParams failed: %v", err)
}
if params.Identifier != "go" {
t.Fatalf("unexpected DocumentDiagnosticParams: %+v", params)
}
var report protocol.DocumentDiagnosticReport
if err := json.Unmarshal([]byte(`{"kind":"full","resultId":"r2","items":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":1}},"message":"m"}]}`), &report); err != nil {
t.Fatalf("unmarshal DocumentDiagnosticReport failed: %v", err)
}
if report.Full == nil || report.Full.Kind != "full" {
t.Fatalf("unexpected DocumentDiagnosticReport: %+v", report)
}
}