(t *testing.T)
| 462 | } |
| 463 | |
| 464 | func TestDeleteMonitor(t *testing.T) { |
| 465 | datasource, mock, err := newTestDataSource() |
| 466 | if err != nil { |
| 467 | t.Fatalf("Error creating test data source: %s", err) |
| 468 | } |
| 469 | |
| 470 | d, err := NewLedgerForge(datasource) |
| 471 | if err != nil { |
| 472 | t.Fatalf("Error creating LedgerForge instance: %s", err) |
| 473 | } |
| 474 | monitorID := "test-monitor" |
| 475 | balanceID := "test-balance" |
| 476 | |
| 477 | rows := sqlmock.NewRows([]string{"monitor_id", "balance_id", "field", "operator", "value", "precision", "precise_value", "description", "call_back_url", "created_at"}). |
| 478 | AddRow(monitorID, balanceID, "balance", ">", 100.0, 100.0, int64(10000), "test", "http://test.com", time.Now()) |
| 479 | mock.ExpectQuery("SELECT monitor_id, balance_id, field, operator, value, precision, precise_value, description, call_back_url, created_at FROM ledgerforge.balance_monitors WHERE monitor_id ="). |
| 480 | WithArgs(monitorID).WillReturnRows(rows) |
| 481 | |
| 482 | mock.ExpectExec("DELETE FROM ledgerforge.balance_monitors WHERE monitor_id =").WithArgs(monitorID).WillReturnResult(sqlmock.NewResult(1, 1)) |
| 483 | |
| 484 | err = d.DeleteMonitor(context.Background(), monitorID) |
| 485 | |
| 486 | assert.NoError(t, err) |
| 487 | |
| 488 | if err := mock.ExpectationsWereMet(); err != nil { |
| 489 | t.Errorf("there were unfulfilled expectations: %s", err) |
| 490 | } |
| 491 | } |
| 492 | |
| 493 | func TestGetBalanceByIndicator(t *testing.T) { |
| 494 | // Skip in short mode |
nothing calls this directly
no test coverage detected