-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
increase windows test coverage, and remove platformSpecificStat nonsense
- Loading branch information
Showing
5 changed files
with
109 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package times | ||
|
||
import ( | ||
"errors" | ||
"os" | ||
"syscall" | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestStatFile(t *testing.T) { | ||
fileTest(t, func(f *os.File) { | ||
ts, err := StatFile(f) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
timespecTest(ts, newInterval(time.Now(), time.Second), t) | ||
}) | ||
} | ||
|
||
func TestStatFileErr(t *testing.T) { | ||
fileTest(t, func(f *os.File) { | ||
f.Close() | ||
|
||
_, err := StatFile(f) | ||
if err == nil { | ||
t.Error("got nil err, but err was expected!") | ||
} | ||
}) | ||
} | ||
|
||
func TestStatFileProcErr(t *testing.T) { | ||
fileTest(t, func(f *os.File) { | ||
findProcErr = errors.New("fake error") | ||
defer func() { findProcErr = nil }() | ||
|
||
_, err := StatFile(f) | ||
if err == nil { | ||
t.Error("got nil err, but err was expected!") | ||
} | ||
}) | ||
} | ||
|
||
func TestStatBadNameErr(t *testing.T) { | ||
_, err := platformSpecficStat(string([]byte{0})) | ||
if err != syscall.EINVAL { | ||
t.Error(err) | ||
} | ||
} | ||
|
||
func TestStatProcErrFallback(t *testing.T) { | ||
fileTest(t, func(f *os.File) { | ||
findProcErr = errors.New("fake error") | ||
defer func() { findProcErr = nil }() | ||
|
||
ts, err := Stat(f.Name()) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
timespecTest(ts, newInterval(time.Now(), time.Second), t) | ||
}) | ||
} | ||
|
||
func TestLstatProcErrFallback(t *testing.T) { | ||
fileTest(t, func(f *os.File) { | ||
findProcErr = errors.New("fake error") | ||
defer func() { findProcErr = nil }() | ||
|
||
ts, err := Lstat(f.Name()) | ||
if err != nil { | ||
t.Error(err.Error()) | ||
} | ||
timespecTest(ts, newInterval(time.Now(), time.Second), t) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters