(c *C)
| 69 | } |
| 70 | |
| 71 | func (s *PackagePoolSuite) TestRemove(c *C) { |
| 72 | _ = os.MkdirAll(filepath.Join(s.pool.rootPath, "bd", "0b"), 0755) |
| 73 | _ = os.MkdirAll(filepath.Join(s.pool.rootPath, "bd", "0a"), 0755) |
| 74 | _ = os.MkdirAll(filepath.Join(s.pool.rootPath, "ae", "0c"), 0755) |
| 75 | |
| 76 | _ = os.WriteFile(filepath.Join(s.pool.rootPath, "ae", "0c", "1.deb"), []byte("1"), 0644) |
| 77 | _ = os.WriteFile(filepath.Join(s.pool.rootPath, "ae", "0c", "2.deb"), []byte("22"), 0644) |
| 78 | _ = os.WriteFile(filepath.Join(s.pool.rootPath, "bd", "0a", "3.deb"), []byte("333"), 0644) |
| 79 | _ = os.WriteFile(filepath.Join(s.pool.rootPath, "bd", "0b", "4.deb"), []byte("4444"), 0644) |
| 80 | |
| 81 | size, err := s.pool.Remove("ae/0c/2.deb") |
| 82 | c.Check(err, IsNil) |
| 83 | c.Check(size, Equals, int64(2)) |
| 84 | |
| 85 | _, err = s.pool.Remove("ae/0c/2.deb") |
| 86 | c.Check(err, ErrorMatches, ".*no such file or directory") |
| 87 | |
| 88 | list, err := s.pool.FilepathList(nil) |
| 89 | c.Check(err, IsNil) |
| 90 | c.Check(list, DeepEquals, []string{"ae/0c/1.deb", "bd/0a/3.deb", "bd/0b/4.deb"}) |
| 91 | } |
| 92 | |
| 93 | func isSameDevice(s *PackagePoolSuite) bool { |
| 94 | poolPath, _ := s.pool.buildPoolPath(filepath.Base(s.debFile), &s.checksum) |
nothing calls this directly
no test coverage detected