8784: Fix test for latest firefox.
[arvados.git] / services / keep-balance / main_test.go
1 package main
2
3 import (
4         "time"
5
6         "github.com/ghodss/yaml"
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(yaml.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(yaml.Unmarshal([]byte(`{
25                     "Client": {
26                         "APIHost": "zzzzz.arvadosapi.com:443",
27                         "AuthToken": "xyzzy",
28                         "Insecure": false
29                     },
30                     "KeepServiceList": {
31                         "items": [
32                             {"uuid":"zzzzz-bi64l-abcdefghijklmno", "service_type":"disk", "service_host":"a.zzzzz.arvadosapi.com", "service_port":12345},
33                             {"uuid":"zzzzz-bi64l-bcdefghijklmnop", "service_type":"blob", "service_host":"b.zzzzz.arvadosapi.com", "service_port":12345}
34                         ]
35                     },
36                     "RunPeriod": "600s"
37                 }`), &config), check.IsNil)
38         c.Assert(len(config.KeepServiceList.Items), check.Equals, 2)
39         c.Check(config.KeepServiceList.Items[0].UUID, check.Equals, "zzzzz-bi64l-abcdefghijklmno")
40         c.Check(config.KeepServiceList.Items[0].ServicePort, check.Equals, 12345)
41         c.Check(config.Client.AuthToken, check.Equals, "xyzzy")
42 }