|
5 | 5 | "testing" |
6 | 6 |
|
7 | 7 | "github.com/stretchr/testify/assert" |
| 8 | + "github.com/stretchr/testify/require" |
8 | 9 |
|
9 | 10 | "github.com/osbuild/images/internal/testdisk" |
10 | 11 | "github.com/osbuild/images/pkg/blueprint" |
@@ -2284,21 +2285,24 @@ func TestNewCustomPartitionTableErrors(t *testing.T) { |
2284 | 2285 | } |
2285 | 2286 |
|
2286 | 2287 | func TestPartitionTableFeatures(t *testing.T) { |
2287 | | - type testCase struct { |
2288 | | - partitionType string |
2289 | | - expectedFeatures disk.PartitionTableFeatures |
2290 | | - } |
2291 | | - testCases := []testCase{ |
2292 | | - {"plain", disk.PartitionTableFeatures{XFS: true, FAT: true}}, |
2293 | | - {"plain-swap", disk.PartitionTableFeatures{XFS: true, FAT: true, Swap: true}}, |
2294 | | - {"luks", disk.PartitionTableFeatures{XFS: true, FAT: true, LUKS: true}}, |
2295 | | - {"luks+lvm", disk.PartitionTableFeatures{XFS: true, FAT: true, LUKS: true, LVM: true}}, |
2296 | | - {"btrfs", disk.PartitionTableFeatures{XFS: true, FAT: true, Btrfs: true}}, |
2297 | | - } |
| 2288 | + require := require.New(t) |
2298 | 2289 |
|
2299 | | - for _, tc := range testCases { |
2300 | | - pt := testdisk.TestPartitionTables[tc.partitionType] |
2301 | | - assert.Equal(t, tc.expectedFeatures, disk.GetPartitionTableFeatures(pt)) |
| 2290 | + testCases := map[string]disk.PartitionTableFeatures{ |
| 2291 | + "plain": {XFS: true, FAT: true}, |
| 2292 | + "plain-noboot": {XFS: true, FAT: true}, |
| 2293 | + "plain-swap": {XFS: true, FAT: true, Swap: true}, |
| 2294 | + "luks": {XFS: true, FAT: true, LUKS: true}, |
| 2295 | + "luks+lvm": {XFS: true, FAT: true, LUKS: true, LVM: true}, |
| 2296 | + "btrfs": {XFS: true, FAT: true, Btrfs: true}, |
| 2297 | + } |
2302 | 2298 |
|
| 2299 | + for name := range testdisk.TestPartitionTables { |
| 2300 | + // print an informative failure message if a new test partition |
| 2301 | + // table is added and this test is not updated (instead of failing |
| 2302 | + // at the final Equal() check) |
| 2303 | + exp, ok := testCases[name] |
| 2304 | + require.True(ok, "expected test result not defined for test partition table %q: please update the %s test", name, t.Name()) |
| 2305 | + pt := testdisk.TestPartitionTables[name] |
| 2306 | + require.Equal(exp, disk.GetPartitionTableFeatures(pt)) |
2303 | 2307 | } |
2304 | 2308 | } |
0 commit comments