-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrestore_test.go
More file actions
57 lines (51 loc) · 1.53 KB
/
restore_test.go
File metadata and controls
57 lines (51 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package pitreos
import (
"testing"
"github.com/ghodss/yaml"
"github.com/stretchr/testify/assert"
)
func TestUnmarshal(t *testing.T) {
restoreYAML := `version: v2
date: 2018-08-28T12:55:39.12702167Z
tag: ""
meta: {}
files:
- filename: bigfile
date: 2018-08-28T08:55:39.12702167-04:00
size: 73400320
chunks:
- start: 52428800
end: 73400319
empty: true
- start: 0
end: 52428799
contentSHA: 21fd1fa9da7bda488ea1b3f62e1eae2224c0da73
- filename: data/test.index
date: 2018-08-28T08:55:39.12702167-04:00
size: 62914560
chunks:
- start: 52428800
end: 62914559
contentSHA: 6c592575b37b6d81949b914412bbda1c798b017f
- start: 0
end: 52428799
contentSHA: acd9c9ac1c23aafa19151e354bb23e2e3a01c007
- filename: sparse.file
date: 2018-08-28T08:55:39.12702167-04:00
size: 5009
chunks:
- start: 0
end: 5008
contentSHA: 73886020c8cdb0e7210f54a8d988387961171f90
`
cnt := []byte(restoreYAML)
var bi *BackupIndex
if err := yaml.Unmarshal(cnt, &bi); err != nil {
t.Errorf("Unmarshal failed with %s\n", err)
}
assert.Equal(t, bi.Files[0].Chunks[0].IsEmpty, true, "Chunk 0 should be empty")
assert.Equal(t, bi.Files[0].Chunks[1].IsEmpty, false, "Chunk 1 should be non-empty")
assert.Equal(t, bi.Files[0].Chunks[0].Start, int64(52428800), "Chunk 0 should start at 52428800")
assert.Equal(t, bi.Files[0].Chunks[1].End, int64(52428799), "Chunk 1 should end at 52428799")
assert.Equal(t, bi.Files[0].Chunks[1].ContentSHA, "21fd1fa9da7bda488ea1b3f62e1eae2224c0da73", "Chunk 1 should sha incorrectly decoded")
}