mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
chore: remove dead code
This commit is contained in:
parent
e35ab3c5fe
commit
2fbb52fa2c
2 changed files with 0 additions and 54 deletions
|
@ -117,27 +117,6 @@ func (c *OSCommand) AppendLineToFile(filename, line string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateTempFile writes a string to a new temp file and returns the file's name
|
|
||||||
func (c *OSCommand) CreateTempFile(filename, content string) (string, error) {
|
|
||||||
tmpfile, err := ioutil.TempFile("", filename)
|
|
||||||
if err != nil {
|
|
||||||
c.Log.Error(err)
|
|
||||||
return "", utils.WrapError(err)
|
|
||||||
}
|
|
||||||
c.LogCommand(fmt.Sprintf("Creating temp file '%s'", tmpfile.Name()), false)
|
|
||||||
|
|
||||||
if _, err := tmpfile.WriteString(content); err != nil {
|
|
||||||
c.Log.Error(err)
|
|
||||||
return "", utils.WrapError(err)
|
|
||||||
}
|
|
||||||
if err := tmpfile.Close(); err != nil {
|
|
||||||
c.Log.Error(err)
|
|
||||||
return "", utils.WrapError(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return tmpfile.Name(), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// CreateFileWithContent creates a file with the given content
|
// CreateFileWithContent creates a file with the given content
|
||||||
func (c *OSCommand) CreateFileWithContent(path string, content string) error {
|
func (c *OSCommand) CreateFileWithContent(path string, content string) error {
|
||||||
c.LogCommand(fmt.Sprintf("Creating file '%s'", path), false)
|
c.LogCommand(fmt.Sprintf("Creating file '%s'", path), false)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package oscommands
|
package oscommands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -164,35 +163,3 @@ func TestOSCommandFileType(t *testing.T) {
|
||||||
_ = os.RemoveAll(s.path)
|
_ = os.RemoveAll(s.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOSCommandCreateTempFile(t *testing.T) {
|
|
||||||
type scenario struct {
|
|
||||||
testName string
|
|
||||||
filename string
|
|
||||||
content string
|
|
||||||
test func(string, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
scenarios := []scenario{
|
|
||||||
{
|
|
||||||
"valid case",
|
|
||||||
"filename",
|
|
||||||
"content",
|
|
||||||
func(path string, err error) {
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(path)
|
|
||||||
assert.NoError(t, err)
|
|
||||||
|
|
||||||
assert.Equal(t, "content", string(content))
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, s := range scenarios {
|
|
||||||
s := s
|
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
|
||||||
s.test(NewDummyOSCommand().CreateTempFile(s.filename, s.content))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue