21704: clarified comments
[arvados.git] / services / keep-balance / change_set_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package keepbalance
6
7 import (
8         "encoding/json"
9
10         "git.arvados.org/arvados.git/sdk/go/arvados"
11
12         check "gopkg.in/check.v1"
13 )
14
15 var _ = check.Suite(&changeSetSuite{})
16
17 type changeSetSuite struct{}
18
19 func (s *changeSetSuite) TestJSONFormat(c *check.C) {
20         mnt := &KeepMount{
21                 KeepMount: arvados.KeepMount{
22                         UUID: "zzzzz-mount-abcdefghijklmno"}}
23         srv := &KeepService{
24                 KeepService: arvados.KeepService{
25                         UUID:           "zzzzz-bi6l4-000000000000001",
26                         ServiceType:    "disk",
27                         ServiceSSLFlag: false,
28                         ServiceHost:    "keep1.zzzzz.arvadosapi.com",
29                         ServicePort:    25107}}
30
31         buf, err := json.Marshal([]Pull{{
32                 SizedDigest: arvados.SizedDigest("acbd18db4cc2f85cedef654fccc4a4d8+3"),
33                 To:          mnt,
34                 From:        srv}})
35         c.Check(err, check.IsNil)
36         c.Check(string(buf), check.Equals, `[{"locator":"acbd18db4cc2f85cedef654fccc4a4d8+3","servers":["http://keep1.zzzzz.arvadosapi.com:25107"],"mount_uuid":"zzzzz-mount-abcdefghijklmno"}]`)
37
38         buf, err = json.Marshal([]Trash{{
39                 SizedDigest: arvados.SizedDigest("acbd18db4cc2f85cedef654fccc4a4d8+3"),
40                 From:        mnt,
41                 Mtime:       123456789}})
42         c.Check(err, check.IsNil)
43         c.Check(string(buf), check.Equals, `[{"locator":"acbd18db4cc2f85cedef654fccc4a4d8+3","block_mtime":123456789,"mount_uuid":"zzzzz-mount-abcdefghijklmno"}]`)
44 }