BG9, BN9, BI3: the build seats' steps with drop writes the hand-act log first
A drop of a kept detected-steps key records the act with the caller the bus proved, then deletes the key; a log that refuses deletes nothing and is answered error; a drop without why is refused; fetch is asked unless drop. Builds: design 47 G §463, §480 Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -2,9 +2,11 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -51,3 +53,27 @@ func TestTheStepsVerbIsServedAndRefusesAnAskWithoutAnArtifact(t *testing.T) {
|
||||
t.Error("an ask with no artifact was answered")
|
||||
}
|
||||
}
|
||||
|
||||
// Design 47 G §463, §480 (BN9): steps with drop writes the hand-act log first, then deletes the key; a log that
|
||||
// refuses deletes nothing; a drop without why is refused.
|
||||
func TestTheStepsDropWritesTheHandActLogFirst(t *testing.T) {
|
||||
var order []string
|
||||
m := &Module{
|
||||
ForgetDetected: func(key string) error { order = append(order, "delete "+key); return nil },
|
||||
RecordAct: func(what, why string) error { order = append(order, "log "+why); return nil },
|
||||
}
|
||||
args := map[string]any{"module": "mod", "artifact": "mod:web", "drop": true, "why": "stale"}
|
||||
got, err := m.dropDetected(args, "shanks.person")
|
||||
if a, _ := got.(StepsAnswer); err != nil || a.Dropped != "mod:web" || !reflect.DeepEqual(order, []string{"log stale", "delete mod.web"}) {
|
||||
t.Fatalf("drop = %+v, %v, order %v", got, err, order)
|
||||
}
|
||||
if _, err := m.dropDetected(map[string]any{"module": "mod", "artifact": "mod:web", "drop": true}, "shanks.person"); err == nil {
|
||||
t.Error("a drop without why was taken")
|
||||
}
|
||||
order = nil
|
||||
m.RecordAct = func(string, string) error { return errors.New("log down") }
|
||||
got, err = m.dropDetected(args, "shanks.person")
|
||||
if a, _ := got.(StepsAnswer); err != nil || !strings.Contains(a.Error, "hand-act log") || len(order) != 0 {
|
||||
t.Fatalf("a refusing log: %+v, %v, order %v", got, err, order)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user