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

Side by Side Diff: go/src/infra/tools/cipd/local/files_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, 6 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 | « go/src/infra/tools/cipd/local/files.go ('k') | go/src/infra/tools/cipd/local/fs.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package local 5 package local
6 6
7 import ( 7 import (
8 "io/ioutil" 8 "io/ioutil"
9 "os" 9 "os"
10 "path/filepath" 10 "path/filepath"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 discoveredTarget, err := file.SymlinkTarget() 256 discoveredTarget, err := file.SymlinkTarget()
257 So(err, ShouldBeNil) 257 So(err, ShouldBeNil)
258 So(discoveredTarget, ShouldEqual, target) 258 So(discoveredTarget, ShouldEqual, target)
259 } 259 }
260 260
261 func TestFileSystemDestination(t *testing.T) { 261 func TestFileSystemDestination(t *testing.T) {
262 Convey("Given a temp directory", t, func() { 262 Convey("Given a temp directory", t, func() {
263 tempDir, err := ioutil.TempDir("", "cipd_test") 263 tempDir, err := ioutil.TempDir("", "cipd_test")
264 destDir := filepath.Join(tempDir, "dest") 264 destDir := filepath.Join(tempDir, "dest")
265 So(err, ShouldBeNil) 265 So(err, ShouldBeNil)
266 » » dest := NewFileSystemDestination(destDir) 266 » » dest := NewFileSystemDestination(destDir, nil)
267 Reset(func() { os.RemoveAll(tempDir) }) 267 Reset(func() { os.RemoveAll(tempDir) })
268 268
269 writeFileToDest := func(name string, executable bool, data strin g) { 269 writeFileToDest := func(name string, executable bool, data strin g) {
270 writer, err := dest.CreateFile(name, executable) 270 writer, err := dest.CreateFile(name, executable)
271 if writer != nil { 271 if writer != nil {
272 defer writer.Close() 272 defer writer.Close()
273 } 273 }
274 So(err, ShouldBeNil) 274 So(err, ShouldBeNil)
275 _, err = writer.Write([]byte(data)) 275 _, err = writer.Write([]byte(data))
276 So(err, ShouldBeNil) 276 So(err, ShouldBeNil)
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 So(dest.Begin(), ShouldBeNil) 465 So(dest.Begin(), ShouldBeNil)
466 w, err := dest.CreateFile("a", false) 466 w, err := dest.CreateFile("a", false)
467 So(w, ShouldNotBeNil) 467 So(w, ShouldNotBeNil)
468 So(err, ShouldBeNil) 468 So(err, ShouldBeNil)
469 So(dest.End(true), ShouldNotBeNil) 469 So(dest.End(true), ShouldNotBeNil)
470 w.Close() 470 w.Close()
471 So(dest.End(true), ShouldBeNil) 471 So(dest.End(true), ShouldBeNil)
472 }) 472 })
473 }) 473 })
474 } 474 }
OLDNEW
« no previous file with comments | « go/src/infra/tools/cipd/local/files.go ('k') | go/src/infra/tools/cipd/local/fs.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698