The Status field is a human-readable uptime string (e.g. "Up Less than a
second" vs "Up 1 second") that changes as time passes. The sub-tests
compare a previously captured DiskUsageResult snapshot against a fresh
API call, so even a sub-second delay between the two can cause a mismatch.
Use cmpopts.IgnoreFields to exclude Status from the DeepEqual comparison
in the type-filter sub-tests. The field is already implicitly covered by
the State and Created assertions in the parent step.
Signed-off-by: Ricardo Branco <rbranco@suse.de>
| ... | ... |
@@ -5,6 +5,7 @@ import ( |
| 5 | 5 |
"testing" |
| 6 | 6 |
|
| 7 | 7 |
"github.com/google/go-cmp/cmp/cmpopts" |
| 8 |
+ containertypes "github.com/moby/moby/api/types/container" |
|
| 8 | 9 |
"github.com/moby/moby/client" |
| 9 | 10 |
"github.com/moby/moby/v2/integration/internal/container" |
| 10 | 11 |
"github.com/moby/moby/v2/internal/testutil" |
| ... | ... |
@@ -284,7 +285,10 @@ func TestDiskUsage(t *testing.T) {
|
| 284 | 284 |
|
| 285 | 285 |
du, err := apiClient.DiskUsage(ctx, tc.options) |
| 286 | 286 |
assert.NilError(t, err) |
| 287 |
- assert.DeepEqual(t, du, tc.expected, cmpopts.EquateComparable(netip.Addr{}, netip.Prefix{}))
|
|
| 287 |
+ assert.DeepEqual(t, du, tc.expected, |
|
| 288 |
+ cmpopts.EquateComparable(netip.Addr{}, netip.Prefix{}),
|
|
| 289 |
+ cmpopts.IgnoreFields(containertypes.Summary{}, "Status"),
|
|
| 290 |
+ ) |
|
| 288 | 291 |
}) |
| 289 | 292 |
} |
| 290 | 293 |
}) |