(t *testing.T)
| 588 | } |
| 589 | |
| 590 | func TestHandler_CustomExternalURL(t *testing.T) { |
| 591 | dir := filepath.Join(t.TempDir(), "artifactcache") |
| 592 | handler, err := StartHandler(dir, "", "127.0.0.1", 0, nil) |
| 593 | require.NoError(t, err) |
| 594 | |
| 595 | defer func() { |
| 596 | require.NoError(t, handler.Close()) |
| 597 | }() |
| 598 | |
| 599 | handler.customExternalURL = fmt.Sprintf("http://%s:%d", "127.0.0.1", handler.GetActualPort()) |
| 600 | |
| 601 | assert.Equal(t, fmt.Sprintf("http://%s:%d/%s", "127.0.0.1", handler.GetActualPort(), handler.token), handler.ExternalURL()) |
| 602 | |
| 603 | base := fmt.Sprintf("%s%s", handler.ExternalURL(), apiPath) |
| 604 | |
| 605 | t.Run("advertise url set wrong", func(t *testing.T) { |
| 606 | original := handler.customExternalURL |
| 607 | defer func() { |
| 608 | handler.customExternalURL = original |
| 609 | }() |
| 610 | handler.customExternalURL = "http://127.0.0.999:1234" |
| 611 | assert.Equal(t, "http://127.0.0.999:1234/"+handler.token, handler.ExternalURL()) |
| 612 | }) |
| 613 | |
| 614 | t.Run("reserve and upload", func(t *testing.T) { |
| 615 | key := strings.ToLower(t.Name()) |
| 616 | version := "c19da02a2bd7e77277f1ac29ab45c09b7d46a4ee758284e26bb3045ad11d9d20" |
| 617 | content := make([]byte, 100) |
| 618 | _, err := rand.Read(content) |
| 619 | require.NoError(t, err) |
| 620 | uploadCacheNormally(t, base, key, version, content) |
| 621 | }) |
| 622 | } |
| 623 | |
| 624 | func TestHandler_gcCache(t *testing.T) { |
| 625 | dir := filepath.Join(t.TempDir(), "artifactcache") |
nothing calls this directly
no test coverage detected
searching dependent graphs…