vendor: vfs add vendor/github.com/djherbis/times

This commit is contained in:
Nick Craig-Wood
2017-11-20 12:36:50 +00:00
parent e946a8eab0
commit bb0ce0cb5f
20 changed files with 828 additions and 1 deletions
+65
View File
@@ -0,0 +1,65 @@
package times
import (
"os"
"testing"
"time"
)
func TestStat(t *testing.T) {
fileTest(t, func(f *os.File) {
ts, err := Stat(f.Name())
if err != nil {
t.Error(err.Error())
}
timespecTest(ts, newInterval(time.Now(), time.Second), t)
})
}
func TestGet(t *testing.T) {
fileTest(t, func(f *os.File) {
fi, err := os.Stat(f.Name())
if err != nil {
t.Error(err.Error())
}
timespecTest(Get(fi), newInterval(time.Now(), time.Second), t)
})
}
func TestStatErr(t *testing.T) {
_, err := Stat("badfile?")
if err == nil {
t.Error("expected an error")
}
}
func TestCheat(t *testing.T) {
// not all times are available for all platforms
// this allows us to get 100% test coverage for platforms which do not have
// ChangeTime/BirthTime
var c ctime
if c.HasChangeTime() {
c.ChangeTime()
}
var b btime
if b.HasBirthTime() {
b.BirthTime()
}
var nc noctime
func() {
if !nc.HasChangeTime() {
defer func() { recover() }()
}
nc.ChangeTime()
}()
var nb nobtime
func() {
if !nb.HasBirthTime() {
defer func() { recover() }()
}
nb.BirthTime()
}()
}