This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
bactdb/api/observations_test.go
2014-11-18 10:41:24 -09:00

40 lines
749 B
Go

package api
import (
"testing"
"github.com/thermokarst/bactdb/models"
)
func newObservation() *models.Observation {
observation := models.NewObservation()
return observation
}
func TestObservation_Get(t *testing.T) {
setup()
want := newObservation()
calledGet := false
store.Observations.(*models.MockObservationsService).Get_ = func(id int64) (*models.Observation, error) {
if id != want.Id {
t.Errorf("wanted request for observation %d but got %d", want.Id, id)
}
calledGet = true
return want, nil
}
got, err := apiClient.Observations.Get(want.Id)
if err != nil {
t.Fatal(err)
}
if !calledGet {
t.Error("!calledGet")
}
if !normalizeDeepEqual(want, got) {
t.Errorf("got %+v but wanted %+v", got, want)
}
}