From 38ab7ebefb444af75f3799fd91cac40d52c9ce50 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sun, 23 Feb 2025 18:51:35 +0100 Subject: [PATCH] Change TestCommitPrefixMigrations to compare only strings --- pkg/config/app_config_test.go | 47 ++++++++++++++--------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/pkg/config/app_config_test.go b/pkg/config/app_config_test.go index 72bc5f7cc..4a6ce0ee6 100644 --- a/pkg/config/app_config_test.go +++ b/pkg/config/app_config_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/stretchr/testify/assert" - "gopkg.in/yaml.v3" ) func TestCommitPrefixMigrations(t *testing.T) { @@ -19,36 +18,36 @@ func TestCommitPrefixMigrations(t *testing.T) { expected: "", }, { name: "Single CommitPrefix Rename", - input: ` -git: + input: `git: commitPrefix: pattern: "^\\w+-\\w+.*" - replace: '[JIRA $0] '`, - expected: ` -git: + replace: '[JIRA $0] ' +`, + expected: `git: commitPrefix: - pattern: "^\\w+-\\w+.*" - replace: '[JIRA $0] '`, + replace: '[JIRA $0] ' +`, }, { name: "Complicated CommitPrefixes Rename", - input: ` -git: + input: `git: commitPrefixes: foo: pattern: "^\\w+-\\w+.*" replace: '[OTHER $0] ' CrazyName!@#$^*&)_-)[[}{f{[]: pattern: "^foo.bar*" - replace: '[FUN $0] '`, - expected: ` -git: + replace: '[FUN $0] ' +`, + expected: `git: commitPrefixes: - foo: - - pattern: "^\\w+-\\w+.*" - replace: '[OTHER $0] ' - CrazyName!@#$^*&)_-)[[}{f{[]: - - pattern: "^foo.bar*" - replace: '[FUN $0] '`, + foo: + - pattern: "^\\w+-\\w+.*" + replace: '[OTHER $0] ' + CrazyName!@#$^*&)_-)[[}{f{[]: + - pattern: "^foo.bar*" + replace: '[FUN $0] ' +`, }, { name: "Incomplete Configuration", input: "git:", @@ -58,21 +57,11 @@ git: for _, s := range scenarios { t.Run(s.name, func(t *testing.T) { - expectedConfig := GetDefaultConfig() - err := yaml.Unmarshal([]byte(s.expected), expectedConfig) - if err != nil { - t.Error(err) - } actual, err := computeMigratedConfig("path doesn't matter", []byte(s.input)) if err != nil { t.Error(err) } - actualConfig := GetDefaultConfig() - err = yaml.Unmarshal(actual, actualConfig) - if err != nil { - t.Error(err) - } - assert.Equal(t, expectedConfig, actualConfig) + assert.Equal(t, s.expected, string(actual)) }) } }