mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Tests for FileSize
This commit is contained in:
parent
f084cea292
commit
fe9ccb8677
1 changed files with 21 additions and 3 deletions
|
@ -6,10 +6,28 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSplitFile(t *testing.T) {
|
func TestSplitFile(t *testing.T) {
|
||||||
err := SplitFile("README.md", 3)
|
err := SplitFile("testing_data/README.md", 3)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
}
|
}
|
||||||
os.Remove("README.md.0")
|
os.Remove("testing_data/README.md.0")
|
||||||
os.Remove("README.md.1")
|
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue