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
client_test.go
Normal file
26
client_test.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue