@@ -2,7 +2,7 @@ package volume
2
2
3
3
import (
4
4
"context"
5
- "fmt "
5
+ "path/filepath "
6
6
"strings"
7
7
"testing"
8
8
"time"
@@ -20,7 +20,6 @@ import (
20
20
21
21
func TestVolumesCreateAndList (t * testing.T ) {
22
22
skip .If (t , testEnv .IsRemoteDaemon , "cannot run daemon when remote daemon" )
23
- skip .If (t , testEnv .OSType == "windows" , "FIXME" )
24
23
defer setupTest (t )()
25
24
client := request .NewAPIClient (t )
26
25
ctx := context .Background ()
@@ -37,7 +36,7 @@ func TestVolumesCreateAndList(t *testing.T) {
37
36
Driver : "local" ,
38
37
Scope : "local" ,
39
38
Name : name ,
40
- Mountpoint : fmt . Sprintf ( "%s/volumes/%s/_data" , testEnv .DaemonInfo .DockerRootDir , name ),
39
+ Mountpoint : filepath . Join ( testEnv .DaemonInfo .DockerRootDir , "volumes" , name , "_data" ),
41
40
}
42
41
assert .Check (t , is .DeepEqual (vol , expected , cmpopts .EquateEmpty ()))
43
42
@@ -77,38 +76,23 @@ func TestVolumesRemove(t *testing.T) {
77
76
78
77
func TestVolumesInspect (t * testing.T ) {
79
78
skip .If (t , testEnv .IsRemoteDaemon , "cannot run daemon when remote daemon" )
80
- skip .If (t , testEnv .OSType == "windows" , "FIXME" )
81
79
defer setupTest (t )()
82
80
client := request .NewAPIClient (t )
83
81
ctx := context .Background ()
84
82
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 {})
92
85
assert .NilError (t , err )
93
86
94
- vol , err := client .VolumeInspect (ctx , name )
87
+ inspected , err := client .VolumeInspect (ctx , vol . Name )
95
88
assert .NilError (t , err )
96
89
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 ()))
106
91
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 ))
109
94
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 )
112
96
}
113
97
114
98
func getPrefixAndSlashFromDaemonPlatform () (prefix , slash string ) {
0 commit comments