Merge branch '11906-health-check-lib'
[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 main
6
7 import (
8         "encoding/json"
9
10         "git.curoverse.com/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         srv := &KeepService{
21                 KeepService: arvados.KeepService{
22                         UUID:           "zzzzz-bi6l4-000000000000001",
23                         ServiceType:    "disk",
24                         ServiceSSLFlag: false,
25                         ServiceHost:    "keep1.zzzzz.arvadosapi.com",
26                         ServicePort:    25107}}
27
28         buf, err := json.Marshal([]Pull{{
29                 SizedDigest: arvados.SizedDigest("acbd18db4cc2f85cedef654fccc4a4d8+3"),
30                 Source:      srv}})
31         c.Check(err, check.IsNil)
32         c.Check(string(buf), check.Equals, `[{"locator":"acbd18db4cc2f85cedef654fccc4a4d8","servers":["http://keep1.zzzzz.arvadosapi.com:25107"]}]`)
33
34         buf, err = json.Marshal([]Trash{{
35                 SizedDigest: arvados.SizedDigest("acbd18db4cc2f85cedef654fccc4a4d8+3"),
36                 Mtime:       123456789}})
37         c.Check(err, check.IsNil)
38         c.Check(string(buf), check.Equals, `[{"locator":"acbd18db4cc2f85cedef654fccc4a4d8","block_mtime":123456789}]`)
39 }