MCPcopy Create free account
hub / github.com/Mnexa-AI/e2a / TestWriteOutboxRow_NilsEmptyOptionals

Function TestWriteOutboxRow_NilsEmptyOptionals

internal/webhookpub/outbox_test.go:214–246  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestWriteOutboxRow_NilsEmptyOptionals(t *testing.T) {
215 // AgentID/ConversationID/MessageID are passed as *string; empty
216 // strings should become nil, not "".
217 fe := &fakeExec{}
218 e := Event{
219 ID: "evt_abc",
220 Type: EventEmailReceived,
221 UserID: "u_42",
222 // AgentID, ConversationID, MessageID all empty
223 }
224 if err := writeOutboxRow(context.Background(), fe, e); err != nil {
225 t.Fatalf("writeOutboxRow err: %v", err)
226 }
227 if len(fe.args) < 1 || len(fe.args[0]) < 7 {
228 t.Fatalf("not enough args captured: %v", fe.args)
229 }
230 // args order in writeOutboxRow: id, userID, type, envelopeJSON, agentID, conversationID, messageID
231 // indices 0, 1, 2, 3, 4, 5, 6
232 // args[4..6] are *string for agent_id, conversation_id, message_id.
233 // Empty event fields should become typed-nil pointers so pgx
234 // passes SQL NULL to the column. Use reflect to dereference the
235 // interface and check the underlying pointer is nil.
236 for i, name := range []string{"agent_id", "conversation_id", "message_id"} {
237 v := reflect.ValueOf(fe.args[0][4+i])
238 if v.Kind() != reflect.Ptr {
239 t.Errorf("%s arg should be *string, got %s", name, v.Kind())
240 continue
241 }
242 if !v.IsNil() {
243 t.Errorf("expected %s = nil, got %v", name, fe.args[0][4+i])
244 }
245 }
246}
247
248func TestOutbox_PublishTx_FlagOffNoOp(t *testing.T) {
249 // PublishTx must be a complete no-op when the flag is disabled.

Callers

nothing calls this directly

Calls 2

writeOutboxRowFunction · 0.85
KindMethod · 0.45

Tested by

no test coverage detected