Adding ‘isolated from’ to strains.
This commit is contained in:
parent
f33205e721
commit
641203ceb9
3 changed files with 15 additions and 12 deletions
|
@ -9,6 +9,7 @@ CREATE TABLE strains (
|
|||
etymology CHARACTER VARYING(500),
|
||||
accession_banks CHARACTER VARYING(100),
|
||||
genbank_embl_ddb CHARACTER VARYING(100),
|
||||
isolated_from CHARACTER VARYING(100),
|
||||
|
||||
created_at TIMESTAMP WITH TIME ZONE,
|
||||
updated_at TIMESTAMP WITH TIME ZONE,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
@ -12,16 +13,17 @@ import (
|
|||
|
||||
// A Strain is a subclass of species
|
||||
type Strain struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
SpeciesId int64 `db:"species_id" json:"speciesId"`
|
||||
StrainName string `db:"strain_name" json:"strainName"`
|
||||
StrainType string `db:"strain_type" json:"strainType"`
|
||||
Etymology string `db:"etymology" json:"etymology"`
|
||||
AccessionBanks string `db:"accession_banks" json:"accessionBanks"`
|
||||
GenbankEmblDdb string `db:"genbank_embl_ddb" json:"genbankEmblDdb"`
|
||||
CreatedAt time.Time `db:"created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
|
||||
DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
SpeciesId int64 `db:"species_id" json:"speciesId"`
|
||||
StrainName string `db:"strain_name" json:"strainName"`
|
||||
StrainType string `db:"strain_type" json:"strainType"`
|
||||
Etymology string `db:"etymology" json:"etymology"`
|
||||
AccessionBanks string `db:"accession_banks" json:"accessionBanks"`
|
||||
GenbankEmblDdb string `db:"genbank_embl_ddb" json:"genbankEmblDdb"`
|
||||
IsolatedFrom sql.NullString `db:"isolated_from" json:"isolatedFrom"`
|
||||
CreatedAt time.Time `db:"created_at" json:"createdAt"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updatedAt"`
|
||||
DeletedAt pq.NullTime `db:"deleted_at" json:"deletedAt"`
|
||||
}
|
||||
|
||||
func NewStrain() *Strain {
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestStrainService_Create(t *testing.T) {
|
|||
mux.HandleFunc(urlPath(t, router.CreateStrain, nil), func(w http.ResponseWriter, r *http.Request) {
|
||||
called = true
|
||||
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)
|
||||
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) {
|
||||
called = true
|
||||
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)
|
||||
writeJSON(w, want)
|
||||
})
|
||||
|
|
Reference in a new issue