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

Function TestGetMatchingRules_Success

database/reconciliation_test.go:580–599  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

578}
579
580func TestGetMatchingRules_Success(t *testing.T) {
581 db, mock, err := sqlmock.New()
582 assert.NoError(t, err)
583 defer func() { _ = db.Close() }()
584
585 ds := Datasource{Conn: db}
586 ctx := context.TODO()
587
588 mock.ExpectQuery("SELECT id, rule_id, created_at, updated_at, name, description, criteria FROM ledgerforge.matching_rules").
589 WillReturnRows(sqlmock.NewRows([]string{
590 "id", "rule_id", "created_at", "updated_at", "name", "description", "criteria",
591 }).
592 AddRow(1, "rule1", time.Now(), time.Now(), "Rule 1", "Description 1", []byte(`[]`)).
593 AddRow(2, "rule2", time.Now(), time.Now(), "Rule 2", "Description 2", []byte(`[]`)))
594
595 rules, err := ds.GetMatchingRules(ctx)
596 assert.NoError(t, err)
597 assert.Len(t, rules, 2)
598 assert.Equal(t, "rule1", rules[0].RuleID)
599}
600
601func TestGetMatchingRules_Error(t *testing.T) {
602 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 2

GetMatchingRulesMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected