(t *testing.T)
| 176 | } |
| 177 | |
| 178 | func TestLoggerWithCaptures(t *testing.T) { |
| 179 | type withF func(*Logger, ...Field) *Logger |
| 180 | tests := []struct { |
| 181 | name string |
| 182 | withMethods []withF |
| 183 | wantJSON []string |
| 184 | }{ |
| 185 | { |
| 186 | name: "regular with captures arguments at time of With", |
| 187 | withMethods: []withF{(*Logger).With}, |
| 188 | wantJSON: []string{ |
| 189 | `{ |
| 190 | "m": "hello 0", |
| 191 | "a0": [0], |
| 192 | "b0": [1] |
| 193 | }`, |
| 194 | `{ |
| 195 | "m": "world 0", |
| 196 | "a0": [0], |
| 197 | "c0": [2] |
| 198 | }`, |
| 199 | }, |
| 200 | }, |
| 201 | { |
| 202 | name: "lazy with captures arguments at time of With or Logging", |
| 203 | withMethods: []withF{(*Logger).WithLazy}, |
| 204 | wantJSON: []string{ |
| 205 | `{ |
| 206 | "m": "hello 0", |
| 207 | "a0": [1], |
| 208 | "b0": [1] |
| 209 | }`, |
| 210 | `{ |
| 211 | "m": "world 0", |
| 212 | "a0": [1], |
| 213 | "c0": [2] |
| 214 | }`, |
| 215 | }, |
| 216 | }, |
| 217 | { |
| 218 | name: "2x With captures arguments at time of each With", |
| 219 | withMethods: []withF{(*Logger).With, (*Logger).With}, |
| 220 | wantJSON: []string{ |
| 221 | `{ |
| 222 | "m": "hello 0", |
| 223 | "a0": [0], |
| 224 | "b0": [1] |
| 225 | }`, |
| 226 | `{ |
| 227 | "m": "world 0", |
| 228 | "a0": [0], |
| 229 | "c0": [2] |
| 230 | }`, |
| 231 | `{ |
| 232 | "m": "hello 1", |
| 233 | "a0": [0], |
| 234 | "c0": [2], |
| 235 | "a1": [10], |
nothing calls this directly
no test coverage detected