mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
Change TestCommitPrefixMigrations to compare only strings
This commit is contained in:
parent
4b30bc6dd3
commit
38ab7ebefb
@ -4,7 +4,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v3"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCommitPrefixMigrations(t *testing.T) {
|
func TestCommitPrefixMigrations(t *testing.T) {
|
||||||
@ -19,36 +18,36 @@ func TestCommitPrefixMigrations(t *testing.T) {
|
|||||||
expected: "",
|
expected: "",
|
||||||
}, {
|
}, {
|
||||||
name: "Single CommitPrefix Rename",
|
name: "Single CommitPrefix Rename",
|
||||||
input: `
|
input: `git:
|
||||||
git:
|
|
||||||
commitPrefix:
|
commitPrefix:
|
||||||
pattern: "^\\w+-\\w+.*"
|
pattern: "^\\w+-\\w+.*"
|
||||||
replace: '[JIRA $0] '`,
|
replace: '[JIRA $0] '
|
||||||
expected: `
|
`,
|
||||||
git:
|
expected: `git:
|
||||||
commitPrefix:
|
commitPrefix:
|
||||||
- pattern: "^\\w+-\\w+.*"
|
- pattern: "^\\w+-\\w+.*"
|
||||||
replace: '[JIRA $0] '`,
|
replace: '[JIRA $0] '
|
||||||
|
`,
|
||||||
}, {
|
}, {
|
||||||
name: "Complicated CommitPrefixes Rename",
|
name: "Complicated CommitPrefixes Rename",
|
||||||
input: `
|
input: `git:
|
||||||
git:
|
|
||||||
commitPrefixes:
|
commitPrefixes:
|
||||||
foo:
|
foo:
|
||||||
pattern: "^\\w+-\\w+.*"
|
pattern: "^\\w+-\\w+.*"
|
||||||
replace: '[OTHER $0] '
|
replace: '[OTHER $0] '
|
||||||
CrazyName!@#$^*&)_-)[[}{f{[]:
|
CrazyName!@#$^*&)_-)[[}{f{[]:
|
||||||
pattern: "^foo.bar*"
|
pattern: "^foo.bar*"
|
||||||
replace: '[FUN $0] '`,
|
replace: '[FUN $0] '
|
||||||
expected: `
|
`,
|
||||||
git:
|
expected: `git:
|
||||||
commitPrefixes:
|
commitPrefixes:
|
||||||
foo:
|
foo:
|
||||||
- pattern: "^\\w+-\\w+.*"
|
- pattern: "^\\w+-\\w+.*"
|
||||||
replace: '[OTHER $0] '
|
replace: '[OTHER $0] '
|
||||||
CrazyName!@#$^*&)_-)[[}{f{[]:
|
CrazyName!@#$^*&)_-)[[}{f{[]:
|
||||||
- pattern: "^foo.bar*"
|
- pattern: "^foo.bar*"
|
||||||
replace: '[FUN $0] '`,
|
replace: '[FUN $0] '
|
||||||
|
`,
|
||||||
}, {
|
}, {
|
||||||
name: "Incomplete Configuration",
|
name: "Incomplete Configuration",
|
||||||
input: "git:",
|
input: "git:",
|
||||||
@ -58,21 +57,11 @@ git:
|
|||||||
|
|
||||||
for _, s := range scenarios {
|
for _, s := range scenarios {
|
||||||
t.Run(s.name, func(t *testing.T) {
|
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))
|
actual, err := computeMigratedConfig("path doesn't matter", []byte(s.input))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
actualConfig := GetDefaultConfig()
|
assert.Equal(t, s.expected, string(actual))
|
||||||
err = yaml.Unmarshal(actual, actualConfig)
|
|
||||||
if err != nil {
|
|
||||||
t.Error(err)
|
|
||||||
}
|
|
||||||
assert.Equal(t, expectedConfig, actualConfig)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user