remove unused function

This commit is contained in:
Evan Jarrett
2025-12-26 09:37:57 -06:00
parent 2a60a47fd5
commit 363c12e6bf
2 changed files with 0 additions and 128 deletions
-8
View File
@@ -271,14 +271,6 @@ func digestToRKey(dgst digest.Digest) string {
return dgst.Encoded()
}
// GetLastFetchedHoldDID returns the hold DID from the most recently fetched manifest
// This is used by the routing repository to cache the hold for blob requests
func (s *ManifestStore) GetLastFetchedHoldDID() string {
s.mu.RLock()
defer s.mu.RUnlock()
return s.lastFetchedHoldDID
}
// rawManifest is a simple implementation of distribution.Manifest
type rawManifest struct {
mediaType string
-120
View File
@@ -136,60 +136,6 @@ func TestNewManifestStore(t *testing.T) {
}
}
// TestManifestStore_GetLastFetchedHoldDID tests tracking last fetched hold DID
func TestManifestStore_GetLastFetchedHoldDID(t *testing.T) {
tests := []struct {
name string
manifestHoldDID string
manifestHoldURL string
expectedLastFetched string
}{
{
name: "prefers HoldDID",
manifestHoldDID: "did:web:hold01.atcr.io",
manifestHoldURL: "https://hold01.atcr.io",
expectedLastFetched: "did:web:hold01.atcr.io",
},
{
name: "falls back to HoldEndpoint URL conversion",
manifestHoldDID: "",
manifestHoldURL: "https://hold02.atcr.io",
expectedLastFetched: "did:web:hold02.atcr.io",
},
{
name: "empty hold references",
manifestHoldDID: "",
manifestHoldURL: "",
expectedLastFetched: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client := atproto.NewClient("https://pds.example.com", "did:plc:test123", "token")
ctx := mockRegistryContext(client, "myapp", "", "did:plc:test123", "test.handle", nil)
store := NewManifestStore(ctx, nil)
// Simulate what happens in Get() when parsing a manifest record
var manifestRecord atproto.ManifestRecord
manifestRecord.HoldDID = tt.manifestHoldDID
manifestRecord.HoldEndpoint = tt.manifestHoldURL
// Mimic the hold DID extraction logic from Get()
if manifestRecord.HoldDID != "" {
store.lastFetchedHoldDID = manifestRecord.HoldDID
} else if manifestRecord.HoldEndpoint != "" {
store.lastFetchedHoldDID = atproto.ResolveHoldDIDFromURL(manifestRecord.HoldEndpoint)
}
got := store.GetLastFetchedHoldDID()
if got != tt.expectedLastFetched {
t.Errorf("GetLastFetchedHoldDID() = %v, want %v", got, tt.expectedLastFetched)
}
})
}
}
// TestRawManifest tests the rawManifest implementation
func TestRawManifest(t *testing.T) {
mediaType := "application/vnd.oci.image.manifest.v1+json"
@@ -541,72 +487,6 @@ func TestManifestStore_Get(t *testing.T) {
}
}
// TestManifestStore_Get_HoldDIDTracking tests that Get() stores the holdDID
func TestManifestStore_Get_HoldDIDTracking(t *testing.T) {
ociManifest := []byte(`{"schemaVersion":2}`)
tests := []struct {
name string
manifestResp string
expectedHoldDID string
}{
{
name: "tracks HoldDID from new format",
manifestResp: `{
"uri":"at://did:plc:test123/io.atcr.manifest/abc123",
"value":{
"$type":"io.atcr.manifest",
"holdDid":"did:web:hold01.atcr.io",
"holdEndpoint":"https://hold01.atcr.io",
"mediaType":"application/vnd.oci.image.manifest.v1+json",
"manifestBlob":{"ref":{"$link":"bafytest"},"size":100}
}
}`,
expectedHoldDID: "did:web:hold01.atcr.io",
},
{
name: "tracks HoldDID from legacy HoldEndpoint",
manifestResp: `{
"uri":"at://did:plc:test123/io.atcr.manifest/abc123",
"value":{
"$type":"io.atcr.manifest",
"holdEndpoint":"https://hold02.atcr.io",
"mediaType":"application/vnd.oci.image.manifest.v1+json",
"manifestBlob":{"ref":{"$link":"bafytest"},"size":100}
}
}`,
expectedHoldDID: "did:web:hold02.atcr.io",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == atproto.SyncGetBlob {
w.Write(ociManifest)
return
}
w.Write([]byte(tt.manifestResp))
}))
defer server.Close()
client := atproto.NewClient(server.URL, "did:plc:test123", "token")
ctx := mockRegistryContext(client, "myapp", "", "did:plc:test123", "test.handle", nil)
store := NewManifestStore(ctx, nil)
_, err := store.Get(context.Background(), "sha256:abc123")
if err != nil {
t.Fatalf("Get() error = %v", err)
}
gotHoldDID := store.GetLastFetchedHoldDID()
if gotHoldDID != tt.expectedHoldDID {
t.Errorf("GetLastFetchedHoldDID() = %v, want %v", gotHoldDID, tt.expectedHoldDID)
}
})
}
}
// TestManifestStore_Get_OnlyCountsGETRequests verifies that HEAD requests don't increment pull count
func TestManifestStore_Get_OnlyCountsGETRequests(t *testing.T) {
ociManifest := []byte(`{"schemaVersion":2}`)