Skip to content

Commit 05fb6b4

Browse files
author
Claude
committed
fix: use regex to strip IDs in import/export test
Simplify the approach by using regex to remove ID fields directly rather than parsing and normalizing YAML. Signed-off-by: markphelps <[email protected]>
1 parent e2598b2 commit 05fb6b4

File tree

2 files changed

+12
-84
lines changed

2 files changed

+12
-84
lines changed

build/testing/integration.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"math/big"
1515
"os"
1616
"path"
17+
"regexp"
1718
"runtime"
1819
"strconv"
1920
"strings"
@@ -648,19 +649,19 @@ func importExport(ctx context.Context, _ *dagger.Client, base, flipt *dagger.Con
648649
// remove line that starts with comment character '#' and newline after
649650
generated = generated[strings.Index(generated, "\n")+2:]
650651

651-
// Normalize both YAMLs by removing IDs before comparison
652-
// IDs are server-generated and not stable across import/export
653-
expectedNormalized, err := normalizeYAMLForComparison(expected)
654-
if err != nil {
655-
return fmt.Errorf("normalizing expected YAML: %w", err)
656-
}
652+
// Remove ID fields from constraints and rollouts before comparison
653+
// IDs are server-generated UUIDs and not stable across import/export
654+
// Using regex to remove id: lines from the YAML
655+
idLineRegex := regexp.MustCompile(`(?m)^\s*- id: "[^"]*"\n`)
656+
expected = idLineRegex.ReplaceAllString(expected, "")
657+
generated = idLineRegex.ReplaceAllString(generated, "")
657658

658-
generatedNormalized, err := normalizeYAMLForComparison(generated)
659-
if err != nil {
660-
return fmt.Errorf("normalizing generated YAML: %w", err)
661-
}
659+
// Also handle case where id is not first in the list
660+
idFieldRegex := regexp.MustCompile(`(?m)^\s+id: "[^"]*"\n`)
661+
expected = idFieldRegex.ReplaceAllString(expected, "")
662+
generated = idFieldRegex.ReplaceAllString(generated, "")
662663

663-
diff := cmp.Diff(expectedNormalized, generatedNormalized)
664+
diff := cmp.Diff(expected, generated)
664665
if diff != "" {
665666
fmt.Printf("Unexpected difference in %q exported output: \n", conf.name)
666667
fmt.Println(diff)

build/testing/integration_helper.go

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)