Developing lightweight computation at the DSG edge

antidoteclient_test.go 686 Bytes
Newer Older
Peter Zeller's avatar
Peter Zeller committed
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
package antidoteclient

//import "fmt"
import (
	"testing"
	"fmt"
)

func TestSimple(t *testing.T) {

	client, err := NewClient(Host{"127.0.0.1", 8087})
	if err != nil {
		t.Fatal(err)
	}

	tx, err := client.StartTransaction()
	if err != nil {
		t.Fatal(err)
	}
	crdtType := CRDTType_COUNTER
	key := &ApbBoundObject{
		Bucket: []byte("bucket"),
		Key:    []byte("key"),
		Type:   &crdtType}
	one := int64(1)
	tx.update(&ApbUpdateOp{
		Boundobject: key,
		Operation:   &ApbUpdateOperation{Counterop: &ApbCounterUpdate{Inc: &one}},
	})
	resp, err := tx.read(key)
	if err != nil {
		t.Fatal(err)
	}

	fmt.Print(resp.Objects[0])

	_, err = tx.commit()
	if err != nil {
		t.Fatal(err)
	}

}