Skip to content

Commit e1b7aa1

Browse files
committed
dont ignore empty modules
1 parent c848651 commit e1b7aa1

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

input/input_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,26 +1129,27 @@ func TestModuleParams_GetDefinedModules(t *testing.T) {
11291129
},
11301130
},
11311131
{
1132-
name: "ignores empty maps",
1132+
name: "dont ignore empty maps",
11331133
params: ModuleParams{
11341134
Order: []string{"topoaa"},
11351135
Topoaa: map[string]any{
11361136
"param1": "value1",
11371137
},
1138-
Rigidbody: map[string]any{}, // empty map should be ignored
1138+
Rigidbody: map[string]any{},
11391139
},
11401140
expected: map[string]map[string]any{
11411141
"topoaa": {
11421142
"param1": "value1",
11431143
},
1144+
"rigidbody": {},
11441145
},
11451146
},
11461147
{
1147-
name: "ignores nil maps",
1148+
name: "ignore nil maps",
11481149
params: ModuleParams{
11491150
Order: []string{"topoaa"},
11501151
Topoaa: map[string]any{"param1": "value1"},
1151-
Rigidbody: nil, // nil map should be ignored
1152+
Rigidbody: nil,
11521153
},
11531154
expected: map[string]map[string]any{
11541155
"topoaa": {
@@ -1200,13 +1201,14 @@ func TestModuleParams_GetUndefinedModulesInOrder(t *testing.T) {
12001201
{
12011202
name: "all modules defined",
12021203
params: ModuleParams{
1203-
Order: []string{"topoaa", "rigidbody"},
1204+
Order: []string{"topoaa", "rigidbody", "clustfcc"},
12041205
Topoaa: map[string]any{
12051206
"param1": "value1",
12061207
},
12071208
Rigidbody: map[string]any{
12081209
"param2": "value2",
12091210
},
1211+
Clustfcc: map[string]any{},
12101212
},
12111213
expected: []string{},
12121214
},
@@ -1332,13 +1334,14 @@ func TestModuleParams_GetMissingModulesFromOrder(t *testing.T) {
13321334
{
13331335
name: "all defined modules in order",
13341336
params: ModuleParams{
1335-
Order: []string{"topoaa", "rigidbody"},
1337+
Order: []string{"topoaa", "rigidbody", "clustfcc"},
13361338
Topoaa: map[string]any{
13371339
"param1": "value1",
13381340
},
13391341
Rigidbody: map[string]any{
13401342
"param2": "value2",
13411343
},
1344+
Clustfcc: map[string]any{},
13421345
},
13431346
expected: []string{},
13441347
},

input/module-struct.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ func (mp ModuleParams) String() string {
747747
return sb.String()
748748
}
749749

750-
// GetDefinedModules returns a map of all module names that have non-empty configurations
750+
// GetDefinedModules returns a map of all module names that have non-nil configurations
751751
func (mp ModuleParams) GetDefinedModules() map[string]map[string]any {
752752
defined := make(map[string]map[string]any)
753753

@@ -763,8 +763,9 @@ func (mp ModuleParams) GetDefinedModules() map[string]map[string]any {
763763
continue
764764
}
765765

766-
// Only consider map fields
767-
if field.Type().Kind() == reflect.Map && !field.IsNil() && field.Len() > 0 {
766+
// Only consider map fields that are not nil
767+
// Include empty maps as they represent modules with no parameters
768+
if field.Type().Kind() == reflect.Map && !field.IsNil() {
768769
yamlTag := fieldType.Tag.Get("yaml")
769770
if yamlTag != "" {
770771
defined[yamlTag] = field.Interface().(map[string]any)

0 commit comments

Comments
 (0)