MCPcopy
hub / github.com/nektos/act / TestHandler_CustomExternalURL

Function TestHandler_CustomExternalURL

pkg/artifactcache/handler_test.go:590–622  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

588}
589
590func 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
624func TestHandler_gcCache(t *testing.T) {
625 dir := filepath.Join(t.TempDir(), "artifactcache")

Callers

nothing calls this directly

Calls 8

StartHandlerFunction · 0.85
makeFunction · 0.85
uploadCacheNormallyFunction · 0.85
GetActualPortMethod · 0.80
ExternalURLMethod · 0.80
NameMethod · 0.80
ReadMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…