9437: Report timestamps as nanoseconds since epoch in keepstore index.
[arvados.git] / services / keep-balance / main_test.go
1 package main
2
3 import (
4         "encoding/json"
5         "time"
6
7         check "gopkg.in/check.v1"
8 )
9
10 var _ = check.Suite(&mainSuite{})
11
12 type mainSuite struct{}
13
14 func (s *mainSuite) TestExampleJSON(c *check.C) {
15         var config Config
16         c.Check(json.Unmarshal(exampleConfigFile, &config), check.IsNil)
17         c.Check(config.KeepServiceTypes, check.DeepEquals, []string{"disk"})
18         c.Check(config.Client.AuthToken, check.Equals, "xyzzy")
19         c.Check(time.Duration(config.RunPeriod), check.Equals, 600*time.Second)
20 }
21
22 func (s *mainSuite) TestConfigJSONWithKeepServiceList(c *check.C) {
23         var config Config
24         c.Check(json.Unmarshal([]byte(`
25                 {
26                     "Client": {
27                         "APIHost": "zzzzz.arvadosapi.com:443",
28                         "AuthToken": "xyzzy",
29                         "Insecure": false
30                     },
31                     "KeepServiceList": {
32                         "items": [
33                             {"uuid":"zzzzz-bi64l-abcdefghijklmno", "service_type":"disk", "service_host":"a.zzzzz.arvadosapi.com", "service_port":12345},
34                             {"uuid":"zzzzz-bi64l-bcdefghijklmnop", "service_type":"blob", "service_host":"b.zzzzz.arvadosapi.com", "service_port":12345}
35                         ]
36                     },
37                     "RunPeriod": "600s"
38                 }`), &config), check.IsNil)
39         c.Assert(len(config.KeepServiceList.Items), check.Equals, 2)
40         c.Check(config.KeepServiceList.Items[0].UUID, check.Equals, "zzzzz-bi64l-abcdefghijklmno")
41         c.Check(config.KeepServiceList.Items[0].ServicePort, check.Equals, 12345)
42         c.Check(config.Client.AuthToken, check.Equals, "xyzzy")
43 }