2017-10-21 01:26:04 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-10-24 11:22:30 +02:00
|
|
|
"os"
|
2017-10-21 01:26:04 +02:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestSplitFile(t *testing.T) {
|
2017-10-25 13:49:31 +02:00
|
|
|
err := SplitFile("testing_data/README.md", 3)
|
2017-10-21 01:26:04 +02:00
|
|
|
if err != nil {
|
|
|
|
t.Error(err)
|
|
|
|
}
|
2017-10-25 13:49:31 +02:00
|
|
|
os.Remove("testing_data/README.md.0")
|
|
|
|
os.Remove("testing_data/README.md.1")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestFileSize(t *testing.T) {
|
|
|
|
t.Run("File is ok ", func(t *testing.T) {
|
|
|
|
_, err := FileSize("testing_data/README.md")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("should pass with no error, got: %v", err)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
t.Run("File does not exist", func(t *testing.T) {
|
|
|
|
s, err := FileSize("testing_data/someStrangeFile")
|
|
|
|
if err == nil {
|
|
|
|
t.Error("should return an error")
|
|
|
|
}
|
|
|
|
if s > 0 {
|
|
|
|
t.Errorf("size should be 0, got: %d", s)
|
|
|
|
}
|
|
|
|
})
|
2017-10-21 01:26:04 +02:00
|
|
|
}
|