The versions, bounds, reserved, publish-queue, acted, toolchains-heard and instances buckets were constants naming mesh-delivery-builder; ownBucketsOf takes them from the module the credential names. Builds: design 47 G A-296, §428 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
47 lines
1.4 KiB
Go
47 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/nats-io/nats.go/jetstream"
|
|
)
|
|
|
|
type saysOf map[string]string
|
|
|
|
func (s saysOf) Put(_ context.Context, key string, value []byte) (uint64, error) {
|
|
s[key] = string(value)
|
|
return 1, nil
|
|
}
|
|
|
|
func (s saysOf) Delete(_ context.Context, key string, _ ...jetstream.KVDeleteOpt) error {
|
|
delete(s, key)
|
|
return nil
|
|
}
|
|
|
|
// 1886/AC5: a builder says, under its node, that it writes references only once every build module it calls answered
|
|
// one; stopped, it says nothing any more.
|
|
func TestTheBuilderSaysItWritesReferencesOnceEveryBuildModuleAnsweredOne(t *testing.T) {
|
|
s := saysOf{}
|
|
say := newSayer(t.Context(), s, "mesh-delivery-builder_instances", "shanks", func() []string { return []string{"mesh-build-go", "mesh-build-node", "mesh-build-image"} }, t.Logf)
|
|
say.Answered("mesh-build-go")
|
|
say.Answered("mesh-build-node")
|
|
if v, ok := s["shanks"]; ok {
|
|
t.Fatalf("said before the image build module answered a reference: %q", v)
|
|
}
|
|
say.Answered("mesh-build-image")
|
|
var v struct {
|
|
Writes []string `json:"writes"`
|
|
}
|
|
if err := json.Unmarshal([]byte(s["shanks"]), &v); err != nil || len(v.Writes) != 1 || v.Writes[0] != "references" {
|
|
t.Fatalf("the builder's say: %q %v", s["shanks"], err)
|
|
}
|
|
if err := say.unsay(t.Context()); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if _, ok := s["shanks"]; ok {
|
|
t.Fatalf("the stopped builder still says: %v", s)
|
|
}
|
|
}
|