mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-31 23:19:40 +02:00
Add tests for migration of renamed keys
This commit is contained in:
parent
0249d4c8ab
commit
df805f3a1a
@ -6,6 +6,67 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestMigrationOfRenamedKeys(t *testing.T) {
|
||||||
|
scenarios := []struct {
|
||||||
|
name string
|
||||||
|
input string
|
||||||
|
expected string
|
||||||
|
expectedDidChange bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Empty String",
|
||||||
|
input: "",
|
||||||
|
expectedDidChange: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "No rename needed",
|
||||||
|
input: `foo:
|
||||||
|
bar: 5
|
||||||
|
`,
|
||||||
|
expectedDidChange: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Rename one",
|
||||||
|
input: `gui:
|
||||||
|
skipUnstageLineWarning: true
|
||||||
|
`,
|
||||||
|
expected: `gui:
|
||||||
|
skipDiscardChangeWarning: true
|
||||||
|
`,
|
||||||
|
expectedDidChange: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Rename several",
|
||||||
|
input: `gui:
|
||||||
|
windowSize: half
|
||||||
|
skipUnstageLineWarning: true
|
||||||
|
keybinding:
|
||||||
|
universal:
|
||||||
|
executeCustomCommand: a
|
||||||
|
`,
|
||||||
|
expected: `gui:
|
||||||
|
screenMode: half
|
||||||
|
skipDiscardChangeWarning: true
|
||||||
|
keybinding:
|
||||||
|
universal:
|
||||||
|
executeShellCommand: a
|
||||||
|
`,
|
||||||
|
expectedDidChange: true,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, s := range scenarios {
|
||||||
|
t.Run(s.name, func(t *testing.T) {
|
||||||
|
actual, didChange, err := computeMigratedConfig("path doesn't matter", []byte(s.input))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
assert.Equal(t, s.expectedDidChange, didChange)
|
||||||
|
if didChange {
|
||||||
|
assert.Equal(t, s.expected, string(actual))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCommitPrefixMigrations(t *testing.T) {
|
func TestCommitPrefixMigrations(t *testing.T) {
|
||||||
scenarios := []struct {
|
scenarios := []struct {
|
||||||
name string
|
name string
|
||||||
|
Loading…
x
Reference in New Issue
Block a user