mirror of https://github.com/docker/docs.git
[Store] Drop an index variable in Store.All
Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
This commit is contained in:
parent
1f2bd67555
commit
0618c29be2
|
@ -122,11 +122,9 @@ func (s *Store) All() []*RequestedState {
|
|||
s.RLock()
|
||||
defer s.RUnlock()
|
||||
|
||||
states := make([]*RequestedState, len(s.values))
|
||||
i := 0
|
||||
states := make([]*RequestedState, 0, len(s.values))
|
||||
for _, state := range s.values {
|
||||
states[i] = state
|
||||
i = i + 1
|
||||
states = append(states, state)
|
||||
}
|
||||
return states
|
||||
}
|
||||
|
|
|
@ -40,6 +40,14 @@ func TestStore(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
assert.Equal(t, c2.Name, ret.Name)
|
||||
|
||||
// Only one item in the store
|
||||
all := store.All()
|
||||
assert.Equal(t, 1, len(all))
|
||||
// The same name
|
||||
assert.Equal(t, c2.Name, all[0].Name)
|
||||
// It's actually the same pointer
|
||||
assert.Equal(t, c2, all[0])
|
||||
|
||||
// Initialize a brand new store and retrieve "foo" again.
|
||||
// This is to ensure data load on initialization works correctly.
|
||||
store = NewStore(dir)
|
||||
|
|
Loading…
Reference in New Issue