(c *C)
| 327 | } |
| 328 | |
| 329 | func (s *PublishedStorageSuite) TestLinkFromPoolCache(c *C) { |
| 330 | root := c.MkDir() |
| 331 | pool := files.NewPackagePool(root, false) |
| 332 | cs := files.NewMockChecksumStorage() |
| 333 | |
| 334 | tmpFile1 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb") |
| 335 | err := os.WriteFile(tmpFile1, []byte("Contents"), 0644) |
| 336 | c.Assert(err, IsNil) |
| 337 | cksum1 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"} |
| 338 | |
| 339 | src1, err := pool.Import(tmpFile1, "mars-invaders_1.03.deb", &cksum1, true, cs) |
| 340 | c.Assert(err, IsNil) |
| 341 | |
| 342 | // Publish two packages at the same publish prefix |
| 343 | err = s.storage.LinkFromPool("", filepath.Join("pool", "a"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 344 | c.Check(err, IsNil) |
| 345 | |
| 346 | err = s.storage.LinkFromPool("", filepath.Join("pool", "b"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 347 | c.Check(err, IsNil) |
| 348 | |
| 349 | // Check only one listing request was done to the server |
| 350 | s.checkGetRequestsEqual(c, "/test?", []string{"/test?encryption=", "/test?encryption=", "/test?list-type=2&max-keys=1000&prefix=pool%2F"}) |
| 351 | |
| 352 | s.srv.Requests = nil |
| 353 | // Publish two packages at a different prefix |
| 354 | err = s.storage.LinkFromPool("publish-prefix", filepath.Join("pool", "a"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 355 | c.Check(err, IsNil) |
| 356 | |
| 357 | err = s.storage.LinkFromPool("publish-prefix", filepath.Join("pool", "b"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 358 | c.Check(err, IsNil) |
| 359 | |
| 360 | // Check no listing request was done to the server (pathCache is used) |
| 361 | s.checkGetRequestsEqual(c, "/test?", []string{}) |
| 362 | |
| 363 | s.srv.Requests = nil |
| 364 | // Publish two packages at a prefixed storage |
| 365 | err = s.prefixedStorage.LinkFromPool("", filepath.Join("pool", "a"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 366 | c.Check(err, IsNil) |
| 367 | |
| 368 | err = s.prefixedStorage.LinkFromPool("", filepath.Join("pool", "b"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 369 | c.Check(err, IsNil) |
| 370 | |
| 371 | // Check only one listing request was done to the server |
| 372 | s.checkGetRequestsEqual(c, "/test?", []string{ |
| 373 | "/test?list-type=2&max-keys=1000&prefix=lala%2Fpool%2F", |
| 374 | }) |
| 375 | |
| 376 | // Publish two packages at a prefixed storage plus a publish prefix. |
| 377 | s.srv.Requests = nil |
| 378 | err = s.prefixedStorage.LinkFromPool("publish-prefix", filepath.Join("pool", "a"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 379 | c.Check(err, IsNil) |
| 380 | |
| 381 | err = s.prefixedStorage.LinkFromPool("publish-prefix", filepath.Join("pool", "b"), "mars-invaders_1.03.deb", pool, src1, cksum1, false) |
| 382 | c.Check(err, IsNil) |
| 383 | |
| 384 | // Check no listing request was done to the server (pathCache is used) |
| 385 | s.checkGetRequestsEqual(c, "/test?", []string{}) |
| 386 |
nothing calls this directly
no test coverage detected