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

Unified Diff: go/src/infra/tools/cipd/local/deployer_test.go

Issue 1154423015: cipd: Extract high level file system operations into the separate interface. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/tools/cipd/local/deployer.go ('k') | go/src/infra/tools/cipd/local/files.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tools/cipd/local/deployer_test.go
diff --git a/go/src/infra/tools/cipd/local/deployer_test.go b/go/src/infra/tools/cipd/local/deployer_test.go
index 62b628fb54608e7e7b3a96d2ef64b884682a9b50..cc95eb451a10a8be3d91be7fd602829f8172a3db 100644
--- a/go/src/infra/tools/cipd/local/deployer_test.go
+++ b/go/src/infra/tools/cipd/local/deployer_test.go
@@ -34,29 +34,8 @@ func TestUtilities(t *testing.T) {
f.Close()
}
ensureLink := func(symlinkRel string, target string) error {
- return ensureSymlink(filepath.Join(tempDir, symlinkRel), target)
+ return os.Symlink(target, filepath.Join(tempDir, symlinkRel))
}
- readLink := func(symlinkRel string) string {
- val, err := os.Readlink(filepath.Join(tempDir, symlinkRel))
- So(err, ShouldBeNil)
- return val
- }
-
- Convey("ensureSymlink creates new symlink", func() {
- So(ensureLink("symlink", "target"), ShouldBeNil)
- So(readLink("symlink"), ShouldEqual, "target")
- })
-
- Convey("ensureSymlink builds full path", func() {
- So(ensureLink(filepath.Join("a", "b", "c"), "target"), ShouldBeNil)
- So(readLink(filepath.Join("a", "b", "c")), ShouldEqual, "target")
- })
-
- Convey("ensureSymlink replaces existing one", func() {
- So(ensureLink("symlink", "target"), ShouldBeNil)
- So(ensureLink("symlink", "another"), ShouldBeNil)
- So(readLink("symlink"), ShouldEqual, "another")
- })
Convey("scanPackageDir works with empty dir", func() {
err := os.Mkdir(filepath.Join(tempDir, "dir"), 0777)
@@ -90,37 +69,6 @@ func TestUtilities(t *testing.T) {
"b/1",
})
})
-
- Convey("ensureDirectoryGone works with missing dir", func() {
- So(ensureDirectoryGone(filepath.Join(tempDir, "missing"), nil), ShouldBeNil)
- })
-
- Convey("ensureDirectoryGone works", func() {
- touch("dir/a/1")
- touch("dir/a/2")
- touch("dir/b/1")
- So(ensureDirectoryGone(filepath.Join(tempDir, "dir"), nil), ShouldBeNil)
- _, err := os.Stat(filepath.Join(tempDir, "dir"))
- So(os.IsNotExist(err), ShouldBeTrue)
- })
-
- Convey("ensureFileGone works", func() {
- touch("abc")
- So(ensureFileGone(filepath.Join(tempDir, "abc"), nil), ShouldBeNil)
- _, err := os.Stat(filepath.Join(tempDir, "abc"))
- So(os.IsNotExist(err), ShouldBeTrue)
- })
-
- Convey("ensureFileGone works with missing file", func() {
- So(ensureFileGone(filepath.Join(tempDir, "abc"), nil), ShouldBeNil)
- })
-
- Convey("ensureFileGone works with symlink", func() {
- ensureLink("abc", "target")
- So(ensureFileGone(filepath.Join(tempDir, "abc"), nil), ShouldBeNil)
- _, err := os.Stat(filepath.Join(tempDir, "abc"))
- So(os.IsNotExist(err), ShouldBeTrue)
- })
})
}
« no previous file with comments | « go/src/infra/tools/cipd/local/deployer.go ('k') | go/src/infra/tools/cipd/local/files.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698