mirror of
https://github.com/vbatts/tar-split.git
synced 2024-11-16 13:28:37 +00:00
check: failing test case for #8
https://github.com/vbatts/go-mtree/issues/8 Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
ac37b23f38
commit
fca9d4b5b6
1 changed files with 44 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
|||
package mtree
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -95,3 +96,46 @@ func ExampleCheck() {
|
|||
// handle failed validity ...
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/vbatts/go-mtree/issues/8
|
||||
func TestTimeComparison(t *testing.T) {
|
||||
dir, err := ioutil.TempDir("", "test-time.")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
// This is the format of time from FreeBSD
|
||||
spec := `
|
||||
/set type=file time=0.000000000
|
||||
. type=dir
|
||||
file time=0.000000000
|
||||
..
|
||||
`
|
||||
|
||||
fh, err := os.Create(filepath.Join(dir, "file"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// This is what mode we're checking for. Round integer of epoch seconds
|
||||
epoch := time.Unix(0, 0)
|
||||
if err := os.Chtimes(fh.Name(), epoch, epoch); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := fh.Close(); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
dh, err := ParseSpec(bytes.NewBufferString(spec))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
res, err := Check(dir, dh, nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
if len(res.Failures) > 0 {
|
||||
t.Fatal(res.Failures)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue