(t *testing.T)
| 267 | } |
| 268 | |
| 269 | func TestResultLine(t *testing.T) { |
| 270 | timestamp := "2020-04-01T15:00:00.999999999+09:00" |
| 271 | ts, err := time.Parse(time.RFC3339Nano, timestamp) |
| 272 | if err != nil { |
| 273 | t.Fatalf("unexpected time.Parse error: %v", err) |
| 274 | } |
| 275 | |
| 276 | for _, tt := range []struct { |
| 277 | desc string |
| 278 | result *Result |
| 279 | verbose bool |
| 280 | want string |
| 281 | }{ |
| 282 | { |
| 283 | desc: "mutation in normal mode", |
| 284 | result: &Result{ |
| 285 | AffectedRows: 3, |
| 286 | IsMutation: true, |
| 287 | Stats: QueryStats{ |
| 288 | ElapsedTime: "10 msec", |
| 289 | }, |
| 290 | }, |
| 291 | verbose: false, |
| 292 | want: "Query OK, 3 rows affected (10 msec)\n", |
| 293 | }, |
| 294 | { |
| 295 | desc: "mutation in verbose mode (timestamp exist)", |
| 296 | result: &Result{ |
| 297 | AffectedRows: 3, |
| 298 | IsMutation: true, |
| 299 | Stats: QueryStats{ |
| 300 | ElapsedTime: "10 msec", |
| 301 | }, |
| 302 | Timestamp: ts, |
| 303 | }, |
| 304 | verbose: true, |
| 305 | want: fmt.Sprintf("Query OK, 3 rows affected (10 msec)\ntimestamp: %s\n", timestamp), |
| 306 | }, |
| 307 | { |
| 308 | desc: "mutation in verbose mode (both of timestamp and mutation count exist)", |
| 309 | result: &Result{ |
| 310 | AffectedRows: 3, |
| 311 | IsMutation: true, |
| 312 | Stats: QueryStats{ |
| 313 | ElapsedTime: "10 msec", |
| 314 | }, |
| 315 | CommitStats: &sppb.CommitResponse_CommitStats{MutationCount: 6}, |
| 316 | Timestamp: ts, |
| 317 | }, |
| 318 | verbose: true, |
| 319 | want: fmt.Sprintf("Query OK, 3 rows affected (10 msec)\ntimestamp: %s\nmutation_count: 6\n", timestamp), |
| 320 | }, |
| 321 | { |
| 322 | desc: "mutation in verbose mode (timestamp not exist)", |
| 323 | result: &Result{ |
| 324 | AffectedRows: 0, |
| 325 | IsMutation: true, |
| 326 | Stats: QueryStats{ |
nothing calls this directly
no test coverage detected