Adding ‘isolated from’ to strains.

This commit is contained in:
Matthew Dillon 2014-12-03 13:14:58 -09:00
parent f33205e721
commit 641203ceb9
3 changed files with 15 additions and 12 deletions

View file

@ -9,6 +9,7 @@ CREATE TABLE strains (
etymology CHARACTER VARYING(500), etymology CHARACTER VARYING(500),
accession_banks CHARACTER VARYING(100), accession_banks CHARACTER VARYING(100),
genbank_embl_ddb CHARACTER VARYING(100), genbank_embl_ddb CHARACTER VARYING(100),
isolated_from CHARACTER VARYING(100),
created_at TIMESTAMP WITH TIME ZONE, created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE, updated_at TIMESTAMP WITH TIME ZONE,

View file

@ -1,6 +1,7 @@
package models package models
import ( import (
"database/sql"
"errors" "errors"
"net/http" "net/http"
"strconv" "strconv"
@ -19,6 +20,7 @@ type Strain struct {
Etymology string `db:"etymology" json:"etymology"` Etymology string `db:"etymology" json:"etymology"`
AccessionBanks string `db:"accession_banks" json:"accessionBanks"` AccessionBanks string `db:"accession_banks" json:"accessionBanks"`
GenbankEmblDdb string `db:"genbank_embl_ddb" json:"genbankEmblDdb"` GenbankEmblDdb string `db:"genbank_embl_ddb" json:"genbankEmblDdb"`
IsolatedFrom sql.NullString `db:"isolated_from" json:"isolatedFrom"`
CreatedAt time.Time `db:"created_at" json:"createdAt"` CreatedAt time.Time `db:"created_at" json:"createdAt"`
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"` UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"` DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"`

View file

@ -55,7 +55,7 @@ func TestStrainService_Create(t *testing.T) {
mux.HandleFunc(urlPath(t, router.CreateStrain, nil), func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc(urlPath(t, router.CreateStrain, nil), func(w http.ResponseWriter, r *http.Request) {
called = true called = true
testMethod(t, r, "POST") testMethod(t, r, "POST")
testBody(t, r, `{"id":1,"speciesId":1,"strainName":"Test Strain","strainType":"Test Type","etymology":"Test Etymology","accessionBanks":"Test Accession","genbankEmblDdb":"Test Genbank","createdAt":"0001-01-01T00:00:00Z","updatedAt":"0001-01-01T00:00:00Z","deletedAt":{"Time":"0001-01-01T00:00:00Z","Valid":false}}`+"\n") testBody(t, r, `{"id":1,"speciesId":1,"strainName":"Test Strain","strainType":"Test Type","etymology":"Test Etymology","accessionBanks":"Test Accession","genbankEmblDdb":"Test Genbank","isolatedFrom":{"String":"","Valid":false},"createdAt":"0001-01-01T00:00:00Z","updatedAt":"0001-01-01T00:00:00Z","deletedAt":{"Time":"0001-01-01T00:00:00Z","Valid":false}}`+"\n")
w.WriteHeader(http.StatusCreated) w.WriteHeader(http.StatusCreated)
writeJSON(w, want) writeJSON(w, want)
@ -124,7 +124,7 @@ func TestStrainService_Update(t *testing.T) {
mux.HandleFunc(urlPath(t, router.UpdateStrain, map[string]string{"Id": "1"}), func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc(urlPath(t, router.UpdateStrain, map[string]string{"Id": "1"}), func(w http.ResponseWriter, r *http.Request) {
called = true called = true
testMethod(t, r, "PUT") testMethod(t, r, "PUT")
testBody(t, r, `{"id":1,"speciesId":1,"strainName":"Test Strain Updated","strainType":"Test Type Updated","etymology":"Test Etymology Updated","accessionBanks":"Test Accession Updated","genbankEmblDdb":"Test Genbank Updated","createdAt":"0001-01-01T00:00:00Z","updatedAt":"0001-01-01T00:00:00Z","deletedAt":{"Time":"0001-01-01T00:00:00Z","Valid":false}}`+"\n") testBody(t, r, `{"id":1,"speciesId":1,"strainName":"Test Strain Updated","strainType":"Test Type Updated","etymology":"Test Etymology Updated","accessionBanks":"Test Accession Updated","genbankEmblDdb":"Test Genbank Updated","isolatedFrom":{"String":"","Valid":false},"createdAt":"0001-01-01T00:00:00Z","updatedAt":"0001-01-01T00:00:00Z","deletedAt":{"Time":"0001-01-01T00:00:00Z","Valid":false}}`+"\n")
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
writeJSON(w, want) writeJSON(w, want)
}) })