(t *testing.T)
| 257 | } |
| 258 | |
| 259 | func TestFnForEachOutputKeyHasIdentifier(t *testing.T) { |
| 260 | // Test cases for OutputKeyHasIdentifier |
| 261 | testCases := []struct { |
| 262 | name string |
| 263 | identifier string |
| 264 | outputKey string |
| 265 | expected bool |
| 266 | }{ |
| 267 | { |
| 268 | name: "Dollar syntax present", |
| 269 | identifier: "item", |
| 270 | outputKey: "test-${item}", |
| 271 | expected: true, |
| 272 | }, |
| 273 | { |
| 274 | name: "Ampersand syntax present", |
| 275 | identifier: "item", |
| 276 | outputKey: "test-&{item}", |
| 277 | expected: true, |
| 278 | }, |
| 279 | { |
| 280 | name: "No identifier", |
| 281 | identifier: "item", |
| 282 | outputKey: "test-static", |
| 283 | expected: false, |
| 284 | }, |
| 285 | { |
| 286 | name: "Different identifier", |
| 287 | identifier: "item", |
| 288 | outputKey: "${different}", |
| 289 | expected: false, |
| 290 | }, |
| 291 | } |
| 292 | |
| 293 | for _, tc := range testCases { |
| 294 | t.Run(tc.name, func(t *testing.T) { |
| 295 | fnForEach := FnForEach{ |
| 296 | Identifier: tc.identifier, |
| 297 | OutputKey: tc.outputKey, |
| 298 | } |
| 299 | |
| 300 | result := fnForEach.OutputKeyHasIdentifier() |
| 301 | if result != tc.expected { |
| 302 | t.Errorf("Expected OutputKeyHasIdentifier()=%v, got %v", |
| 303 | tc.expected, result) |
| 304 | } |
| 305 | }) |
| 306 | } |
| 307 | } |
| 308 | |
| 309 | func TestFnForEachReplaceIdentifier(t *testing.T) { |
| 310 | // Test cases for ReplaceIdentifier |
nothing calls this directly
no test coverage detected