Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
Connor1996 committed Mar 2, 2018
1 parent a9a8b88 commit 48b7dc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion server/api/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (h *labelsHandler) GetStores(w http.ResponseWriter, r *http.Request) {

stores := cluster.GetStores()
storesInfo := &storesInfo{
Stores: make([]*StoreInfo, 0, len(stores)),
Stores: make([]*storeInfo, 0, len(stores)),
}

stores = filter.filter(stores)
Expand Down
10 changes: 5 additions & 5 deletions server/api/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s *testStoreSuite) TestStoreLabel(c *C) {
labels := map[string]string{"zone": "cn", "host": "local"}
b, err := json.Marshal(labels)
c.Assert(err, IsNil)
err = postJSON(&http.Client{}, url+"/label", b)
err = postJSON(url+"/label", b)
c.Assert(err, IsNil)

err = readJSONWithURL(url, &info)
Expand All @@ -148,7 +148,7 @@ func (s *testStoreSuite) TestStoreLabel(c *C) {
labels = map[string]string{"zack": "zack1", "Host": "host1"}
b, err = json.Marshal(labels)
c.Assert(err, IsNil)
err = postJSON(&http.Client{}, url+"/label", b)
err = postJSON(url+"/label", b)
c.Assert(err, IsNil)

expectLabel := map[string]string{"zone": "cn", "zack": "zack1", "host": "host1"}
Expand Down Expand Up @@ -197,23 +197,23 @@ func (s *testStoreSuite) TestStoreSetState(c *C) {

// Set to Offline.
info = storeInfo{}
err = postJSON(&http.Client{}, url+"/state?state=Offline", nil)
err = postJSON(url+"/state?state=Offline", nil)
c.Assert(err, IsNil)
err = readJSONWithURL(url, &info)
c.Assert(err, IsNil)
c.Assert(info.Store.State, Equals, metapb.StoreState_Offline)

// Invalid state.
info = storeInfo{}
err = postJSON(&http.Client{}, url+"/state?state=Foo", nil)
err = postJSON(url+"/state?state=Foo", nil)
c.Assert(err, NotNil)
err = readJSONWithURL(url, &info)
c.Assert(err, IsNil)
c.Assert(info.Store.State, Equals, metapb.StoreState_Offline)

// Set back to Up.
info = storeInfo{}
err = postJSON(&http.Client{}, url+"/state?state=Up", nil)
err = postJSON(url+"/state?state=Up", nil)
c.Assert(err, IsNil)
err = readJSONWithURL(url, &info)
c.Assert(err, IsNil)
Expand Down

0 comments on commit 48b7dc1

Please sign in to comment.