13994: Fix import cycle.
[arvados.git] / sdk / go / arvados / config_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: Apache-2.0
4
5 package arvados
6
7 import (
8         "github.com/ghodss/yaml"
9         check "gopkg.in/check.v1"
10 )
11
12 var _ = check.Suite(&ConfigSuite{})
13
14 type ConfigSuite struct{}
15
16 func (s *ConfigSuite) TestInstanceTypesAsArray(c *check.C) {
17         var cluster Cluster
18         yaml.Unmarshal([]byte("InstanceTypes:\n- Name: foo\n"), &cluster)
19         c.Check(len(cluster.InstanceTypes), check.Equals, 1)
20         c.Check(cluster.InstanceTypes["foo"].Name, check.Equals, "foo")
21 }
22
23 func (s *ConfigSuite) TestInstanceTypesAsHash(c *check.C) {
24         var cluster Cluster
25         yaml.Unmarshal([]byte("InstanceTypes:\n  foo:\n    ProviderType: bar\n"), &cluster)
26         c.Check(len(cluster.InstanceTypes), check.Equals, 1)
27         c.Check(cluster.InstanceTypes["foo"].Name, check.Equals, "foo")
28         c.Check(cluster.InstanceTypes["foo"].ProviderType, check.Equals, "bar")
29 }
30
31 func (s *ConfigSuite) TestInstanceTypeSize(c *check.C) {
32         var it InstanceType
33         err := yaml.Unmarshal([]byte("Name: foo\nScratch: 4GB\nRAM: 4GiB\n"), &it)
34         c.Check(err, check.IsNil)
35         c.Check(int64(it.Scratch), check.Equals, int64(4000000000))
36         c.Check(int64(it.RAM), check.Equals, int64(4294967296))
37 }