MCPcopy Create free account
hub / github.com/calebwin/pgclaw / test_context_function

Function test_context_function

src/lib.rs:744–775  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

742
743 #[pg_test]
744 fn test_context_function() {
745 Spi::run(
746 "INSERT INTO claw.agents (id, soul) VALUES ('ctx-bot', 'Test.')",
747 )
748 .expect("insert agent failed");
749 Spi::run(
750 "INSERT INTO claw.bindings (channel, agent_id) VALUES ('ctx-ch', 'ctx-bot')",
751 )
752 .expect("insert binding failed");
753
754 let session_id = Spi::get_one::<String>(
755 "SELECT claw.route('ctx-ch', '*', 'user1', NULL, 'First message')::text",
756 )
757 .expect("SPI failed")
758 .expect("NULL result");
759
760 Spi::run(&format!(
761 "SELECT claw.respond('{}', 'First response')",
762 session_id
763 ))
764 .expect("respond failed");
765
766 let ctx = Spi::get_one::<String>(&format!(
767 "SELECT claw.context('{}')::text",
768 session_id
769 ))
770 .expect("SPI failed")
771 .expect("NULL result");
772
773 assert!(ctx.contains("First message"), "Context should contain user message");
774 assert!(ctx.contains("First response"), "Context should contain assistant response");
775 }
776
777 // ── Claw type in table columns ────────────────────────────────────
778

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected