Browse code

Don't assume the file system has sub-second precision timestamp

For example, FreeBSD doesn't have that
(see http://lists.freebsd.org/pipermail/freebsd-fs/2012-February/013677.html).

Docker-DCO-1.1-Signed-off-by: Kato Kazuyoshi <kato.kazuyoshi@gmail.com> (github: kzys)

Kato Kazuyoshi authored on 2014/04/05 10:29:40
Showing 1 changed files
... ...
@@ -138,7 +138,7 @@ func mutateSampleDir(t *testing.T, root string) {
138 138
 	}
139 139
 
140 140
 	// Rewrite a file
141
-	if err := ioutil.WriteFile(path.Join(root, "file2"), []byte("fileN\n"), 0777); err != nil {
141
+	if err := ioutil.WriteFile(path.Join(root, "file2"), []byte("fileNN\n"), 0777); err != nil {
142 142
 		t.Fatal(err)
143 143
 	}
144 144
 
... ...
@@ -146,12 +146,12 @@ func mutateSampleDir(t *testing.T, root string) {
146 146
 	if err := os.RemoveAll(path.Join(root, "file3")); err != nil {
147 147
 		t.Fatal(err)
148 148
 	}
149
-	if err := ioutil.WriteFile(path.Join(root, "file3"), []byte("fileM\n"), 0404); err != nil {
149
+	if err := ioutil.WriteFile(path.Join(root, "file3"), []byte("fileMM\n"), 0404); err != nil {
150 150
 		t.Fatal(err)
151 151
 	}
152 152
 
153 153
 	// Touch file
154
-	if err := os.Chtimes(path.Join(root, "file4"), time.Now(), time.Now()); err != nil {
154
+	if err := os.Chtimes(path.Join(root, "file4"), time.Now().Add(time.Second), time.Now().Add(time.Second)); err != nil {
155 155
 		t.Fatal(err)
156 156
 	}
157 157
 
... ...
@@ -195,7 +195,7 @@ func mutateSampleDir(t *testing.T, root string) {
195 195
 	}
196 196
 
197 197
 	// Touch dir
198
-	if err := os.Chtimes(path.Join(root, "dir3"), time.Now(), time.Now()); err != nil {
198
+	if err := os.Chtimes(path.Join(root, "dir3"), time.Now().Add(time.Second), time.Now().Add(time.Second)); err != nil {
199 199
 		t.Fatal(err)
200 200
 	}
201 201
 }