| 26 | ) |
| 27 | |
| 28 | func TestCopyFile(t *testing.T) { |
| 29 | Convey("copy file", t, func() { |
| 30 | bytes := []byte("abc") |
| 31 | defer os.Remove("testcopy") |
| 32 | defer os.Remove("testcopy2") |
| 33 | ioutil.WriteFile("testcopy", bytes, 0600) |
| 34 | CopyFile("testcopy", "testcopy2") |
| 35 | bytes2, _ := ioutil.ReadFile("testcopy2") |
| 36 | So(bytes2, ShouldResemble, bytes) |
| 37 | |
| 38 | n, err := CopyFile("testcopy", "testcopy") |
| 39 | So(err, ShouldBeNil) |
| 40 | So(n, ShouldBeZeroValue) |
| 41 | |
| 42 | n, err = CopyFile("/path/not/exist", "testcopy") |
| 43 | So(err, ShouldNotBeNil) |
| 44 | So(n, ShouldBeZeroValue) |
| 45 | |
| 46 | n, err = CopyFile("testcopy", "/path/not/exist") |
| 47 | So(err, ShouldNotBeNil) |
| 48 | So(n, ShouldBeZeroValue) |
| 49 | }) |
| 50 | } |
| 51 | |
| 52 | func TestHomeDirExpand(t *testing.T) { |
| 53 | Convey("expand ~ dir", t, func() { |