Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Oct 2, 2019
1 parent 68963ad commit 27b883a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestClient(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(1, 1)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(1, 1, 'rack1')")
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion drain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestDrain(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(1, 1)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(1, 1, 'rack1')")
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CREATE TABLE `zone` (
CREATE TABLE `rack` (
`rackid` mediumint(8) unsigned NOT NULL,
`zoneid` mediumint(8) unsigned NOT NULL,
`name` varchar(40),
`name` varchar(40) NOT NULL,
PRIMARY KEY (`rackid`),
FOREIGN KEY (`zoneid`) REFERENCES `zone` (`zoneid`)
);
Expand Down
2 changes: 1 addition & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func setupServer(t *testing.T, ttl time.Duration) (s *Server, closeFunc func())
if err != nil {
t.Fatal(err)
}
_, err = s.db.Exec("insert into rack(rackid, zoneid) values(1, 1)")
_, err = s.db.Exec("insert into rack(rackid, zoneid, name) values(1, 1, 'rack1')")
if err != nil {
t.Fatal(err)
}
Expand Down
12 changes: 6 additions & 6 deletions tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func insertHost(t *testing.T, tr *Tracker) {
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(1, 1)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(1, 1, 'rack1')")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -137,19 +137,19 @@ func TestCreateOpenSameZone(t *testing.T) {
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(1, 1)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(1, 1, 'rack1')")
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(2, 1)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(2, 1, 'rack2')")
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(3, 2)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(3, 2, 'rack3')")
if err != nil {
t.Fatal(err)
}
_, err = tr.db.Exec("insert into rack(rackid, zoneid) values(4, 2)")
_, err = tr.db.Exec("insert into rack(rackid, zoneid, name) values(4, 2, 'rack4')")
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func TestGetDevices(t *testing.T) {
t.Errorf("handler returned wrong status code: got %v want %v",
status, http.StatusOK)
}
expected := `{"devices":[{"devid":2,"hostid":1,"rackid":1,"zoneid":1,"status":"alive","bytes_total":1000,"bytes_used":500,"bytes_free":500,"updated_at":1510216046,"io_utilization":null}]}`
expected := `{"devices":[{"devid":2,"hostid":1,"host_name":"foo","host_status":"alive","rackid":1,"rack_name":"rack1","zoneid":1,"zone_name":"zone1","status":"alive","bytes_total":1000,"bytes_used":500,"bytes_free":500,"updated_at":1510216046,"io_utilization":null}]}`
if strings.TrimSpace(rr.Body.String()) != expected {
t.Errorf("handler returned unexpected body: got %v want %v",
rr.Body.String(), expected)
Expand Down

0 comments on commit 27b883a

Please sign in to comment.