mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Change TestCommitPrefixMigrations to compare only strings
This commit is contained in:
parent
4b30bc6dd3
commit
38ab7ebefb
1 changed files with 18 additions and 29 deletions
|
@ -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))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue