34 lines
892 B
Go
34 lines
892 B
Go
package provider
|
|
|
|
import (
|
|
"errors"
|
|
"testing"
|
|
|
|
"orchestra/internal/domain"
|
|
)
|
|
|
|
type appendThenReflectSink struct{ appended bool }
|
|
|
|
func (s *appendThenReflectSink) Append(domain.Event) error { s.appended = true; return nil }
|
|
|
|
type failingReflector struct{}
|
|
|
|
func (failingReflector) ReflectTask(domain.Task, domain.Event) error {
|
|
return errors.New("provider unavailable")
|
|
}
|
|
|
|
type taskLookup struct{}
|
|
|
|
func (taskLookup) Task(string) (domain.Task, bool) { return domain.Task{ID: "task"}, true }
|
|
|
|
func TestReflectingSinkAppendsBeforeReflection(t *testing.T) {
|
|
sink := &appendThenReflectSink{}
|
|
err := (ReflectingSink{Sink: sink, Tasks: taskLookup{}, Reflector: failingReflector{}}).Append(domain.Event{TaskID: "task", Type: "TaskCompleted"})
|
|
if !sink.appended {
|
|
t.Fatal("reflection was attempted before canonical append")
|
|
}
|
|
if err == nil {
|
|
t.Fatal("reflection failure was hidden")
|
|
}
|
|
}
|