| 269 | } |
| 270 | |
| 271 | func (s *PackagePoolSuite) TestImportMove(c *C) { |
| 272 | tmpDir := c.MkDir() |
| 273 | tmpPath := filepath.Join(tmpDir, filepath.Base(s.debFile)) |
| 274 | |
| 275 | dst, err := os.Create(tmpPath) |
| 276 | c.Assert(err, IsNil) |
| 277 | |
| 278 | src, err := os.Open(s.debFile) |
| 279 | c.Assert(err, IsNil) |
| 280 | |
| 281 | _, err = io.Copy(dst, src) |
| 282 | c.Assert(err, IsNil) |
| 283 | |
| 284 | c.Assert(dst.Close(), IsNil) |
| 285 | c.Assert(src.Close(), IsNil) |
| 286 | |
| 287 | path, err := s.pool.Import(tmpPath, filepath.Base(tmpPath), &s.checksum, true, s.cs) |
| 288 | c.Check(err, IsNil) |
| 289 | c.Check(path, Equals, "c7/6b/4bd12fd92e4dfe1b55b18a67a669_libboost-program-options-dev_1.49.0.1_i386.deb") |
| 290 | |
| 291 | info, err := s.pool.Stat(path) |
| 292 | c.Assert(err, IsNil) |
| 293 | c.Check(info.Size(), Equals, int64(2738)) |
| 294 | c.Check(int(info.Sys().(*syscall.Stat_t).Nlink), Equals, 1) |
| 295 | } |
| 296 | |
| 297 | func (s *PackagePoolSuite) TestImportNotExist(c *C) { |
| 298 | _, err := s.pool.Import("no-such-file", "a.deb", &s.checksum, false, s.cs) |