@@ -8,6 +8,7 @@ import * as Effect from "effect/Effect";
88import * as Fiber from "effect/Fiber" ;
99import * as SqlClient from "effect/sql/SqlClient" ;
1010import * as TestClock from "effect/testing/TestClock" ;
11+ import * as Tracer from "effect/Tracer" ;
1112
1213import * as HookInboxStore from "./HookInboxStore.ts" ;
1314
@@ -44,6 +45,35 @@ const withInbox = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
4445 ) ;
4546
4647describe ( "HookInboxStore" , ( ) => {
48+ it . effect . each ( [ "delivered" , "unreachable" ] as const ) (
49+ "keeps %s delivery results on the operation span" ,
50+ ( outcome ) =>
51+ withInbox (
52+ Effect . gen ( function * ( ) {
53+ yield * HookInboxStore . hold ( yield * hook ( "traced" ) , BASE_URL ) ;
54+ const spans : Array < Tracer . NativeSpan > = [ ] ;
55+ const tracer = Tracer . make ( {
56+ span ( options ) {
57+ const span = new Tracer . NativeSpan ( options ) ;
58+ spans . push ( span ) ;
59+ return span ;
60+ } ,
61+ } ) ;
62+ yield * HookInboxStore . deliverDue ( deliverer ( ( ) => outcome ) . send ) . pipe (
63+ Effect . withTracer ( tracer ) ,
64+ ) ;
65+ const run = spans . find ( ( span ) => span . name === "HookInboxStore.deliverDue" ) ;
66+ expect ( run ?. attributes . get ( "relay.inbox.run_result" ) ) . toBe (
67+ outcome === "delivered" ? "drained" : "unreachable" ,
68+ ) ;
69+ expect ( run ?. attributes . get ( "relay.inbox.sent" ) ) . toBe ( 1 ) ;
70+ expect ( run ?. attributes . get ( "relay.inbox.delivered" ) ) . toBe (
71+ outcome === "delivered" ? 1 : 0 ,
72+ ) ;
73+ } ) ,
74+ ) ,
75+ ) ;
76+
4777 it . effect . each ( [ "delivered" , "busy" , "unreachable" ] as const ) (
4878 "stops a prefetched batch cleared during a %s send" ,
4979 ( outcome ) =>
0 commit comments