提交 ab6b1fea 编写于 作者: M Mislav Marohnić

Remove obsolete tests

上级 2e47a2d7
......@@ -8,24 +8,6 @@ import (
"github.com/bmizerany/assert"
)
func TestReadMsg(t *testing.T) {
title, body := readMsg("")
assert.Equal(t, "", title)
assert.Equal(t, "", body)
title, body = readMsg("my pull title")
assert.Equal(t, "my pull title", title)
assert.Equal(t, "", body)
title, body = readMsg("my pull title\n\nmy description\n\nanother line")
assert.Equal(t, "my pull title", title)
assert.Equal(t, "my description\n\nanother line", body)
title, body = readMsg("my pull\ntitle\n\nmy description\n\nanother line")
assert.Equal(t, "my pull title", title)
assert.Equal(t, "my description\n\nanother line", body)
}
func TestDirIsNotEmpty(t *testing.T) {
dir := createTempDir(t)
defer os.RemoveAll(dir)
......
package github
import (
"bufio"
"fmt"
"io/ioutil"
"os"
"strings"
"testing"
"github.com/bmizerany/assert"
......@@ -78,85 +76,3 @@ func TestEditor_openAndEdit_writeFileIfNotExist(t *testing.T) {
assert.Equal(t, nil, err)
assert.Equal(t, "hello", string(content))
}
func TestEditor_EditTitleAndBodyEmptyTitle(t *testing.T) {
tempFile, _ := ioutil.TempFile("", "PULLREQ")
tempFile.Close()
editor := Editor{
Program: "memory",
File: tempFile.Name(),
CS: "#",
openEditor: func(program string, file string) error {
assert.Equal(t, "memory", program)
assert.Equal(t, tempFile.Name(), file)
return ioutil.WriteFile(file, []byte(""), 0644)
},
}
title, body, err := editor.EditTitleAndBody()
assert.Equal(t, nil, err)
assert.Equal(t, "", title)
assert.Equal(t, "", body)
_, err = os.Stat(tempFile.Name())
assert.T(t, os.IsNotExist(err))
}
func TestEditor_EditTitleAndBody(t *testing.T) {
tempFile, _ := ioutil.TempFile("", "PULLREQ")
tempFile.Close()
editor := Editor{
Program: "memory",
File: tempFile.Name(),
CS: "#",
openEditor: func(program string, file string) error {
assert.Equal(t, "memory", program)
assert.Equal(t, tempFile.Name(), file)
message := `A title
A title continues
A body
A body continues
# comment
`
return ioutil.WriteFile(file, []byte(message), 0644)
},
}
title, body, err := editor.EditTitleAndBody()
assert.Equal(t, nil, err)
assert.Equal(t, "A title A title continues", title)
assert.Equal(t, "A body\nA body continues", body)
}
func TestReadTitleAndBody(t *testing.T) {
message := `A title
A title continues
A body
A body continues
# comment
`
r := strings.NewReader(message)
reader := bufio.NewReader(r)
title, body, err := readTitleAndBody(reader, "#")
assert.Equal(t, nil, err)
assert.Equal(t, "A title A title continues", title)
assert.Equal(t, "A body\nA body continues", body)
message = `# Dat title
/ This line is commented out.
Dem body.
`
r = strings.NewReader(message)
reader = bufio.NewReader(r)
title, body, err = readTitleAndBody(reader, "/")
assert.Equal(t, nil, err)
assert.Equal(t, "# Dat title", title)
assert.Equal(t, "Dem body.", body)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册