Ejemplo n.º 1
0
func TestUnmarshalling(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "error_creating_response.json")
	rsp := &ErrorResponse{}
	e := json.Unmarshal(f, rsp)
	assert.Nil(t, e)
	t.Log(rsp.Result)

	f = testhelpers.MustReadFixture(t, "no_module_response.json")
	rsp = &ErrorResponse{}
	e = json.Unmarshal(f, rsp)
	assert.Nil(t, e)
	t.Log(rsp.Result)

}
Ejemplo n.º 2
0
func TestAccountAliases(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "list_account_aliases.xml")
	rsp := &ListAccountAliasesResponse{}
	e := xml.Unmarshal(f, rsp)
	assert.Nil(t, e)
	assert.NotNil(t, f)
	assert.Equal(t, len(rsp.AccountAliases), 1)
	assert.Equal(t, rsp.AccountAliases[0], "foocorporation")
}
Ejemplo n.º 3
0
func TestListUsers(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "list_users.xml")
	rsp := &ListUsersResponse{}
	e := xml.Unmarshal(f, rsp)
	assert.Nil(t, e)
	assert.NotNil(t, f)
	assert.Equal(t, len(rsp.Users), 2)
	assert.Equal(t, rsp.Users[0].UserName, "Andrew")
}
Ejemplo n.º 4
0
func TestGetUser(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "get_user.xml")
	rsp := &GetUserResponse{}
	e := xml.Unmarshal(f, rsp)
	assert.Nil(t, e)
	assert.NotNil(t, f)
	user := rsp.User
	assert.Equal(t, user.Path, "/division_abc/subdivision_xyz/")
	assert.Equal(t, user.UserName, "Bob")
	assert.Contains(t, user.Arn, "arn:aws:iam::123456789012:user/division_abc/subdivision_xyz/Bob")
}
Ejemplo n.º 5
0
func TestAccountSummary(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "get_account_summary.xml")
	rsp := &GetAccountSummaryResponse{}
	e := xml.Unmarshal(f, rsp)
	assert.Nil(t, e)
	assert.NotNil(t, f)
	m := rsp.SummaryMap
	assert.Equal(t, len(m.Entries), 14)

	entry := m.Entries[0]
	assert.Equal(t, entry.Key, "Groups")
	assert.Equal(t, entry.Value, "31")
}
Ejemplo n.º 6
0
func TestDistributions(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "distributions.json")
	assert.NotNil(t, f)

	rsp := &DistributionsResponse{}
	e := json.Unmarshal(f, rsp)
	assert.Nil(t, e)
	assert.NotNil(t, rsp)

	assert.Equal(t, len(rsp.DistributionsMap), 2)
	assert.Equal(t, len(rsp.Distributions()), 2)

	dist := rsp.Distributions()[0]
	assert.Equal(t, dist.Name, "CentOS 5.4")
	assert.Equal(t, dist.Key, "centos_5_4_32bit")
}
Ejemplo n.º 7
0
func TestJiffyBoxes(t *testing.T) {
	f := testhelpers.MustReadFixture(t, "jiffyBoxes.json")
	assert.NotNil(t, f)

	rsp := &JiffyBoxesResponse{}
	e := json.Unmarshal(f, rsp)
	assert.Nil(t, e)
	assert.Equal(t, len(rsp.Messages), 0)

	assert.Equal(t, len(rsp.Servers()), 1)

	server := rsp.Server()
	assert.Equal(t, server.Id, 12345)
	assert.Equal(t, server.Name, "Test")
	assert.Equal(t, len(server.Ips), 2)
	assert.Equal(t, server.Ips["public"], []string{"188.93.14.176"})
	assert.Equal(t, server.Status, "READY")

	plan := server.Plan
	assert.Equal(t, plan.Id, 22)
	assert.Equal(t, plan.Name, "CloudLevel 3")
	assert.Equal(t, plan.RamInMB, 8192)

	assert.Equal(t, server.Metadata, map[string]string{
		"createdby": "JiffyBoxTeam",
	})

	ap := server.ActiveProfile
	assert.Equal(t, ap.Name, "Standard")
	assert.Equal(t, ap.Created, 1234567890)

	assert.Equal(t, len(ap.DisksHash), 2)
	assert.Equal(t, len(ap.Disks()), 2)

	disk := ap.DisksHash["xvda"]

	assert.Equal(t, disk.Name, "CentOS 5.4")
	assert.Equal(t, disk.SizeInMB, 81408)
}