diff --git a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go index 7c26ccf2..0764a9e9 100644 --- a/modules/mesh-delivery-sdk/publishconformance/publishconformance.go +++ b/modules/mesh-delivery-sdk/publishconformance/publishconformance.go @@ -1,8 +1,10 @@ // Package publishconformance holds the cases every holder of a registry seat's `publish` is held to, so that two holders of // one contract cannot each read it their own way (novox/hq design 47 G A-73, A-417, A-490): a publish with a version, a -// digest and no parts moves nothing. A holder holding what the digest names under the name says it published; a holder that -// holds none of it refuses it as not stored, naming the digest, and says it refused. A holder's own test runs Run over its -// own test bed. +// digest and no parts is the builder's publish again. A holder holding what the digest names under the name says it published +// (it moves nothing, or, where the bytes sit in the artifact store, as distribution's A-417 takes them, tags them); a holder +// that holds none of it, or holds the version under another digest, refuses it as not stored, naming the digest, and says it +// refused (A-490, A-490a). The cases live here beside the build modules' conformance kit (design 47 G ยง680, A-490a). A +// holder's own test runs Run over its own test bed, for every seat it fills. package publishconformance import ( @@ -29,8 +31,8 @@ type Outcome struct { // Bed is one holder under test, fresh for a case. type Bed struct { - // Hold makes the holder hold Digest under Name, as the builder's reservation of Version would find it. - Hold func() + // Hold makes the holder hold the digest under Name at Version, as the builder's reservation of Version would find it. + Hold func(digest string) // Publish sends the publish of name at version with the digest and no parts, and reports what the holder did. Publish func(name, version, digest string) Outcome } @@ -40,7 +42,7 @@ func Run(t *testing.T, fresh func(t *testing.T) Bed) { t.Helper() t.Run("a publish with a digest and no parts is published when the holder holds it", func(t *testing.T) { b := fresh(t) - b.Hold() + b.Hold(Digest) o := b.Publish(Name, Version, Digest) if o.Err != nil || !o.Ended || o.Lacks != 0 || o.Event != "published" { t.Fatalf("a held digest answered %+v; want ended, no part lacked, published said", o) @@ -56,4 +58,15 @@ func Run(t *testing.T, fresh func(t *testing.T) Bed) { t.Errorf("a digest not held answered %+v; want refused said with the digest in its reason, ended, no part lacked", o) } }) + t.Run("a publish with a digest and no parts is refused as not stored, naming the digest, when the holder holds the version under another digest", func(t *testing.T) { + b := fresh(t) + b.Hold(Digest + "ff") + o := b.Publish(Name, Version, Digest) + if o.Err == nil || !strings.Contains(o.Err.Error(), "not stored") || !strings.Contains(o.Err.Error(), Digest) { + t.Fatalf("another digest held answered %+v; want the error to say not stored and name %s", o, Digest) + } + if o.Event != "refused" || !strings.Contains(o.Reason, "not stored") || !strings.Contains(o.Reason, Digest) || o.Lacks != 0 || !o.Ended { + t.Errorf("another digest held answered %+v; want refused said as not stored with the digest, ended, no part lacked", o) + } + }) }