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

Function TestCheckCondition_Extended

model/model_test.go:879–940  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

877}
878
879func 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 }

Callers

nothing calls this directly

Calls 1

CheckConditionMethod · 0.95

Tested by

no test coverage detected