|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 | "net/netip" |
7 | | - "reflect" |
8 | 7 | "sort" |
| 8 | + "strconv" |
9 | 9 | "testing" |
10 | 10 | "time" |
11 | 11 |
|
@@ -368,23 +368,23 @@ func TestUpdateHealthcheckTable(t *testing.T) { |
368 | 368 | err: "--no-healthcheck conflicts with --health-* options", |
369 | 369 | }, |
370 | 370 | } |
371 | | - for i, c := range testCases { |
372 | | - flags := newUpdateCommand(nil).Flags() |
373 | | - for _, flag := range c.flags { |
374 | | - flags.Set(flag[0], flag[1]) |
375 | | - } |
376 | | - cspec := &swarm.ContainerSpec{ |
377 | | - Healthcheck: c.initial, |
378 | | - } |
379 | | - err := updateHealthcheck(flags, cspec) |
380 | | - if c.err != "" { |
381 | | - assert.Error(t, err, c.err) |
382 | | - } else { |
383 | | - assert.NilError(t, err) |
384 | | - if !reflect.DeepEqual(cspec.Healthcheck, c.expected) { |
385 | | - t.Errorf("incorrect result for test %d, expected health config:\n\t%#v\ngot:\n\t%#v", i, c.expected, cspec.Healthcheck) |
| 371 | + for i, tc := range testCases { |
| 372 | + t.Run(strconv.Itoa(i), func(t *testing.T) { |
| 373 | + flags := newUpdateCommand(nil).Flags() |
| 374 | + for _, flag := range tc.flags { |
| 375 | + assert.Check(t, flags.Set(flag[0], flag[1])) |
386 | 376 | } |
387 | | - } |
| 377 | + cspec := &swarm.ContainerSpec{ |
| 378 | + Healthcheck: tc.initial, |
| 379 | + } |
| 380 | + err := updateHealthcheck(flags, cspec) |
| 381 | + if tc.err != "" { |
| 382 | + assert.Error(t, err, tc.err) |
| 383 | + } else { |
| 384 | + assert.NilError(t, err) |
| 385 | + assert.Check(t, is.DeepEqual(cspec.Healthcheck, tc.expected)) |
| 386 | + } |
| 387 | + }) |
388 | 388 | } |
389 | 389 | } |
390 | 390 |
|
|
0 commit comments