11546: Wrap lock/unlock in transactions.
[arvados.git] / services / keep-balance / change_set_test.go
1 package main
2
3 import (
4         "encoding/json"
5
6         "git.curoverse.com/arvados.git/sdk/go/arvados"
7
8         check "gopkg.in/check.v1"
9 )
10
11 var _ = check.Suite(&changeSetSuite{})
12
13 type changeSetSuite struct{}
14
15 func (s *changeSetSuite) TestJSONFormat(c *check.C) {
16         srv := &KeepService{
17                 KeepService: arvados.KeepService{
18                         UUID:           "zzzzz-bi6l4-000000000000001",
19                         ServiceType:    "disk",
20                         ServiceSSLFlag: false,
21                         ServiceHost:    "keep1.zzzzz.arvadosapi.com",
22                         ServicePort:    25107}}
23
24         buf, err := json.Marshal([]Pull{{
25                 SizedDigest: arvados.SizedDigest("acbd18db4cc2f85cedef654fccc4a4d8+3"),
26                 Source:      srv}})
27         c.Check(err, check.IsNil)
28         c.Check(string(buf), check.Equals, `[{"locator":"acbd18db4cc2f85cedef654fccc4a4d8","servers":["http://keep1.zzzzz.arvadosapi.com:25107"]}]`)
29
30         buf, err = json.Marshal([]Trash{{
31                 SizedDigest: arvados.SizedDigest("acbd18db4cc2f85cedef654fccc4a4d8+3"),
32                 Mtime:       123456789}})
33         c.Check(err, check.IsNil)
34         c.Check(string(buf), check.Equals, `[{"locator":"acbd18db4cc2f85cedef654fccc4a4d8","block_mtime":123456789}]`)
35 }