(t *testing.T)
| 328 | } |
| 329 | |
| 330 | func TestCalcMapHash(t *testing.T) { |
| 331 | testCases := []struct { |
| 332 | name string |
| 333 | input map[string]string |
| 334 | expectedResult uint32 |
| 335 | expectedError error |
| 336 | }{ |
| 337 | { |
| 338 | "nil map", |
| 339 | nil, |
| 340 | 0, |
| 341 | nil, |
| 342 | }, |
| 343 | { |
| 344 | "empty map", |
| 345 | map[string]string{}, |
| 346 | 0, |
| 347 | nil, |
| 348 | }, |
| 349 | { |
| 350 | "map with value", |
| 351 | map[string]string{"param_table_name": "clients"}, |
| 352 | 0x40802c7a, // write whatever to buf to make the data partially invalid |
| 353 | nil, |
| 354 | }, |
| 355 | { |
| 356 | "map with multiple value", |
| 357 | map[string]string{"param_table_name": "clients", "param_database": "default"}, |
| 358 | 0x6fddf04d, |
| 359 | nil, |
| 360 | }, |
| 361 | { |
| 362 | "map with exchange value", |
| 363 | map[string]string{"param_database": "default", "param_table_name": "clients"}, |
| 364 | 0x6fddf04d, |
| 365 | nil, |
| 366 | }, |
| 367 | } |
| 368 | |
| 369 | for _, tc := range testCases { |
| 370 | t.Run(tc.name, func(t *testing.T) { |
| 371 | r, err := calcMapHash(tc.input) |
| 372 | assert.Equal(t, r, tc.expectedResult) |
| 373 | assert.Equal(t, err, tc.expectedError) |
| 374 | }) |
| 375 | } |
| 376 | } |
nothing calls this directly
no test coverage detected