MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / TestInstantReconciliation

Function TestInstantReconciliation

api/reconciliation_api_test.go:60–91  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestInstantReconciliation(t *testing.T) {
61 router, _, err := setupRouter(t)
62 if err != nil {
63 t.Fatalf("Failed to setup router: %v", err)
64 }
65
66 t.Run("Missing external transactions", func(t *testing.T) {
67 payload := struct {
68 ExternalTransactions []interface{} `json:"external_transactions"`
69 Strategy string `json:"strategy"`
70 MatchingRuleIDs []string `json:"matching_rule_ids"`
71 }{
72 ExternalTransactions: []interface{}{},
73 Strategy: "one_to_one",
74 MatchingRuleIDs: []string{"mr_test"},
75 }
76 payloadBytes, _ := request.ToJsonReq(&payload)
77 req := httptest.NewRequest("POST", "/reconciliation/start-instant", payloadBytes)
78 req.Header.Set("Content-Type", "application/json")
79 resp := httptest.NewRecorder()
80 router.ServeHTTP(resp, req)
81 assert.Equal(t, http.StatusBadRequest, resp.Code)
82 })
83
84 t.Run("Invalid JSON", func(t *testing.T) {
85 req := httptest.NewRequest("POST", "/reconciliation/start-instant", bytes.NewReader([]byte("invalid json")))
86 req.Header.Set("Content-Type", "application/json")
87 resp := httptest.NewRecorder()
88 router.ServeHTTP(resp, req)
89 assert.Equal(t, http.StatusBadRequest, resp.Code)
90 })
91}
92
93func TestGetReconciliation(t *testing.T) {
94 router, _, err := setupRouter(t)

Callers

nothing calls this directly

Calls 3

ToJsonReqFunction · 0.92
setupRouterFunction · 0.85
SetMethod · 0.65

Tested by

no test coverage detected