github.com/equinox-io/equinox@v1.2.1-0.20200723040547-60ffe7f858fe/sdk_ctx_test.go (about)

     1  // +build go1.7
     2  
     3  package equinox
     4  
     5  import (
     6  	"bytes"
     7  	"context"
     8  	"io/ioutil"
     9  	"testing"
    10  	"time"
    11  
    12  	"github.com/equinox-io/equinox/proto"
    13  )
    14  
    15  func TestEndToEndContext(t *testing.T) {
    16  	opts := setup(t, "TestEndtoEnd", proto.Response{
    17  		Available: true,
    18  		Release: proto.Release{
    19  			Version:     "0.1.2.3",
    20  			Title:       "Release Title",
    21  			Description: "Release Description",
    22  			CreateDate:  time.Now(),
    23  		},
    24  		Checksum:  newSHA,
    25  		Signature: signature,
    26  	})
    27  	defer cleanup(opts)
    28  
    29  	resp, err := CheckContext(context.Background(), fakeAppID, opts)
    30  	if err != nil {
    31  		t.Fatalf("Failed check: %v", err)
    32  	}
    33  	err = resp.ApplyContext(context.Background())
    34  	if err != nil {
    35  		t.Fatalf("Failed apply: %v", err)
    36  	}
    37  
    38  	buf, err := ioutil.ReadFile(opts.TargetPath)
    39  	if err != nil {
    40  		t.Fatalf("Failed to read file: %v", err)
    41  	}
    42  	if !bytes.Equal(buf, newFakeBinary) {
    43  		t.Fatalf("Binary did not update to new expected value. Got %v, expected %v", buf, newFakeBinary)
    44  	}
    45  }