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/models/species_test.go
Matthew Dillon 830a8805c9 Species Read - Order of ops:
router/routes.go
router/api.go
models/species_test.go
models/species.go
models/client.go
datastore/migrations/addspecies.sql
datastore/migrations/dropspecies.sql
datastore/species_test.go
datastore/species.go
datastore/datastore.go
api/species_test.go
api/species.go
api/handler.go
2014-10-15 13:01:11 -08:00

39 lines
774 B
Go

package models
import (
"net/http"
"reflect"
"testing"
"github.com/thermokarst/bactdb/router"
)
func TestSpeciesService_Get(t *testing.T) {
setup()
defer teardown()
want := &Species{Id: 1, GenusId: 1, SpeciesName: "Test Species"}
var called bool
mux.HandleFunc(urlPath(t, router.Species, map[string]string{"Id": "1"}), func(w http.ResponseWriter, r *http.Request) {
called = true
testMethod(t, r, "GET")
writeJSON(w, want)
})
species, err := client.Species.Get(1)
if err != nil {
t.Errorf("Species.Get returned error: %v", err)
}
if !called {
t.Fatal("!called")
}
normalizeTime(&want.CreatedAt, &want.UpdatedAt, &want.DeletedAt)
if !reflect.DeepEqual(species, want) {
t.Errorf("Species.Get returned %+v, want %+v", species, want)
}
}