Fixing tests in review of #1568

Signed-off-by: Jonathon Anderson <janderson@ciq.com>
This commit is contained in:
Jonathon Anderson
2025-01-17 00:58:12 -07:00
parent 847d11611b
commit eff1edd038
27 changed files with 90 additions and 98 deletions

View File

@@ -188,7 +188,7 @@ Return the names of all available remote resources
*/
func (config *NodesYaml) ListAllResources() []string {
var resList []string
for name := range config.Resource {
for name := range config.Resources {
resList = append(resList, name)
}
sort.Strings(resList)
@@ -227,8 +227,8 @@ func (config *NodesYaml) FindDiscoverableNode() (Node, string, error) {
/*
get the given resource
*/
func (config *NodesYaml) GetResource(id string) (res RemoteRes, err error) {
if found, ok := config.Resource[id]; ok {
func (config *NodesYaml) GetResource(id string) (res Resource, err error) {
if found, ok := config.Resources[id]; ok {
return found, nil
}
return res, ErrNotFound

View File

@@ -22,7 +22,7 @@ nodes:
network devices:
net0:
device: eth0
resource_list:
resources:
- NFSHOME
test_node2:
primary network: net1
@@ -53,7 +53,7 @@ nodes:
network devices:
override:
device: ib1
resource:
resources:
NFSHOME:
mountpoint: /home
`
@@ -123,8 +123,8 @@ func Test_Primary_Network(t *testing.T) {
assert.Equal(t, "profile", test_node6.NetDevs["override"].Type)
})
t.Run("resource is defined", func(t *testing.T) {
assert.Contains(t, test_node1.ResourceList, "NFSHOME")
res, err := c.GetResource(test_node1.ResourceList[0])
assert.Contains(t, test_node1.Resources, "NFSHOME")
res, err := c.GetResource(test_node1.Resources[0])
assert.NoError(t, err)
assert.Contains(t, res, "mountpoint")
})

View File

@@ -15,9 +15,9 @@ const undef string = "UNDEF"
Structure of which goes to disk
*/
type NodesYaml struct {
NodeProfiles map[string]*Profile
Nodes map[string]*Node
Resource map[string]RemoteRes `yaml:"resource,omitempty"`
NodeProfiles map[string]*Profile `yaml:"nodeprofiles"`
Nodes map[string]*Node `yaml:"nodes"`
Resources map[string]Resource `yaml:"resources,omitempty"`
}
/*
@@ -54,7 +54,7 @@ type Profile struct {
PrimaryNetDev string `yaml:"primary network,omitempty" lopt:"primarynet" sopt:"p" comment:"Set the primary network interface"`
Disks map[string]*Disk `yaml:"disks,omitempty"`
FileSystems map[string]*FileSystem `yaml:"filesystems,omitempty"`
ResourceList []string `yaml:"resource_list,omitempty" lopt:"resources" comment:"Set the resources available to the node or profile"`
Resources []string `yaml:"resources,omitempty" lopt:"resources" comment:"Set the resources available to the node or profile"`
}
type IpmiConf struct {
@@ -127,13 +127,4 @@ type FileSystem struct {
MountOptions string `yaml:"mount_options,omitempty" comment:"any special options to be passed to the mount command"`
}
/*
Definition of any remote. Can be a nfs share or other FS types
*/
type RemoteRes map[string]string
// always return so that the resource isn't marshalled
// func (res RemoteRes) IsZero() bool {
// return true
// }
type Resource map[string]string

View File

@@ -142,6 +142,7 @@ func Test_listFields(t *testing.T) {
"NetDevs[default].Tags[nettag]",
"Tags[tag]",
"PrimaryNetDev",
"Resources",
},
},
"profile": {
@@ -192,6 +193,7 @@ func Test_listFields(t *testing.T) {
"NetDevs[default].Tags[nettag]",
"Tags[tag]",
"PrimaryNetDev",
"Resources",
},
},
}