-
Notifications
You must be signed in to change notification settings - Fork 15
/
sdk_ctx_test.go
45 lines (39 loc) · 955 Bytes
/
sdk_ctx_test.go
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
// +build go1.7
package equinox
import (
"bytes"
"context"
"io/ioutil"
"testing"
"time"
"github.com/equinox-io/equinox/proto"
)
func TestEndToEndContext(t *testing.T) {
opts := setup(t, "TestEndtoEnd", proto.Response{
Available: true,
Release: proto.Release{
Version: "0.1.2.3",
Title: "Release Title",
Description: "Release Description",
CreateDate: time.Now(),
},
Checksum: newSHA,
Signature: signature,
})
defer cleanup(opts)
resp, err := CheckContext(context.Background(), fakeAppID, opts)
if err != nil {
t.Fatalf("Failed check: %v", err)
}
err = resp.ApplyContext(context.Background())
if err != nil {
t.Fatalf("Failed apply: %v", err)
}
buf, err := ioutil.ReadFile(opts.TargetPath)
if err != nil {
t.Fatalf("Failed to read file: %v", err)
}
if !bytes.Equal(buf, newFakeBinary) {
t.Fatalf("Binary did not update to new expected value. Got %v, expected %v", buf, newFakeBinary)
}
}