(t *testing.T)
| 877 | } |
| 878 | |
| 879 | func TestCheckCondition_Extended(t *testing.T) { |
| 880 | balance := &Balance{ |
| 881 | Balance: big.NewInt(10000), |
| 882 | CreditBalance: big.NewInt(15000), |
| 883 | DebitBalance: big.NewInt(5000), |
| 884 | } |
| 885 | |
| 886 | t.Run("Balance greater than - using BalanceMonitor", func(t *testing.T) { |
| 887 | monitor := &BalanceMonitor{ |
| 888 | Condition: AlertCondition{ |
| 889 | Field: "balance", |
| 890 | Operator: ">", |
| 891 | Value: 50, |
| 892 | Precision: 100, |
| 893 | PreciseValue: big.NewInt(5000), |
| 894 | }, |
| 895 | } |
| 896 | result := monitor.CheckCondition(balance) |
| 897 | assert.True(t, result) |
| 898 | }) |
| 899 | |
| 900 | t.Run("Credit balance less than", func(t *testing.T) { |
| 901 | monitor := &BalanceMonitor{ |
| 902 | Condition: AlertCondition{ |
| 903 | Field: "credit_balance", |
| 904 | Operator: "<", |
| 905 | Value: 200, |
| 906 | Precision: 100, |
| 907 | PreciseValue: big.NewInt(20000), |
| 908 | }, |
| 909 | } |
| 910 | result := monitor.CheckCondition(balance) |
| 911 | assert.True(t, result) |
| 912 | }) |
| 913 | |
| 914 | t.Run("Debit balance equals", func(t *testing.T) { |
| 915 | monitor := &BalanceMonitor{ |
| 916 | Condition: AlertCondition{ |
| 917 | Field: "debit_balance", |
| 918 | Operator: "==", |
| 919 | Value: 50, |
| 920 | Precision: 100, |
| 921 | PreciseValue: big.NewInt(5000), |
| 922 | }, |
| 923 | } |
| 924 | result := monitor.CheckCondition(balance) |
| 925 | assert.True(t, result) |
| 926 | }) |
| 927 | |
| 928 | t.Run("Unknown field returns false", func(t *testing.T) { |
| 929 | monitor := &BalanceMonitor{ |
| 930 | Condition: AlertCondition{ |
| 931 | Field: "unknown_field", |
| 932 | Operator: ">", |
| 933 | Value: 0, |
| 934 | PreciseValue: big.NewInt(0), |
| 935 | }, |
| 936 | } |
nothing calls this directly
no test coverage detected