-
-
Notifications
You must be signed in to change notification settings - Fork 151
Expand file tree
/
Copy pathdescribe_component_test.go
More file actions
663 lines (581 loc) · 20.5 KB
/
describe_component_test.go
File metadata and controls
663 lines (581 loc) · 20.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
package exec
import (
"os"
"path/filepath"
"strings"
"testing"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
cfg "github.com/cloudposse/atmos/pkg/config"
log "github.com/cloudposse/atmos/pkg/logger"
"github.com/cloudposse/atmos/pkg/pager"
"github.com/cloudposse/atmos/pkg/schema"
u "github.com/cloudposse/atmos/pkg/utils"
)
func TestExecuteDescribeComponentCmd_Success_YAMLWithPager(t *testing.T) {
// Set up gomock controller
ctrl := gomock.NewController(t)
defer ctrl.Finish()
mockedExec := &DescribeComponentExec{
printOrWriteToFile: func(atmosConfig *schema.AtmosConfiguration, format string, file string, data any) error {
return nil
},
IsTTYSupportForStdout: func() bool {
return true
},
executeDescribeComponent: func(params *ExecuteDescribeComponentParams) (map[string]any, error) {
return map[string]any{
"component": params.Component,
"stack": params.Stack,
}, nil
},
initCliConfig: func(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error) {
return schema.AtmosConfiguration{}, nil
},
evaluateYqExpression: func(atmosConfig *schema.AtmosConfiguration, data any, yq string) (any, error) {
return data, nil
},
}
tests := []struct {
name string
params DescribeComponentParams
pagerSetting string
expectPager bool
expectedError bool
}{
{
name: "Test pager with YAML format",
params: DescribeComponentParams{
Component: "component-1",
Stack: "nonprod",
Format: "yaml",
},
pagerSetting: "less",
expectPager: true,
},
{
name: "Test pager with JSON format",
params: DescribeComponentParams{
Component: "component-1",
Stack: "nonprod",
Format: "json",
},
pagerSetting: "more",
expectPager: true,
},
{
name: "Test no pager with YAML format",
params: DescribeComponentParams{
Component: "component-1",
Stack: "nonprod",
Format: "yaml",
},
pagerSetting: "false",
expectPager: false,
},
{
name: "Test no pager with JSON format",
params: DescribeComponentParams{
Component: "component-1",
Stack: "nonprod",
Format: "json",
},
pagerSetting: "off",
expectPager: false,
},
{
name: "Test invalid format",
params: DescribeComponentParams{
Component: "component-1",
Stack: "nonprod",
Format: "invalid-format",
},
pagerSetting: "less",
expectPager: true,
expectedError: true,
},
{
name: "Test pager with query",
params: DescribeComponentParams{
Component: "component-1",
Stack: "nonprod",
Format: "json",
Query: ".component",
},
pagerSetting: "less",
expectPager: true,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
printOrWriteToFileCalled := false
// Set up mock pager based on test expectation
if test.expectPager {
mockPager := pager.NewMockPageCreator(ctrl)
if test.expectedError && test.params.Format == "invalid-format" {
// The pager won't be called because viewConfig will return error before reaching pageCreator
} else {
mockPager.EXPECT().Run("component-1", gomock.Any()).Return(nil).Times(1)
}
mockedExec.pageCreator = mockPager
} else {
// For non-pager tests, we don't need to mock the pager as it won't be called
mockedExec.pageCreator = nil
}
// Mock the initCliConfig to return a config with the test's pager setting
mockedExec.initCliConfig = func(configAndStacksInfo schema.ConfigAndStacksInfo, processStacks bool) (schema.AtmosConfiguration, error) {
return schema.AtmosConfiguration{
Settings: schema.AtmosSettings{
Terminal: schema.Terminal{
Pager: test.pagerSetting,
},
},
}, nil
}
// Mock printOrWriteToFile - this should only be called when pager is disabled or fails
mockedExec.printOrWriteToFile = func(atmosConfig *schema.AtmosConfiguration, format string, file string, data any) error {
printOrWriteToFileCalled = true
if test.expectedError && test.params.Format == "invalid-format" {
return DescribeConfigFormatError{format: "invalid-format"}
}
assert.Equal(t, test.params.Format, format)
assert.Equal(t, "", file)
assert.Equal(t, map[string]any{
"component": "component-1",
"stack": "nonprod",
}, data)
return nil
}
// Execute the command
err := mockedExec.ExecuteDescribeComponentCmd(test.params)
// Assert expectations
if test.expectedError {
assert.Error(t, err)
} else {
assert.NoError(t, err)
}
// When pager is enabled and successful, printOrWriteToFile should NOT be called (pager path returns early)
// When pager is disabled, printOrWriteToFile SHOULD be called
// When pager is enabled but fails with DescribeConfigFormatError, printOrWriteToFile should NOT be called (error path returns early)
expectedPrintCall := !test.expectPager && !test.expectedError
assert.Equal(t, expectedPrintCall, printOrWriteToFileCalled,
"printOrWriteToFile call expectation mismatch for pager setting: %s", test.pagerSetting)
})
}
}
func TestDescribeComponentWithOverridesSection(t *testing.T) {
err := os.Unsetenv("ATMOS_CLI_CONFIG_PATH")
if err != nil {
t.Fatalf("Failed to unset 'ATMOS_CLI_CONFIG_PATH': %v", err)
}
err = os.Unsetenv("ATMOS_BASE_PATH")
if err != nil {
t.Fatalf("Failed to unset 'ATMOS_BASE_PATH': %v", err)
}
log.SetLevel(log.InfoLevel)
log.SetOutput(os.Stdout)
defer func() {
// Delete the generated files and folders after the test
err := os.RemoveAll(filepath.Join("..", "..", "components", "terraform", "mock", ".terraform"))
assert.NoError(t, err)
err = os.RemoveAll(filepath.Join("..", "..", "components", "terraform", "mock", "terraform.tfstate.d"))
assert.NoError(t, err)
}()
// Define the working directory.
workDir := "../../tests/fixtures/scenarios/atmos-overrides-section"
t.Chdir(workDir)
// Set ATMOS_CLI_CONFIG_PATH to CWD to isolate from repo's atmos.yaml.
// This also disables parent directory search and git root discovery.
t.Setenv("ATMOS_CLI_CONFIG_PATH", ".")
component := "c1"
// `dev`
res, err := ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "dev",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err := u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a-dev")
assert.Contains(t, y, "b: b-team2")
assert.Contains(t, y, "c: c-team1")
assert.Contains(t, y, "d: d")
// `staging`
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "staging",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err = u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a-staging")
assert.Contains(t, y, "b: b-team2")
assert.Contains(t, y, "c: c-team1")
assert.Contains(t, y, "d: d")
// `prod`
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "prod",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err = u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a-prod")
assert.Contains(t, y, "b: b-prod")
assert.Contains(t, y, "c: c-prod")
assert.Contains(t, y, "d: d")
// `sandbox`
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "sandbox",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err = u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a-team2")
assert.Contains(t, y, "b: b-team2")
assert.Contains(t, y, "c: c-team1")
assert.Contains(t, y, "d: d")
// `test`
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "test",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err = u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a-test-2")
assert.Contains(t, y, "b: b-test")
assert.Contains(t, y, "c: c-team1")
assert.Contains(t, y, "d: d")
// `test2`
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "test2",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err = u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a")
assert.Contains(t, y, "b: b")
assert.Contains(t, y, "c: c")
assert.Contains(t, y, "d: d")
// `test3`
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "test3",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
y, err = u.ConvertToYAML(res)
assert.Nil(t, err)
assert.Contains(t, y, "a: a-overridden")
assert.Contains(t, y, "b: b-overridden")
assert.Contains(t, y, "c: c")
assert.Contains(t, y, "d: d")
}
func TestDescribeComponent_Packer(t *testing.T) {
log.SetLevel(log.InfoLevel)
log.SetOutput(os.Stdout)
// Define the working directory.
workDir := "../../tests/fixtures/scenarios/packer"
t.Chdir(workDir)
// Set ATMOS_CLI_CONFIG_PATH to CWD to isolate from repo's atmos.yaml.
// This also disables parent directory search and git root discovery.
t.Setenv("ATMOS_CLI_CONFIG_PATH", ".")
atmosConfig := schema.AtmosConfiguration{
Logs: schema.Logs{
Level: "Info",
},
}
component := "aws/bastion"
res, err := ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "prod",
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
val, err := u.EvaluateYqExpression(&atmosConfig, res, ".vars.ami_tags.SourceAMI")
assert.Nil(t, err)
assert.Equal(t, "ami-0013ceeff668b979b", val)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".stack")
assert.Nil(t, err)
assert.Equal(t, "prod", val)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".vars.assume_role_arn")
assert.Nil(t, err)
assert.Equal(t, "arn:aws:iam::PROD_ACCOUNT_ID:role/ROLE_NAME", val)
}
func TestDescribeComponent_Ansible(t *testing.T) {
log.SetLevel(log.InfoLevel)
log.SetOutput(os.Stdout)
// Define the working directory.
workDir := "../../examples/demo-ansible"
t.Chdir(workDir)
// Set ATMOS_CLI_CONFIG_PATH to CWD to isolate from repo's atmos.yaml.
t.Setenv("ATMOS_CLI_CONFIG_PATH", ".")
atmosConfig := schema.AtmosConfiguration{
Logs: schema.Logs{
Level: "Info",
},
}
component := "hello-world"
// Test detecting ansible component in dev stack.
res, err := ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "dev",
ProcessTemplates: false,
ProcessYamlFunctions: false,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
val, err := u.EvaluateYqExpression(&atmosConfig, res, ".vars.app_name")
assert.Nil(t, err)
assert.Equal(t, "my-app", val)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".vars.app_version")
assert.Nil(t, err)
assert.Equal(t, "1.0.0-dev", val)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".component_info.component_type")
assert.Nil(t, err)
assert.Equal(t, "ansible", val)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".stack")
assert.Nil(t, err)
assert.Equal(t, "dev", val)
// Test prod stack with overrides.
res, err = ExecuteDescribeComponent(&ExecuteDescribeComponentParams{
Component: component,
Stack: "prod",
ProcessTemplates: false,
ProcessYamlFunctions: false,
Skip: nil,
AuthManager: nil,
})
assert.NoError(t, err)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".vars.app_version")
assert.Nil(t, err)
assert.Equal(t, "2.0.0", val)
val, err = u.EvaluateYqExpression(&atmosConfig, res, ".vars.app_port")
assert.Nil(t, err)
assert.Equal(t, 443, val)
}
func TestDescribeComponentWithProvenance(t *testing.T) {
// Clear cache to ensure fresh processing.
ClearBaseComponentConfigCache()
ClearMergeContexts()
ClearLastMergeContext()
ClearFileContentCache()
err := os.Unsetenv("ATMOS_CLI_CONFIG_PATH")
if err != nil {
t.Fatalf("Failed to unset 'ATMOS_CLI_CONFIG_PATH': %v", err)
}
err = os.Unsetenv("ATMOS_BASE_PATH")
if err != nil {
t.Fatalf("Failed to unset 'ATMOS_BASE_PATH': %v", err)
}
log.SetLevel(log.InfoLevel)
log.SetOutput(os.Stdout)
// Define the working directory - using quick-start-advanced as it has a good mix of configs.
workDir := "../../examples/quick-start-advanced"
t.Chdir(workDir)
// Set ATMOS_CLI_CONFIG_PATH to CWD to isolate from repo's atmos.yaml.
// This also disables parent directory search and git root discovery.
t.Setenv("ATMOS_CLI_CONFIG_PATH", ".")
component := "vpc-flow-logs-bucket"
stack := "plat-ue2-dev"
// Initialize atmosConfig with provenance tracking enabled
var configAndStacksInfo schema.ConfigAndStacksInfo
configAndStacksInfo.ComponentFromArg = component
configAndStacksInfo.Stack = stack
atmosConfig, err := cfg.InitCliConfig(configAndStacksInfo, true)
assert.NoError(t, err)
atmosConfig.TrackProvenance = true
// Execute with provenance enabled using ExecuteDescribeComponentWithContext
result, err := ExecuteDescribeComponentWithContext(DescribeComponentContextParams{
AtmosConfig: &atmosConfig,
Component: component,
Stack: stack,
ProcessTemplates: true,
ProcessYamlFunctions: true,
Skip: nil,
})
assert.NoError(t, err)
assert.NotNil(t, result)
assert.NotNil(t, result.MergeContext, "MergeContext should not be nil when provenance is enabled")
assert.True(t, result.MergeContext.IsProvenanceEnabled(), "MergeContext should have provenance enabled")
// Verify component section is populated
assert.NotNil(t, result.ComponentSection)
assert.NotEmpty(t, result.ComponentSection)
// Verify MergeContext is populated
assert.NotNil(t, result.MergeContext, "MergeContext should not be nil when provenance is enabled")
assert.True(t, result.MergeContext.IsProvenanceEnabled(), "MergeContext should have provenance enabled")
// Verify provenance data exists
provenancePaths := result.MergeContext.GetProvenancePaths()
assert.NotEmpty(t, provenancePaths, "Provenance paths should not be empty")
// Verify we have provenance entries for vars fields.
// Check for any vars-related paths rather than specific ones to avoid platform-specific issues.
foundVarsPath := false
varsPathsFound := []string{}
for _, path := range provenancePaths {
entries := result.MergeContext.GetProvenance(path)
if len(entries) > 0 {
// Check for any vars.* path.
if strings.Contains(path, "vars.") {
foundVarsPath = true
varsPathsFound = append(varsPathsFound, path)
// Verify the entry has file and line information
assert.NotEmpty(t, entries[0].File, "Provenance entry for %s should have a file", path)
assert.Greater(t, entries[0].Line, 0, "Provenance entry for %s should have a line number", path)
}
}
}
// At least one vars path should be found.
if !foundVarsPath {
t.Logf("No vars.* paths found in provenance. Available paths: %v", provenancePaths)
}
assert.True(t, foundVarsPath, "Should find provenance for at least one vars field. Found vars paths: %v", varsPathsFound)
// Filter computed fields
filtered := FilterComputedFields(result.ComponentSection)
// Verify filtered section only has stack-defined fields
allowedFields := []string{"vars", "settings", "env", "backend", "metadata", "overrides", "providers", "imports", "description"}
for k := range filtered {
assert.Contains(t, allowedFields, k, "Filtered component section should only contain stack-defined fields")
}
// Verify computed fields are removed
computedFields := []string{"atmos_component", "atmos_stack", "component_info", "cli_args", "sources", "deps", "workspace"}
for _, field := range computedFields {
assert.NotContains(t, filtered, field, "Filtered component section should not contain computed field: %s", field)
}
// Verify expected fields exist
assert.Contains(t, filtered, "vars", "Should contain vars")
assert.Contains(t, filtered, "settings", "Should contain settings")
// Verify vars content
vars, ok := filtered["vars"].(map[string]any)
assert.True(t, ok, "vars should be a map")
assert.NotEmpty(t, vars, "vars should not be empty")
assert.Contains(t, vars, "enabled", "vars should contain 'enabled'")
assert.Contains(t, vars, "name", "vars should contain 'name'")
// Verify we can convert to YAML without errors
yamlBytes, err := u.ConvertToYAML(filtered)
assert.NoError(t, err)
assert.NotEmpty(t, yamlBytes)
// Verify YAML contains expected content
yamlStr := yamlBytes
assert.Contains(t, yamlStr, "vars:", "YAML should contain vars")
assert.Contains(t, yamlStr, "enabled:", "YAML should contain enabled")
// Verify YAML structure doesn't have unwanted top-level keys
// (We already verified this in the filtered map checks above, but double-check in YAML)
lines := strings.Split(yamlStr, "\n")
topLevelKeys := make(map[string]bool)
for _, line := range lines {
// Check for non-indented lines (top-level keys)
if len(line) > 0 && !strings.HasPrefix(line, " ") && strings.Contains(line, ":") {
key := strings.Split(line, ":")[0]
topLevelKeys[key] = true
}
}
// Verify computed fields are not top-level keys
assert.False(t, topLevelKeys["component_info"], "component_info should not be a top-level key")
assert.False(t, topLevelKeys["atmos_cli_config"], "atmos_cli_config should not be a top-level key")
assert.False(t, topLevelKeys["sources"], "sources should not be a top-level key")
assert.False(t, topLevelKeys["deps"], "deps should not be a top-level key")
assert.False(t, topLevelKeys["workspace"], "workspace should not be a top-level key")
t.Logf("Successfully tested provenance tracking with %d provenance paths", len(provenancePaths))
}
func TestFilterComputedFields(t *testing.T) {
tests := []struct {
name string
input map[string]any
expected map[string]any
}{
{
name: "Filters out all computed fields",
input: map[string]any{
"vars": map[string]any{"key": "value"},
"settings": map[string]any{"setting": "value"},
"atmos_component": "test-component",
"atmos_stack": "test-stack",
"component_info": map[string]any{"path": "/some/path"},
"cli_args": []string{"arg1"},
"sources": []string{"file1.yaml"},
"deps": []string{"dep1"},
"workspace": "default",
"atmos_cli_config": map[string]any{"base_path": "."},
"spacelift_stack": "stack-name",
"atlantis_project": "project-name",
"atmos_stack_file": "stack.yaml",
"atmos_manifest": "manifest.yaml",
},
expected: map[string]any{
"vars": map[string]any{"key": "value"},
"settings": map[string]any{"setting": "value"},
},
},
{
name: "Keeps only allowed fields",
input: map[string]any{
"vars": map[string]any{"enabled": true},
"env": map[string]any{"VAR": "value"},
"backend": map[string]any{"type": "s3"},
"metadata": map[string]any{"type": "real"},
"overrides": map[string]any{"key": "val"},
"providers": map[string]any{"aws": "config"},
"settings": map[string]any{"key": "val"},
},
expected: map[string]any{
"vars": map[string]any{"enabled": true},
"env": map[string]any{"VAR": "value"},
"backend": map[string]any{"type": "s3"},
"metadata": map[string]any{"type": "real"},
"overrides": map[string]any{"key": "val"},
"providers": map[string]any{"aws": "config"},
"settings": map[string]any{"key": "val"},
},
},
{
name: "Handles empty input",
input: map[string]any{},
expected: map[string]any{},
},
{
name: "Handles nil input",
input: nil,
expected: map[string]any{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := FilterComputedFields(tt.input)
assert.Equal(t, tt.expected, result)
})
}
}