OLD | NEW |
1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package filesystem | 5 package filesystem |
6 | 6 |
7 import ( | 7 import ( |
8 "io/ioutil" | 8 "io/ioutil" |
9 "os" | 9 "os" |
10 "path/filepath" | 10 "path/filepath" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 _, err := os.Open(dnePath) | 46 _, err := os.Open(dnePath) |
47 if !os.IsNotExist(err) { | 47 if !os.IsNotExist(err) { |
48 t.Fatalf("failed to get IsNotExist error: %s", err) | 48 t.Fatalf("failed to get IsNotExist error: %s", err) |
49 } | 49 } |
50 | 50 |
51 Convey(`IsNotExist works`, t, func() { | 51 Convey(`IsNotExist works`, t, func() { |
52 So(IsNotExist(nil), ShouldBeFalse) | 52 So(IsNotExist(nil), ShouldBeFalse) |
53 So(IsNotExist(errors.New("something")), ShouldBeFalse) | 53 So(IsNotExist(errors.New("something")), ShouldBeFalse) |
54 | 54 |
55 So(IsNotExist(err), ShouldBeTrue) | 55 So(IsNotExist(err), ShouldBeTrue) |
56 » » » So(IsNotExist(errors.Annotate(err).Reason("annotated").E
rr()), ShouldBeTrue) | 56 » » » So(IsNotExist(errors.Annotate(err, "annotated").Err()),
ShouldBeTrue) |
57 }) | 57 }) |
58 }) | 58 }) |
59 } | 59 } |
60 | 60 |
61 func TestAbsPath(t *testing.T) { | 61 func TestAbsPath(t *testing.T) { |
62 t.Parallel() | 62 t.Parallel() |
63 | 63 |
64 // Create a temporary directory so we control its contents. This will le
t us | 64 // Create a temporary directory so we control its contents. This will le
t us |
65 // safely create an IsNotExist error. | 65 // safely create an IsNotExist error. |
66 withTempDir(t, func(tdir string) { | 66 withTempDir(t, func(tdir string) { |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 So(isGone(subDir), ShouldBeTrue) | 235 So(isGone(subDir), ShouldBeTrue) |
236 }) | 236 }) |
237 }) | 237 }) |
238 | 238 |
239 Convey(`Will return nil if the target does not exist`, f
unc() { | 239 Convey(`Will return nil if the target does not exist`, f
unc() { |
240 So(RemoveAll(filepath.Join(tdir, "dne")), Should
BeNil) | 240 So(RemoveAll(filepath.Join(tdir, "dne")), Should
BeNil) |
241 }) | 241 }) |
242 }) | 242 }) |
243 }) | 243 }) |
244 } | 244 } |
OLD | NEW |