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

Function TestGetMonitorByID_NotFound

database/balance_test.go:1255–1280  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1253}
1254
1255func TestGetMonitorByID_NotFound(t *testing.T) {
1256 db, mock, err := sqlmock.New()
1257 assert.NoError(t, err)
1258 defer func() { _ = db.Close() }()
1259
1260 ds := Datasource{Conn: db}
1261
1262 query := `
1263 SELECT monitor_id, balance_id, field, operator, value, precision, precise_value, description, call_back_url, created_at
1264 FROM ledgerforge.balance_monitors WHERE monitor_id = $1
1265 `
1266
1267 mock.ExpectQuery(regexp.QuoteMeta(query)).
1268 WithArgs("mon_nonexistent").
1269 WillReturnError(sql.ErrNoRows)
1270
1271 monitor, err := ds.GetMonitorByID("mon_nonexistent")
1272 assert.Error(t, err)
1273 assert.Nil(t, monitor)
1274 apiErr, ok := err.(apierror.APIError)
1275 assert.True(t, ok)
1276 assert.Equal(t, apierror.ErrNotFound, apiErr.Code)
1277
1278 err = mock.ExpectationsWereMet()
1279 assert.NoError(t, err)
1280}
1281
1282func TestGetAllMonitors_Success(t *testing.T) {
1283 db, mock, err := sqlmock.New()

Callers

nothing calls this directly

Calls 3

GetMonitorByIDMethod · 0.95
CloseMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected