Files
at-container-registry/test/integration/push_pull_test.go
T
Evan JarrettandClaude Fable 5.1 bd740060b2 make: lint the integration packages with their build tags
The lint target never passed the integration or stripe_integration tags, so
every file under test/ was compiled out and unchecked. Add a pass for each
and move the integration package comment onto the package's one non-test
file, which is where staticcheck looks for it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WTdBxLFU5TpwmqVdVsN1wq
2026-09-11 17:05:19 -05:00

62 lines
1.6 KiB
Go

//go:build integration
package integration
import (
"fmt"
"testing"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/random"
"atcr.io/internal/testharness"
// distribution registers its drivers and auth providers via init() side
// effects; cmd/appview pulls these in too. Without these blank imports
// distribution panics with "StorageDriver not registered: inmemory".
_ "github.com/distribution/distribution/v3/registry/auth/token"
_ "github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
)
func TestPushPullHappyPath(t *testing.T) {
h := testharness.New(t)
alice := h.AddSailor("alice.test")
img, err := random.Image(1<<20, 3) // 1MB, 3 layers
if err != nil {
t.Fatalf("build random image: %v", err)
}
pushedDigest, err := img.Digest()
if err != nil {
t.Fatalf("pushed digest: %v", err)
}
for _, c := range Clients {
t.Run(c.Name(), func(t *testing.T) {
// Per-client repo path so concurrent / matrixed runs don't
// collide on shared blob digests at the registry.
ref, err := name.ParseReference(
fmt.Sprintf("%s/%s/repo-%s:tag", h.AppViewHostPort(), alice.Handle(), c.Name()),
name.Insecure,
)
if err != nil {
t.Fatalf("parse ref: %v", err)
}
creds := h.RegistryCreds(alice)
if err := c.Push(t.Context(), t, ref.String(), img, creds); err != nil {
t.Fatalf("push: %v", err)
}
pulledDigest, err := c.Pull(t.Context(), ref.String(), creds)
if err != nil {
t.Fatalf("pull: %v", err)
}
if pushedDigest != pulledDigest {
t.Fatalf("digest mismatch: pushed=%s pulled=%s", pushedDigest, pulledDigest)
}
})
}
}