This commit is contained in:
parent
34a94fa269
commit
c6d8fee715
46
mite/mite_test.go
Normal file
46
mite/mite_test.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package mite
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestUnmarshalTimeTracking(t *testing.T) {
|
||||||
|
trackerOn := []byte(`
|
||||||
|
{
|
||||||
|
"tracker": {
|
||||||
|
"tracking_time_entry": {
|
||||||
|
"id": 36135321,
|
||||||
|
"minutes": 247,
|
||||||
|
"since": "2015-10-15T17:05:04+02:00"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`)
|
||||||
|
trackerOff := []byte(`{
|
||||||
|
"tracker": {}
|
||||||
|
}`)
|
||||||
|
off := apiTimeTrackerEntry{}
|
||||||
|
err := json.Unmarshal(trackerOff, &off)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else {
|
||||||
|
if off.TimeTrackerHolder.TrackingTimeEntry != nil {
|
||||||
|
t.Error("expected nil, but is not")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
on := apiTimeTrackerEntry{}
|
||||||
|
err = json.Unmarshal(trackerOn, &on)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
} else {
|
||||||
|
if on.TimeTrackerHolder.TrackingTimeEntry == nil {
|
||||||
|
t.Error("expected note nil, but is not")
|
||||||
|
} else {
|
||||||
|
if on.TimeTrackerHolder.TrackingTimeEntry.ID != 36135321 {
|
||||||
|
t.Error("bad unmarshal?")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user