MCPcopy Create free account
hub / github.com/aws-cloudformation/rain / TestParseModuleConfig

Function TestParseModuleConfig

cft/module_config_test.go:135–195  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func TestParseModuleConfig(t *testing.T) {
136 // Create a test Template
137 template := &Template{}
138
139 // Test case 1: Basic module configuration
140 basicModuleYaml := `
141Source: ./module.yaml
142Properties:
143 Name: test
144Overrides:
145 Resource1:
146 Properties:
147 Name: overridden
148`
149 basicConfig, err := template.ParseModuleConfig("BasicModule",
150 unmarshalYaml(t, basicModuleYaml))
151 if err != nil {
152 t.Errorf("ParseModuleConfig failed: %v", err)
153 }
154
155 if basicConfig.Name != "BasicModule" {
156 t.Errorf("Expected Name=BasicModule, got %s", basicConfig.Name)
157 }
158 if basicConfig.Source != "./module.yaml" {
159 t.Errorf("Expected Source=./module.yaml, got %s", basicConfig.Source)
160 }
161 if basicConfig.PropertiesNode == nil {
162 t.Errorf("Expected PropertiesNode to be non-nil")
163 }
164 if basicConfig.OverridesNode == nil {
165 t.Errorf("Expected OverridesNode to be non-nil")
166 }
167
168 // Test case 2: Module with Map
169 mapModuleYaml := `
170Source: ./module.yaml
171ForEach: !Ref MyList
172Properties:
173 Name: test-${MapValue}
174`
175 mapConfig, err := template.ParseModuleConfig("MapModule",
176 unmarshalYaml(t, mapModuleYaml))
177 if err != nil {
178 t.Errorf("ParseModuleConfig failed: %v", err)
179 }
180
181 if mapConfig.Name != "MapModule" {
182 t.Errorf("Expected Name=MapModule, got %s", mapConfig.Name)
183 }
184 if mapConfig.Map == nil {
185 t.Errorf("Expected Map to be non-nil")
186 }
187
188 // Test case 3: Invalid node type
189 invalidNodeYaml := `- not a mapping node`
190 _, err = template.ParseModuleConfig("InvalidModule",
191 unmarshalYaml(t, invalidNodeYaml))
192 if err == nil {

Callers

nothing calls this directly

Calls 2

ParseModuleConfigMethod · 0.95
unmarshalYamlFunction · 0.85

Tested by

no test coverage detected