1
0
Fork 0
mirror of https://github.com/laravel-ls/protocol.git synced 2026-06-16 03:54:56 +02:00
protocol/client_test.go
2026-03-01 22:57:28 +01:00

26 lines
749 B
Go

package protocol_test
import (
"encoding/json"
"testing"
"github.com/laravel-ls/protocol"
)
func Test_Client_StructsUnmarshalValidJSON(t *testing.T) {
var clientInfo protocol.ClientInfo
if err := json.Unmarshal([]byte(`{"name":"nvim","version":"0.10"}`), &clientInfo); err != nil {
t.Fatalf("unmarshal ClientInfo failed: %v", err)
}
if clientInfo.Name != "nvim" {
t.Fatalf("unexpected ClientInfo: %+v", clientInfo)
}
var command protocol.Command
if err := json.Unmarshal([]byte(`{"title":"Fix","command":"app.fix","arguments":["a",1]}`), &command); err != nil {
t.Fatalf("unmarshal Command failed: %v", err)
}
if command.Command != "app.fix" || len(command.Arguments) != 2 {
t.Fatalf("unexpected Command: %+v", command)
}
}