Fix TestVolumesCreateAndList when running against a shared daemon

The daemon may already have other volumes, so filter out those
when running the test.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 566eea13e6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-04-19 19:05:18 +02:00
parent e1b045c25e
commit 620d9d3c75
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -40,12 +40,20 @@ func TestVolumesCreateAndList(t *testing.T) {
} }
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty())) assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty()))
volumes, err := client.VolumeList(ctx, filters.Args{}) volList, err := client.VolumeList(ctx, filters.Args{})
assert.NilError(t, err) assert.NilError(t, err)
assert.Assert(t, len(volList.Volumes) > 0)
assert.Check(t, is.Equal(len(volumes.Volumes), 1)) volumes := volList.Volumes[:0]
assert.Check(t, volumes.Volumes[0] != nil) for _, v := range volList.Volumes {
assert.Check(t, is.DeepEqual(*volumes.Volumes[0], expected, cmpopts.EquateEmpty())) if v.Name == vol.Name {
volumes = append(volumes, v)
}
}
assert.Check(t, is.Equal(len(volumes), 1))
assert.Check(t, volumes[0] != nil)
assert.Check(t, is.DeepEqual(*volumes[0], expected, cmpopts.EquateEmpty()))
} }
func TestVolumesRemove(t *testing.T) { func TestVolumesRemove(t *testing.T) {