mirror of
https://github.com/jech/galene.git
synced 2024-11-22 08:35:57 +01:00
Add test for description marshalling/unmarshalling.
This commit is contained in:
parent
4b420e5bd6
commit
c178c28b60
1 changed files with 36 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
package group
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
@ -20,3 +22,37 @@ func TestJSTime(t *testing.T) {
|
|||
t.Errorf("Delta %v, %v, %v", delta, tm, tm2)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDescriptionJSON(t *testing.T) {
|
||||
d := `
|
||||
{
|
||||
"op":[{"username": "jch","password": "topsecret"}],
|
||||
"max-history-age": 10,
|
||||
"allow-subgroups": true,
|
||||
"presenter":[
|
||||
{"user": "john", "password": "secret"},
|
||||
{}
|
||||
]
|
||||
}`
|
||||
|
||||
var dd description
|
||||
err := json.Unmarshal([]byte(d), &dd)
|
||||
if err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
|
||||
ddd, err := json.Marshal(dd)
|
||||
if err != nil {
|
||||
t.Fatalf("marshal: %v", err)
|
||||
}
|
||||
|
||||
var dddd description
|
||||
err = json.Unmarshal([]byte(ddd), &dddd)
|
||||
if err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(dd, dddd) {
|
||||
t.Errorf("Got %v, expected %v", dddd, dd)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue