(t *testing.T)
| 121 | } |
| 122 | |
| 123 | func Test_addPerPage(t *testing.T) { |
| 124 | type args struct { |
| 125 | p string |
| 126 | perPage int |
| 127 | params map[string]interface{} |
| 128 | } |
| 129 | tests := []struct { |
| 130 | name string |
| 131 | args args |
| 132 | want string |
| 133 | }{ |
| 134 | { |
| 135 | name: "adds per_page", |
| 136 | args: args{ |
| 137 | p: "items", |
| 138 | perPage: 13, |
| 139 | params: nil, |
| 140 | }, |
| 141 | want: "items?per_page=13", |
| 142 | }, |
| 143 | { |
| 144 | name: "avoids adding per_page if already in params", |
| 145 | args: args{ |
| 146 | p: "items", |
| 147 | perPage: 13, |
| 148 | params: map[string]interface{}{ |
| 149 | "state": "open", |
| 150 | "per_page": 99, |
| 151 | }, |
| 152 | }, |
| 153 | want: "items", |
| 154 | }, |
| 155 | { |
| 156 | name: "avoids adding per_page if already in query", |
| 157 | args: args{ |
| 158 | p: "items?per_page=6&state=open", |
| 159 | perPage: 13, |
| 160 | params: nil, |
| 161 | }, |
| 162 | want: "items?per_page=6&state=open", |
| 163 | }, |
| 164 | } |
| 165 | for _, tt := range tests { |
| 166 | t.Run(tt.name, func(t *testing.T) { |
| 167 | if got := addPerPage(tt.args.p, tt.args.perPage, tt.args.params); got != tt.want { |
| 168 | t.Errorf("addPerPage() = %v, want %v", got, tt.want) |
| 169 | } |
| 170 | }) |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | func TestJsonArrayWriter(t *testing.T) { |
| 175 | tests := []struct { |
nothing calls this directly
no test coverage detected