From 9c3b52b27fc464aa9f053051d9f2c9b35d626744 Mon Sep 17 00:00:00 2001 From: Jonathon Anderson Date: Thu, 7 Nov 2024 23:43:51 -0700 Subject: [PATCH] Restore skipped tests Signed-off-by: Jonathon Anderson --- internal/app/wwctl/node/list/main_test.go | 146 +++++++++++++++++-- internal/app/wwctl/profile/list/main_test.go | 87 +++++++++-- 2 files changed, 204 insertions(+), 29 deletions(-) diff --git a/internal/app/wwctl/node/list/main_test.go b/internal/app/wwctl/node/list/main_test.go index c787c0a8..a821d626 100644 --- a/internal/app/wwctl/node/list/main_test.go +++ b/internal/app/wwctl/node/list/main_test.go @@ -443,7 +443,6 @@ nodes: } func TestListMultipleFormats(t *testing.T) { - t.Skip("temporally skip this test") tests := []struct { name string args []string @@ -452,9 +451,14 @@ func TestListMultipleFormats(t *testing.T) { wantErr bool }{ { - name: "single node list yaml output", - args: []string{"-y"}, - stdout: "n01:\n AssetKey: \"\"\n ClusterName: \"\"\n Comment: \"\"\n ContainerName: \"\"\n Discoverable: \"\"\n Disks: {}\n FileSystems: {}\n Grub: \"\"\n Id: |\n Source: explicit\n Value: n01\n Init: |\n Source: default-value\n Value: /sbin/init\n Ipmi:\n EscapeChar: \"\"\n Gateway: \"\"\n Interface: \"\"\n Ipaddr: \"\"\n Netmask: \"\"\n Password: \"\"\n Port: \"\"\n Tags: null\n UserName: \"\"\n Write: \"\"\n Ipxe: |\n Source: default-value\n Value: default\n Kernel:\n Args: |\n Source: default-value\n Value: quiet crashkernel=no vga=791 net.naming-scheme=v238\n Override: \"\"\n NetDevs: {}\n PrimaryNetDev: \"\"\n Profiles: |\n Source: explicit\n Value: default\n Root: |\n Source: default-value\n Value: initramfs\n RuntimeOverlay: |\n Source: default-value\n Value: generic\n SystemOverlay: |\n Source: default-value\n Value: wwinit\n Tags: {}\n", + name: "single node list yaml output", + args: []string{"-y"}, + stdout: ` +- profiles: + - default + kernel: {} + ipmi: {} +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -465,9 +469,45 @@ nodes: `, }, { - name: "single node list json output", - args: []string{"-j"}, - stdout: "{\"n01\":{\"Id\":\"Source: explicit\\nValue: n01\\n\",\"Comment\":\"\",\"ClusterName\":\"\",\"ContainerName\":\"\",\"Ipxe\":\"Source: default-value\\nValue: default\\n\",\"Grub\":\"\",\"RuntimeOverlay\":\"Source: default-value\\nValue: generic\\n\",\"SystemOverlay\":\"Source: default-value\\nValue: wwinit\\n\",\"Root\":\"Source: default-value\\nValue: initramfs\\n\",\"Discoverable\":\"\",\"Init\":\"Source: default-value\\nValue: /sbin/init\\n\",\"AssetKey\":\"\",\"Kernel\":{\"Override\":\"\",\"Args\":\"Source: default-value\\nValue: quiet crashkernel=no vga=791 net.naming-scheme=v238\\n\"},\"Ipmi\":{\"Ipaddr\":\"\",\"Netmask\":\"\",\"Port\":\"\",\"Gateway\":\"\",\"UserName\":\"\",\"Password\":\"\",\"Interface\":\"\",\"EscapeChar\":\"\",\"Write\":\"\",\"Tags\":null},\"Profiles\":\"Source: explicit\\nValue: default\\n\",\"PrimaryNetDev\":\"\",\"NetDevs\":{},\"Tags\":{},\"Disks\":{},\"FileSystems\":{}}}\n", + name: "single node list json output", + args: []string{"-j"}, + stdout: ` +[ + { + "Discoverable": "", + "AssetKey": "", + "Profiles": [ + "default" + ], + "Comment": "", + "ClusterName": "", + "ContainerName": "", + "Ipxe": "", + "RuntimeOverlay": null, + "SystemOverlay": null, + "Kernel": {}, + "Ipmi": { + "UserName": "", + "Password": "", + "Ipaddr": "", + "Gateway": "", + "Netmask": "", + "Port": "", + "Interface": "", + "EscapeChar": "", + "Write": "", + "Tags": {} + }, + "Init": "", + "Root": "", + "NetDevs": {}, + "Tags": {}, + "PrimaryNetDev": "", + "Disks": null, + "FileSystems": null + } +] +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -478,9 +518,78 @@ nodes: `, }, { - name: "multiple nodes list json output", - args: []string{"-j"}, - stdout: "n01 n02", + name: "multiple nodes list json output", + args: []string{"-j"}, + stdout: ` +[ + { + "Discoverable": "", + "AssetKey": "", + "Profiles": [ + "default" + ], + "Comment": "", + "ClusterName": "", + "ContainerName": "", + "Ipxe": "", + "RuntimeOverlay": null, + "SystemOverlay": null, + "Kernel": {}, + "Ipmi": { + "UserName": "", + "Password": "", + "Ipaddr": "", + "Gateway": "", + "Netmask": "", + "Port": "", + "Interface": "", + "EscapeChar": "", + "Write": "", + "Tags": {} + }, + "Init": "", + "Root": "", + "NetDevs": {}, + "Tags": {}, + "PrimaryNetDev": "", + "Disks": null, + "FileSystems": null + }, + { + "Discoverable": "", + "AssetKey": "", + "Profiles": [ + "default" + ], + "Comment": "", + "ClusterName": "", + "ContainerName": "", + "Ipxe": "", + "RuntimeOverlay": null, + "SystemOverlay": null, + "Kernel": {}, + "Ipmi": { + "UserName": "", + "Password": "", + "Ipaddr": "", + "Gateway": "", + "Netmask": "", + "Port": "", + "Interface": "", + "EscapeChar": "", + "Write": "", + "Tags": {} + }, + "Init": "", + "Root": "", + "NetDevs": {}, + "Tags": {}, + "PrimaryNetDev": "", + "Disks": null, + "FileSystems": null + } +] +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -494,9 +603,18 @@ nodes: `, }, { - name: "multiple nodes list yaml output", - args: []string{"-y"}, - stdout: "n01: n02:", + name: "multiple nodes list yaml output", + args: []string{"-y"}, + stdout: ` +- profiles: + - default + kernel: {} + ipmi: {} +- profiles: + - default + kernel: {} + ipmi: {} +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -529,7 +647,7 @@ nodes: } else { assert.NoError(t, err) } - assert.Equal(t, strings.TrimSpace(buf.String()), strings.TrimSpace(tt.stdout)) + assert.Equal(t, strings.TrimSpace(tt.stdout), strings.TrimSpace(buf.String())) }) } } diff --git a/internal/app/wwctl/profile/list/main_test.go b/internal/app/wwctl/profile/list/main_test.go index fa400283..39362f5d 100644 --- a/internal/app/wwctl/profile/list/main_test.go +++ b/internal/app/wwctl/profile/list/main_test.go @@ -148,17 +148,16 @@ nodes: } func TestListMultipleFormats(t *testing.T) { - t.Skip("temporally skip this test") tests := []struct { name string args []string - output []string + output string inDb string }{ { name: "single profile list yaml output", args: []string{"-y"}, - output: []string{"default:\n AssetKey: \"\"\n ClusterName: \"\"\n Comment: \"\"\n ContainerName: \"\"\n Discoverable: \"\"\n Disks: {}\n FileSystems: {}\n Grub: \"\"\n Id: |\n Source: explicit\n Value: default\n Init: \"\"\n Ipmi:\n EscapeChar: \"\"\n Gateway: \"\"\n Interface: \"\"\n Ipaddr: \"\"\n Netmask: \"\"\n Password: \"\"\n Port: \"\"\n Tags: null\n UserName: \"\"\n Write: \"\"\n Ipxe: \"\"\n Kernel:\n Args: \"\"\n Override: \"\"\n NetDevs: {}\n PrimaryNetDev: \"\"\n Profiles: \"\"\n Root: \"\"\n RuntimeOverlay: \"\"\n SystemOverlay: \"\"\n Tags: {}\n"}, + output: `default: {}`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -169,9 +168,29 @@ nodes: `, }, { - name: "single profile list json output", - args: []string{"-j"}, - output: []string{"{\"default\":{\"Id\":\"Source: explicit\\nValue: default\\n\",\"Comment\":\"\",\"ClusterName\":\"\",\"ContainerName\":\"\",\"Ipxe\":\"\",\"Grub\":\"\",\"RuntimeOverlay\":\"\",\"SystemOverlay\":\"\",\"Root\":\"\",\"Discoverable\":\"\",\"Init\":\"\",\"AssetKey\":\"\",\"Kernel\":{\"Override\":\"\",\"Args\":\"\"},\"Ipmi\":{\"Ipaddr\":\"\",\"Netmask\":\"\",\"Port\":\"\",\"Gateway\":\"\",\"UserName\":\"\",\"Password\":\"\",\"Interface\":\"\",\"EscapeChar\":\"\",\"Write\":\"\",\"Tags\":null},\"Profiles\":\"\",\"PrimaryNetDev\":\"\",\"NetDevs\":{},\"Tags\":{},\"Disks\":{},\"FileSystems\":{}}}\n"}, + name: "single profile list json output", + args: []string{"-j"}, + output: ` +{ + "default": { + "Comment": "", + "ClusterName": "", + "ContainerName": "", + "Ipxe": "", + "RuntimeOverlay": null, + "SystemOverlay": null, + "Kernel": null, + "Ipmi": null, + "Init": "", + "Root": "", + "NetDevs": null, + "Tags": null, + "PrimaryNetDev": "", + "Disks": null, + "FileSystems": null + } +} +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -182,9 +201,12 @@ nodes: `, }, { - name: "multiple profiles list yaml output", - args: []string{"-y"}, - output: []string{"default", "test"}, + name: "multiple profiles list yaml output", + args: []string{"-y"}, + output: ` +default: {} +test: {} +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -196,9 +218,46 @@ nodes: `, }, { - name: "multiple profiles list json output", - args: []string{"-j"}, - output: []string{"default", "test"}, + name: "multiple profiles list json output", + args: []string{"-j"}, + output: ` +{ + "default": { + "Comment": "", + "ClusterName": "", + "ContainerName": "", + "Ipxe": "", + "RuntimeOverlay": null, + "SystemOverlay": null, + "Kernel": null, + "Ipmi": null, + "Init": "", + "Root": "", + "NetDevs": null, + "Tags": null, + "PrimaryNetDev": "", + "Disks": null, + "FileSystems": null + }, + "test": { + "Comment": "", + "ClusterName": "", + "ContainerName": "", + "Ipxe": "", + "RuntimeOverlay": null, + "SystemOverlay": null, + "Kernel": null, + "Ipmi": null, + "Init": "", + "Root": "", + "NetDevs": null, + "Tags": null, + "PrimaryNetDev": "", + "Disks": null, + "FileSystems": null + } +} +`, inDb: `WW_INTERNAL: 43 nodeprofiles: default: {} @@ -244,9 +303,7 @@ nodes: wwlog.SetLogWriter(buf) err := baseCmd.Execute() assert.NoError(t, err) - for _, output := range tt.output { - assert.Contains(t, buf.String(), output) - } + assert.Equal(t, strings.TrimSpace(tt.output), strings.TrimSpace(buf.String())) }) } }