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

Function TestUpdateMatchingRule

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

Source from the content-addressed store, hash-verified

120}
121
122func TestUpdateMatchingRule(t *testing.T) {
123 router, _, err := setupRouter(t)
124 if err != nil {
125 t.Fatalf("Failed to setup router: %v", err)
126 }
127
128 t.Run("Missing rule ID", func(t *testing.T) {
129 payload := struct {
130 Name string `json:"name"`
131 Description string `json:"description"`
132 }{
133 Name: "Updated Rule",
134 Description: "Updated description",
135 }
136 payloadBytes, _ := request.ToJsonReq(&payload)
137 req := httptest.NewRequest("PUT", "/reconciliation/matching-rules/", payloadBytes)
138 req.Header.Set("Content-Type", "application/json")
139 resp := httptest.NewRecorder()
140 router.ServeHTTP(resp, req)
141 assert.Equal(t, http.StatusNotFound, resp.Code)
142 })
143
144 t.Run("Invalid JSON", func(t *testing.T) {
145 req := httptest.NewRequest("PUT", "/reconciliation/matching-rules/mr_test", bytes.NewReader([]byte("invalid json")))
146 req.Header.Set("Content-Type", "application/json")
147 resp := httptest.NewRecorder()
148 router.ServeHTTP(resp, req)
149 assert.Equal(t, http.StatusBadRequest, resp.Code)
150 })
151}
152
153func TestDeleteMatchingRule(t *testing.T) {
154 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