Files
mesh-delivery/modules/mesh-delivery-sdk/steprun/outputs_test.go
T
jschoubben 7125a9f92f C1c-2a: the step runner says a run's answer in step-ended, inline or as an object, and serves it
The puller's end of a run carries the run's program's last line of standard output as `output` up to StepEndedInlineMost, else keeps
it with KeepOutput and names the object in `output-object`; a program that exits other than 0 ends failed. OutputTool serves the
seat's verb `output` from the kept object, as the whole file the tool runner sends in chunks; OutputsStore names the store.

Builds: design 47 G A-254, A-257, §602

Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
2026-11-12 09:37:51 +01:00

43 lines
1.2 KiB
Go

package steprun
import (
"errors"
"testing"
"git.novox.be/novox/mesh-sdk/go/buscalls"
)
type fakeOutputs struct{ m map[string][]byte }
func (f fakeOutputs) Put(name string, data []byte, _ string) (buscalls.ObjectInfo, error) {
f.m[name] = data
return buscalls.ObjectInfo{}, nil
}
func (f fakeOutputs) Get(name string) (buscalls.ObjectData, error) {
d, ok := f.m[name]
if !ok {
return buscalls.ObjectData{}, errors.New("object not found")
}
return buscalls.ObjectData{Data: d}, nil
}
// Design 47 G A-254: what a holder keeps through KeepOutputIn it reads again through ReadOutputFrom; with no store both refuse by name.
func TestOutputsKeptAreRead(t *testing.T) {
st := fakeOutputs{m: map[string][]byte{}}
if err := KeepOutputIn(st)("output.a1", []byte("x")); err != nil {
t.Fatal(err)
}
if got, err := ReadOutputFrom(st)("output.a1"); err != nil || string(got) != "x" {
t.Fatalf("read %q, %v", got, err)
}
if _, err := ReadOutputFrom(st)("output.none"); err == nil {
t.Fatal("an absent answer was read")
}
if KeepOutputIn(nil)("o", nil) == nil {
t.Fatal("no store kept an answer")
}
if _, err := ReadOutputFrom(nil)("o"); err == nil {
t.Fatal("no store read an answer")
}
}