Skip to content

Commit

Permalink
Merge pull request #2508 from yosiat/yosiat/kv-local-sender-tests
Browse files Browse the repository at this point in the history
Adding tests for LocalSender - RemoveStore and GetStoreIDs
  • Loading branch information
bdarnell committed Sep 16, 2015
2 parents c1e2933 + aa8897f commit 84e4aed
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
11 changes: 0 additions & 11 deletions kv/local_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ func (ls *LocalSender) VisitStores(visitor func(s *storage.Store) error) error {
return nil
}

// GetStoreIDs returns all the current store ids in a random order.
func (ls *LocalSender) GetStoreIDs() []proto.StoreID {
ls.mu.RLock()
defer ls.mu.RUnlock()
storeIDs := make([]proto.StoreID, 0, len(ls.storeMap))
for storeID := range ls.storeMap {
storeIDs = append(storeIDs, storeID)
}
return storeIDs
}

// SendBatch implements batch.Sender.
func (ls *LocalSender) SendBatch(ctx context.Context, ba proto.BatchRequest) (*proto.BatchResponse, error) {
trace := tracer.FromCtx(ctx)
Expand Down
15 changes: 15 additions & 0 deletions kv/local_sender_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,21 @@ func TestLocalSenderAddStore(t *testing.T) {
}
}

func TestLocalSenderRemoveStore(t *testing.T) {
defer leaktest.AfterTest(t)
ls := NewLocalSender()

storeID := proto.StoreID(89)

ls.AddStore(&storage.Store{Ident: proto.StoreIdent{StoreID: storeID}})

ls.RemoveStore(&storage.Store{Ident: proto.StoreIdent{StoreID: storeID}})

if ls.HasStore(storeID) {
t.Errorf("expted local sender to remove storeID=%d", storeID)
}
}

func TestLocalSenderGetStoreCount(t *testing.T) {
defer leaktest.AfterTest(t)
ls := NewLocalSender()
Expand Down

0 comments on commit 84e4aed

Please sign in to comment.