Writer[F, C, S, A any] marshals a body, reads and sets kind, scope, id, subject, at, since and observer by their contract names; the interfaces FindingBody, ClearedBody, StatedBody, AskedBody and the constructors go. A body whose wire form lacks a field the contract names is refused when the writer is made. views.CheckFinding(any) judges the wire form. WriterFindings takes only the writer. Builds: design 47 G §686, §640, §687, §689, A-3 (.work/47-G/dev2-ledger.md) Claude-Session: https://claude.ai/code/session_01JG73KEq4zoDfM9WtYpcQgZ
67 lines
2.0 KiB
Go
67 lines
2.0 KiB
Go
package views_test
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.novox.be/novox/mesh-sdk/go/views"
|
|
)
|
|
|
|
// Plain structs shaped as the types the seat generator emits for the seat `mesh-conditions` (design 47 G A-3): the writer
|
|
// is generic over them and works on their wire form, so the test brings the same shape, field for field.
|
|
|
|
type testSubject struct {
|
|
Also []string `json:"also,omitempty"`
|
|
ID string `json:"id"`
|
|
Machine string `json:"machine,omitempty"`
|
|
Scope string `json:"scope"`
|
|
}
|
|
|
|
type testFinding struct {
|
|
At time.Time `json:"at"`
|
|
Explanation string `json:"explanation,omitempty"`
|
|
Headline string `json:"headline,omitempty"`
|
|
ID string `json:"id"`
|
|
Kind string `json:"kind"`
|
|
Observer string `json:"observer"`
|
|
Owner string `json:"owner,omitempty"`
|
|
Run string `json:"run,omitempty"`
|
|
Scope string `json:"scope"`
|
|
Severity string `json:"severity"`
|
|
Since time.Time `json:"since"`
|
|
Source string `json:"source"`
|
|
Subject testSubject `json:"subject"`
|
|
Summary string `json:"summary"`
|
|
WaitingOn string `json:"waiting-on,omitempty"`
|
|
}
|
|
|
|
type testCleared struct {
|
|
At time.Time `json:"at"`
|
|
ID string `json:"id"`
|
|
Kind string `json:"kind"`
|
|
Scope string `json:"scope"`
|
|
Why string `json:"why"`
|
|
}
|
|
|
|
type testPending struct {
|
|
Bound string `json:"bound"`
|
|
Key string `json:"key"`
|
|
Since time.Time `json:"since"`
|
|
}
|
|
|
|
type testStated struct {
|
|
Asked string `json:"asked,omitempty"`
|
|
At time.Time `json:"at"`
|
|
Findings []testFinding `json:"findings"`
|
|
Kinds []string `json:"kinds,omitempty"`
|
|
Pending []testPending `json:"pending"`
|
|
}
|
|
|
|
type testAsked struct {
|
|
Ask string `json:"ask"`
|
|
Module string `json:"module,omitempty"`
|
|
}
|
|
|
|
type testWriter = views.Writer[testFinding, testCleared, testStated, testAsked]
|
|
type testConfig = views.WriterConfig[testFinding, testCleared, testStated, testAsked]
|
|
type testObserved = views.Observed[testFinding]
|