Update strain. Fixed EML/EMBL typo in json.
This commit is contained in:
parent
b8bda910cd
commit
ff0e37d2ef
9 changed files with 163 additions and 2 deletions
|
@ -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,"species_id":1,"strain_name":"Test Strain","strain_type":"Test Type","etymology":"Test Etymology","accession_banks":"Test Accession","genbank_eml_ddb":"Test Genbank","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","deleted_at":"0001-01-01T00:00:00Z"}`+"\n")
|
||||
testBody(t, r, `{"id":1,"species_id":1,"strain_name":"Test Strain","strain_type":"Test Type","etymology":"Test Etymology","accession_banks":"Test Accession","genbank_embl_ddb":"Test Genbank","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","deleted_at":"0001-01-01T00:00:00Z"}`+"\n")
|
||||
|
||||
w.WriteHeader(http.StatusCreated)
|
||||
writeJSON(w, want)
|
||||
|
@ -113,3 +113,38 @@ func TestStrainService_List(t *testing.T) {
|
|||
t.Errorf("Strains.List return %+v, want %+v", strains, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStrainService_Update(t *testing.T) {
|
||||
setup()
|
||||
defer teardown()
|
||||
|
||||
want := newStrain()
|
||||
|
||||
var called bool
|
||||
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,"species_id":1,"strain_name":"Test Strain Updated","strain_type":"Test Type Updated","etymology":"Test Etymology Updated","accession_banks":"Test Accession Updated","genbank_embl_ddb":"Test Genbank Updated","created_at":"0001-01-01T00:00:00Z","updated_at":"0001-01-01T00:00:00Z","deleted_at":"0001-01-01T00:00:00Z"}`+"\n")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
writeJSON(w, want)
|
||||
})
|
||||
|
||||
strain := newStrain()
|
||||
strain.StrainName = "Test Strain Updated"
|
||||
strain.StrainType = "Test Type Updated"
|
||||
strain.Etymology = "Test Etymology Updated"
|
||||
strain.AccessionBanks = "Test Accession Updated"
|
||||
strain.GenbankEmblDdb = "Test Genbank Updated"
|
||||
updated, err := client.Strains.Update(strain.Id, strain)
|
||||
if err != nil {
|
||||
t.Errorf("Strains.Update returned error: %v", err)
|
||||
}
|
||||
|
||||
if !updated {
|
||||
t.Error("!updated")
|
||||
}
|
||||
|
||||
if !called {
|
||||
t.Fatal("!called")
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue