forked from nilslice/protolock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder_test.go
More file actions
40 lines (29 loc) · 808 Bytes
/
order_test.go
File metadata and controls
40 lines (29 loc) · 808 Bytes
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
package protolock
import (
"encoding/json"
"os"
"testing"
"github.com/stretchr/testify/assert"
)
const ignoreArg = ""
func TestOrder(t *testing.T) {
cfg, err := NewConfig(".", ".", ignoreArg, false, false)
assert.NoError(t, err)
// verify that the re-production of the same Protolock encoded as json
// is equivalent to any previously encoded version of the same Protolock
f, err := os.Open(cfg.LockFilePath())
assert.NoError(t, err)
current, err := FromReader(f)
assert.NoError(t, err)
r, err := Commit(*cfg)
assert.NoError(t, err)
assert.NotNil(t, r)
updated, err := FromReader(r)
assert.NoError(t, err)
assert.Equal(t, current, updated)
a, err := json.Marshal(current)
assert.NoError(t, err)
b, err := json.Marshal(updated)
assert.NoError(t, err)
assert.Equal(t, a, b)
}