Create a new observation
This commit is contained in:
parent
a018d2bd7a
commit
f867e5c424
9 changed files with 154 additions and 3 deletions
|
@ -38,3 +38,30 @@ func TestObservation_Get(t *testing.T) {
|
|||
t.Errorf("got %+v but wanted %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestObservation_Create(t *testing.T) {
|
||||
setup()
|
||||
|
||||
want := newObservation()
|
||||
|
||||
calledPost := false
|
||||
store.Observations.(*models.MockObservationsService).Create_ = func(observation *models.Observation) (bool, error) {
|
||||
if !normalizeDeepEqual(want, observation) {
|
||||
t.Errorf("wanted request for observation %d but got %d", want, observation)
|
||||
}
|
||||
calledPost = true
|
||||
return true, nil
|
||||
}
|
||||
|
||||
success, err := apiClient.Observations.Create(want)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if !calledPost {
|
||||
t.Error("!calledPost")
|
||||
}
|
||||
if !success {
|
||||
t.Error("!success")
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue