Skip to content
quarry Artifact [eab10db129]
Login

Artifact [eab10db129]

Artifact eab10db129c73d3a6046c8ef3cd6f50341d45452497d3204f3bff89fe0132cc6:


package api

import (
	"context"
	"errors"
	"testing"

	"craftdesign.group/quarry/internal/ops"
)

// The gate the body-named ops ask (team moves, offers, agent grants):
// a taken-down repository refuses, and one the caller cannot read stays
// the op's own not-found rather than a sentence about a takedown.
func TestRefuseHeldRepo(t *testing.T) {
	readable := true
	d := Deps{
		Held:    func(context.Context, string) string { return "unavailable for legal reasons" },
		CanRead: func(context.Context, string) bool { return readable },
	}
	if err := d.refuseHeldRepo(context.Background(), "pub"); !errors.Is(err, ops.ErrForbidden) {
		t.Errorf("FAIL: a taken-down repository: %v", err)
	}
	readable = false
	if err := d.refuseHeldRepo(context.Background(), "secret"); err != nil {
		t.Errorf("FAIL: an unreadable repository was named as taken down: %v", err)
	}
	if err := (Deps{}).refuseHeldRepo(context.Background(), "pub"); err != nil {
		t.Errorf("FAIL: a forge that takes nothing down refused: %v", err)
	}
}