8000 Merge pull request #38133 from thaJeztah/cleanup_volume_tests · moby/moby@35985ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 35985ca

Browse files
authored
Merge pull request #38133 from thaJeztah/cleanup_volume_tests
Cleanup volume integration tests
2 parents be17863 + b334198 commit 35985ca

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

integration/volume/volume_test.go

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package volume
22

33
import (
44
"context"
5-
"fmt"
5+
"path/filepath"
66
"strings"
77
"testing"
88
"time"
@@ -20,7 +20,6 @@ import (
2020

2121
func TestVolumesCreateAndList(t *testing.T) {
2222
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
23-
skip.If(t, testEnv.OSType == "windows", "FIXME")
2423
defer setupTest(t)()
2524
client := request.NewAPIClient(t)
2625
ctx := context.Background()
@@ -37,7 +36,7 @@ func TestVolumesCreateAndList(t *testing.T) {
3736
Driver: "local",
3837
Scope: "local",
3938
Name: name,
40-
Mountpoint: fmt.Sprintf("%s/volumes/%s/_data", testEnv.DaemonInfo.DockerRootDir, name),
39+
Mountpoint: filepath.Join(testEnv.DaemonInfo.DockerRootDir, "volumes", name, "_data"),
4140
}
4241
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty()))
4342

@@ -77,38 +76,23 @@ func TestVolumesRemove(t *testing.T) {
7776

7877
func TestVolumesInspect(t *testing.T) {
7978
skip.If(t, testEnv.IsRemoteDaemon, "cannot run daemon when remote daemon")
80-
skip.If(t, testEnv.OSType == "windows", "FIXME")
8179
defer setupTest(t)()
8280
client := request.NewAPIClient(t)
8381
ctx := context.Background()
8482

85-
// sampling current time minus a minute so to now have false positive in case of delays
86-
now := time.Now().Truncate(time.Minute)
87-
88-
name := t.Name()
89-
_, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{
90-
Name: name,
91-
})
83+
now := time.Now()
84+
vol, err := client.VolumeCreate(ctx, volumetypes.VolumeCreateBody{})
9285
assert.NilError(t, err)
9386

94-
vol, err := client.VolumeInspect(ctx, name)
87+
inspected, err := client.VolumeInspect(ctx, vol.Name)
9588
assert.NilError(t, err)
9689

97-
expected := types.Volume{
98-
// Ignore timestamp of CreatedAt
99-
CreatedAt: vol.CreatedAt,
100-
Driver: "local",
101-
Scope: "local",
102-
Name: name,
103-
Mountpoint: fmt.Sprintf("%s/volumes/%s/_data", testEnv.DaemonInfo.DockerRootDir, name),
104-
}
105-
assert.Check(t, is.DeepEqual(vol, expected, cmpopts.EquateEmpty()))
90+
assert.Check(t, is.DeepEqual(inspected, vol, cmpopts.EquateEmpty()))
10691

107-
// comparing CreatedAt field time for the new volume to now. Removing a minute from both to avoid false positive
108-
testCreatedAt, err := time.Parse(time.RFC3339, strings.TrimSpace(vol.CreatedAt))
92+
// comparing CreatedAt field time for the new volume to now. Truncate to 1 minute precision to avoid false positive
93+
createdAt, err := time.Parse(time.RFC3339, strings.TrimSpace(inspected.CreatedAt))
10994
assert.NilError(t, err)
110-
testCreatedAt = testCreatedAt.Truncate(time.Minute)
111-
assert.Check(t, is.Equal(testCreatedAt.Equal(now), true), "Time Volume is CreatedAt not equal to current time")
95+
assert.Check(t, createdAt.Truncate(time.Minute).Equal(now.Truncate(time.Minute)), "CreatedAt (%s) not equal to creation time (%s)", createdAt, now)
11296
}
11397

11498
func getPrefixAndSlashFromDaemonPlatform() (prefix, slash string) {

0 commit comments

Comments
 (0)
0