Make production registration asset-free and verify direct deterministic execution
This commit is contained in:
@@ -2,6 +2,7 @@ package appendorder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@@ -23,3 +24,27 @@ func TestTypedMergerCombinesValuesInFrameworkOrder(t *testing.T) {
|
||||
t.Fatalf("result=%#v err=%v", result, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTypedMergerPropagatesApplicationErrorWithoutRetry(t *testing.T) {
|
||||
failure := errors.New("cannot combine these values")
|
||||
calls := 0
|
||||
merger, err := NewTyped(func([]string) (string, error) {
|
||||
calls++
|
||||
return "", failure
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err := merger.Merge(context.Background(), contracts.TypedMergeRequest[string]{
|
||||
Operation: contracts.ProducerOperation[string]{
|
||||
Controls: contracts.ProducerControls{Mode: contracts.ModePermissive, MaxAdditionalTurns: 3},
|
||||
Assess: func(context.Context, string) (contracts.CandidateAssessment, error) {
|
||||
t.Fatal("merger invoked assessment instead of returning its operation error")
|
||||
return contracts.CandidateAssessment{}, nil
|
||||
},
|
||||
},
|
||||
})
|
||||
if !errors.Is(err, failure) || calls != 1 || result.Outcome.Disposition != "" || result.Fallback != nil {
|
||||
t.Fatalf("Merge() = %#v, %v; combine calls = %d", result, err, calls)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user