File: postgresql_test.go

package info (click to toggle)
golang-github-azure-azure-sdk-for-go 10.3.0~beta-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, experimental
  • size: 15,936 kB
  • ctags: 22,331
  • sloc: sh: 33; makefile: 8
file content (68 lines) | stat: -rw-r--r-- 1,604 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package postgresql

import (
	"encoding/json"
	"testing"

	"github.com/Azure/go-autorest/autorest/to"
	chk "gopkg.in/check.v1"
)

// Hook up gocheck to testing
func Test(t *testing.T) { chk.TestingT(t) }

type Suite struct{}

var _ = chk.Suite(&Suite{})

var (
	body = `{
    "sku": {
        "name": "SkuName",
        "tier": "Basic",
        "capacity": 100
    },
    "properties": {
        "createMode": "Default",
        "storageMB": 1024,
        "sslEnforcement": "Enabled",
        "administratorLogin": "cloudsa",
        "administratorLoginPassword": "password"
    },
    "location": "OneBox",
    "tags": {
        "ElasticServer": "1"
    }
}`
	sfc = ServerForCreate{
		Location: to.StringPtr("OneBox"),
		Properties: ServerPropertiesForDefaultCreate{
			AdministratorLogin:         to.StringPtr("cloudsa"),
			AdministratorLoginPassword: to.StringPtr("password"),
			StorageMB:                  to.Int64Ptr(1024),
			SslEnforcement:             SslEnforcementEnumEnabled,
			CreateMode:                 CreateModeDefault,
		},
		Sku: &Sku{
			Name:     to.StringPtr("SkuName"),
			Tier:     Basic,
			Capacity: to.Int32Ptr(100),
		},
		Tags: &map[string]*string{
			"ElasticServer": to.StringPtr("1"),
		},
	}
)

func (s *Suite) TestUnmarshalServerForCreate(c *chk.C) {
	var obtained ServerForCreate
	err := json.Unmarshal([]byte(body), &obtained)
	c.Assert(err, chk.IsNil)
	c.Assert(obtained, chk.DeepEquals, sfc)
}

func (s *Suite) TestMarshalServerForCreate(c *chk.C) {
	b, err := json.MarshalIndent(sfc, "", "    ")
	c.Assert(err, chk.IsNil)
	c.Assert(string(b), chk.Equals, body)
}