Blob
- Date:
- Message:
- Use default MarshalJSON method There's no point doing so much manual work and testing just to keep fields under a "attrs" key when marshalling to JSON. When creating the object we can just: 1. Marshal the object to JSON 2. Put it all under a "attrs" key. Now it's easier to imagine the mapping of the structs to JSON, since they follow the same rules as everything else in Go.
- Actions:
- History | Blame | Raw File
1 package icinga3 import (4 "os"5 "reflect"6 "testing"7 )9 func TestUser(t *testing.T) {10 want := User{Name: "test", Email: "test@example.com", Groups: []string{}}11 f, err := os.Open("testdata/objects/users/test")12 if err != nil {13 t.Fatal(err)14 }15 defer f.Close()16 resp, err := parseResponse(f)17 if err != nil {18 t.Fatal(err)19 }20 got := resp.Results[0].(User)21 if !reflect.DeepEqual(want, got) {22 t.Errorf("want: %+v, got %+v", want, got)23 }24 }