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:
parent
5049160990
commit
be37cd5a53
20 changed files with 755 additions and 1 deletions
26
document_diagnostic_test.go
Normal file
26
document_diagnostic_test.go
Normal 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"}`), ¶ms); 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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue