mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
Test appending to empty file
This commit is contained in:
parent
57f86b8f90
commit
fdf6a9cc2b
1 changed files with 19 additions and 1 deletions
|
@ -142,6 +142,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
path string
|
path string
|
||||||
setup func(string)
|
setup func(string)
|
||||||
|
test func(string)
|
||||||
}
|
}
|
||||||
|
|
||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
|
@ -152,6 +153,20 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
func(output string) {
|
||||||
|
assert.EqualValues(t, "hello\nworld\n", output)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
filepath.Join(os.TempDir(), "emptyTestFile"),
|
||||||
|
func(path string) {
|
||||||
|
if err := ioutil.WriteFile(path, []byte(""), 0o600); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
func(output string) {
|
||||||
|
assert.EqualValues(t, "world\n", output)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
filepath.Join(os.TempDir(), "testFileWithNewline"),
|
filepath.Join(os.TempDir(), "testFileWithNewline"),
|
||||||
|
@ -160,6 +175,9 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
func(output string) {
|
||||||
|
assert.EqualValues(t, "hello\nworld\n", output)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +191,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
assert.EqualValues(t, "hello\nworld\n", string(f))
|
s.test(string(f))
|
||||||
_ = os.RemoveAll(s.path)
|
_ = os.RemoveAll(s.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue