diff options
Diffstat (limited to 'core/operator/harness_test.go')
| -rw-r--r-- | core/operator/harness_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/operator/harness_test.go b/core/operator/harness_test.go new file mode 100644 index 0000000..383ab8c --- /dev/null +++ b/core/operator/harness_test.go | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | package operator_test | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "context" | ||
| 5 | |||
| 6 | "flux/core" | ||
| 7 | ) | ||
| 8 | |||
| 9 | type captureEmitter[T any] struct { | ||
| 10 | records []core.StreamRecord[T] | ||
| 11 | } | ||
| 12 | |||
| 13 | func (e *captureEmitter[T]) Emit(_ context.Context, record core.StreamRecord[T]) error { | ||
| 14 | e.records = append(e.records, record) | ||
| 15 | return nil | ||
| 16 | } | ||
| 17 | |||
| 18 | func (e *captureEmitter[T]) Records() []core.StreamRecord[T] { | ||
| 19 | result := make([]core.StreamRecord[T], len(e.records)) | ||
| 20 | copy(result, e.records) | ||
| 21 | |||
| 22 | return result | ||
| 23 | } | ||
