From cd0e2cccaa50bdbeee70a5c96c7b19aa021f0123 Mon Sep 17 00:00:00 2001 From: LandonTClipp Date: Thu, 16 Jul 2020 22:29:39 -0500 Subject: [PATCH] Adding tests --- path_test.go | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/path_test.go b/path_test.go index add1a78..f929f4d 100644 --- a/path_test.go +++ b/path_test.go @@ -135,6 +135,39 @@ func (p *PathSuite) TestRenamePath() { assert.False(p.T(), oldFileExists) } +func (p *PathSuite) TestSizeZero() { + file := p.tmpdir.Join("file.txt") + require.NoError(p.T(), file.WriteFile([]byte{}, 0o644)) + size, err := file.Size() + require.NoError(p.T(), err) + p.Zero(size) +} + +func (p *PathSuite) TestSizeNonZero() { + msg := "oh, it's you" + file := p.tmpdir.Join("file.txt") + require.NoError(p.T(), file.WriteFile([]byte(msg), 0o644)) + size, err := file.Size() + require.NoError(p.T(), err) + p.Equal(len(msg), int(size)) +} + +func (p *PathSuite) TestIsDir() { + dir := p.tmpdir.Join("dir") + require.NoError(p.T(), dir.Mkdir(0o755)) + isDir, err := dir.IsDir() + require.NoError(p.T(), err) + p.True(isDir) +} + +func (p *PathSuite) TestIsntDir() { + file := p.tmpdir.Join("file.txt") + require.NoError(p.T(), file.WriteFile([]byte("hello world!"), 0o644)) + isDir, err := file.IsDir() + require.NoError(p.T(), err) + p.False(isDir) +} + func (p *PathSuite) TestGetLatest() { now := time.Now() for i := 0; i < 5; i++ {