@@ -80,3 +80,36 @@ func TestPaginationPerPage(t *testing.T) {
80
80
p := env .validatePerPage (nil )
81
81
assert .Equal (t , defaultPerPage , p )
82
82
}
83
+
84
+ func TestValidateUnconfirmedTxsPerPage (t * testing.T ) {
85
+ env := & Environment {}
86
+
87
+ t .Run ("should return default if input is nil" , func (t * testing.T ) {
88
+ got := env .validateUnconfirmedTxsPerPage (nil )
89
+ assert .Equal (t , defaultPerPage , got )
90
+ })
91
+
92
+ type testCase struct {
93
+ input int
94
+ want int
95
+ }
96
+
97
+ cases := []testCase {
98
+ {- 2 , defaultPerPage },
99
+ {- 1 , - 1 }, // -1 is now a valid input and means query all unconfirmed txs
100
+ {0 , defaultPerPage },
101
+ {1 , 1 },
102
+ {10 , 10 },
103
+ {30 , 30 },
104
+ {defaultPerPage , defaultPerPage },
105
+ {maxPerPage - 1 , maxPerPage - 1 },
106
+ {maxPerPage , maxPerPage },
107
+ {maxPerPage + 1 , maxPerPage },
108
+ }
109
+ for _ , c := range cases {
110
+ t .Run (fmt .Sprintf ("should return %d if input is %d" , c .want , c .input ), func (t * testing.T ) {
111
+ got := env .validateUnconfirmedTxsPerPage (& c .input )
112
+ assert .Equal (t , c .want , got )
113
+ })
114
+ }
115
+ }
0 commit comments