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

Function TestGetMatchingRule_Success

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

Source from the content-addressed store, hash-verified

616}
617
618func TestGetMatchingRule_Success(t *testing.T) {
619 db, mock, err := sqlmock.New()
620 assert.NoError(t, err)
621 defer func() { _ = db.Close() }()
622
623 ds := Datasource{Conn: db}
624 ctx := context.TODO()
625
626 mock.ExpectQuery("SELECT id, rule_id, created_at, updated_at, name, description, criteria FROM ledgerforge.matching_rules WHERE rule_id").
627 WithArgs("rule1").
628 WillReturnRows(sqlmock.NewRows([]string{
629 "id", "rule_id", "created_at", "updated_at", "name", "description", "criteria",
630 }).AddRow(1, "rule1", time.Now(), time.Now(), "Rule 1", "Description 1", []byte(`[]`)))
631
632 rule, err := ds.GetMatchingRule(ctx, "rule1")
633 assert.NoError(t, err)
634 assert.Equal(t, "rule1", rule.RuleID)
635}
636
637func TestGetMatchingRule_NotFound(t *testing.T) {
638 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 2

GetMatchingRuleMethod · 0.95
CloseMethod · 0.45

Tested by

no test coverage detected