You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
397 B
Go
28 lines
397 B
Go
4 years ago
|
package iox
|
||
|
|
||
|
import (
|
||
|
"io/ioutil"
|
||
|
"os"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestCountLines(t *testing.T) {
|
||
|
const val = `1
|
||
|
2
|
||
|
3
|
||
|
4`
|
||
|
file, err := ioutil.TempFile(os.TempDir(), "test-")
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
defer os.Remove(file.Name())
|
||
|
|
||
|
file.WriteString(val)
|
||
|
file.Close()
|
||
|
lines, err := CountLines(file.Name())
|
||
|
assert.Nil(t, err)
|
||
|
assert.Equal(t, 4, lines)
|
||
|
}
|