|
|
@@ -1,6 +1,7 @@
|
|
|
package model
|
|
|
|
|
|
import (
|
|
|
+ "os"
|
|
|
"reflect"
|
|
|
"testing"
|
|
|
"time"
|
|
|
@@ -27,24 +28,34 @@ func TestNewModel(t *testing.T) {
|
|
|
var testDataExpected = map[string]File{
|
|
|
"foo": File{
|
|
|
Name: "foo",
|
|
|
- Flags: 0644,
|
|
|
- Modified: 1384244572,
|
|
|
+ Flags: 0,
|
|
|
+ Modified: 0,
|
|
|
Blocks: []Block{{Offset: 0x0, Length: 0x7, Hash: []uint8{0xae, 0xc0, 0x70, 0x64, 0x5f, 0xe5, 0x3e, 0xe3, 0xb3, 0x76, 0x30, 0x59, 0x37, 0x61, 0x34, 0xf0, 0x58, 0xcc, 0x33, 0x72, 0x47, 0xc9, 0x78, 0xad, 0xd1, 0x78, 0xb6, 0xcc, 0xdf, 0xb0, 0x1, 0x9f}}},
|
|
|
},
|
|
|
"bar": File{
|
|
|
Name: "bar",
|
|
|
- Flags: 0644,
|
|
|
- Modified: 1384244579,
|
|
|
+ Flags: 0,
|
|
|
+ Modified: 0,
|
|
|
Blocks: []Block{{Offset: 0x0, Length: 0xa, Hash: []uint8{0x2f, 0x72, 0xcc, 0x11, 0xa6, 0xfc, 0xd0, 0x27, 0x1e, 0xce, 0xf8, 0xc6, 0x10, 0x56, 0xee, 0x1e, 0xb1, 0x24, 0x3b, 0xe3, 0x80, 0x5b, 0xf9, 0xa9, 0xdf, 0x98, 0xf9, 0x2f, 0x76, 0x36, 0xb0, 0x5c}}},
|
|
|
},
|
|
|
"baz/quux": File{
|
|
|
Name: "baz/quux",
|
|
|
- Flags: 0644,
|
|
|
- Modified: 1384244676,
|
|
|
+ Flags: 0,
|
|
|
+ Modified: 0,
|
|
|
Blocks: []Block{{Offset: 0x0, Length: 0x9, Hash: []uint8{0xc1, 0x54, 0xd9, 0x4e, 0x94, 0xba, 0x72, 0x98, 0xa6, 0xad, 0xb0, 0x52, 0x3a, 0xfe, 0x34, 0xd1, 0xb6, 0xa5, 0x81, 0xd6, 0xb8, 0x93, 0xa7, 0x63, 0xd4, 0x5d, 0xdc, 0x5e, 0x20, 0x9d, 0xcb, 0x83}}},
|
|
|
},
|
|
|
}
|
|
|
|
|
|
+func init() {
|
|
|
+ // Fix expected test data to match reality
|
|
|
+ for n, f := range testDataExpected {
|
|
|
+ fi, _ := os.Stat("testdata/" + n)
|
|
|
+ f.Flags = uint32(fi.Mode())
|
|
|
+ f.Modified = fi.ModTime().Unix()
|
|
|
+ testDataExpected[n] = f
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func TestUpdateLocal(t *testing.T) {
|
|
|
m := NewModel("testdata")
|
|
|
fs := m.Walk(false)
|