Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: common/system/filesystem/filesystem_test.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/system/filesystem/filesystem.go ('k') | common/system/prober/probe.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « common/system/filesystem/filesystem.go ('k') | common/system/prober/probe.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698