Add runtime prompt values to module outputs
This commit is contained in:
@@ -13,7 +13,12 @@ type testStanza struct {
|
||||
|
||||
func TestSnapshotPreservesOutputOrderAndJSON(t *testing.T) {
|
||||
snapshot, err := NewSnapshot([]Output{
|
||||
{ID: Metadata, StanzaName: "metadata", Value: testStanza{Message: "first", Count: 1}},
|
||||
{
|
||||
ID: Metadata,
|
||||
StanzaName: "metadata",
|
||||
Value: testStanza{Message: "first", Count: 1},
|
||||
PromptValue: testStanza{Message: "prompt-only", Count: 10},
|
||||
},
|
||||
{ID: AlertDigest, StanzaName: "alert_digest", Value: testStanza{Message: "second", Count: 2}},
|
||||
})
|
||||
if err != nil {
|
||||
@@ -35,6 +40,26 @@ func TestSnapshotPreservesOutputOrderAndJSON(t *testing.T) {
|
||||
if got != want {
|
||||
t.Fatalf("json = %s, want %s", got, want)
|
||||
}
|
||||
if strings.Contains(got, "PromptValue") || strings.Contains(got, "promptValue") || strings.Contains(got, "prompt-only") {
|
||||
t.Fatalf("json includes runtime-only prompt value: %s", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutputDataPackageValue(t *testing.T) {
|
||||
output := Output{
|
||||
ID: Metadata,
|
||||
StanzaName: "metadata",
|
||||
Value: testStanza{Message: "rich", Count: 1},
|
||||
PromptValue: testStanza{Message: "prompt", Count: 2},
|
||||
}
|
||||
if got := output.DataPackageValue(); got != output.PromptValue {
|
||||
t.Fatalf("DataPackageValue() = %#v, want prompt value", got)
|
||||
}
|
||||
|
||||
output.PromptValue = nil
|
||||
if got := output.DataPackageValue(); got != output.Value {
|
||||
t.Fatalf("DataPackageValue() = %#v, want rich value fallback", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSnapshotRejectsDuplicateOutputs(t *testing.T) {
|
||||
@@ -57,7 +82,12 @@ func TestSnapshotRejectsDuplicateOutputs(t *testing.T) {
|
||||
|
||||
func TestStanzaValueDecodesTypedOutput(t *testing.T) {
|
||||
snapshot, err := NewSnapshot([]Output{
|
||||
{ID: Metadata, StanzaName: "metadata", Value: testStanza{Message: "available", Count: 3}},
|
||||
{
|
||||
ID: Metadata,
|
||||
StanzaName: "metadata",
|
||||
Value: testStanza{Message: "available", Count: 3},
|
||||
PromptValue: testStanza{Message: "prompt-only", Count: 99},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("NewSnapshot() error = %v", err)
|
||||
|
||||
Reference in New Issue
Block a user