vendor: switch to using go1.11 modules

This commit is contained in:
Nick Craig-Wood
2018-08-28 16:08:48 +01:00
parent 5c75453aba
commit da1682a30e
6142 changed files with 390 additions and 5155875 deletions
-29
View File
@@ -1,29 +0,0 @@
package times
import (
"os"
"testing"
)
func BenchmarkGet(t *testing.B) {
fileTest(t, func(f *os.File) {
fi, err := os.Stat(f.Name())
if err != nil {
t.Error(err)
}
for i := 0; i < t.N; i++ {
Get(fi)
}
})
t.ReportAllocs()
}
func BenchmarkStat(t *testing.B) {
fileTest(t, func(f *os.File) {
for i := 0; i < t.N; i++ {
Stat(f.Name())
}
})
t.ReportAllocs()
}
-65
View File
@@ -1,65 +0,0 @@
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()
}()
}
-50
View File
@@ -1,50 +0,0 @@
package times
import (
"io/ioutil"
"os"
"testing"
"time"
)
type timeRange struct {
start time.Time
end time.Time
}
func newInterval(t time.Time, dur time.Duration) timeRange {
return timeRange{start: t.Add(-dur), end: t.Add(dur)}
}
func (t timeRange) Contains(findTime time.Time) bool {
return !findTime.Before(t.start) && !findTime.After(t.end)
}
// creates a file and cleans it up after the test is run.
func fileTest(t testing.TB, testFunc func(f *os.File)) {
f, err := ioutil.TempFile("", "")
if err != nil {
t.Error(err)
}
defer os.Remove(f.Name())
defer f.Close()
testFunc(f)
}
func timespecTest(ts Timespec, r timeRange, t testing.TB) {
if !r.Contains(ts.AccessTime()) {
t.Errorf("expected %s to be in range: %s\n", ts.AccessTime(), r.start)
}
if !r.Contains(ts.ModTime()) {
t.Errorf("expected %s to be in range: %s\n", ts.ModTime(), r.start)
}
if ts.HasChangeTime() && !r.Contains(ts.ChangeTime()) {
t.Errorf("expected %s to be in range: %s\n", ts.ChangeTime(), r.start)
}
if ts.HasBirthTime() && !r.Contains(ts.BirthTime()) {
t.Errorf("expected %s to be in range: %s\n", ts.BirthTime(), r.start)
}
}