示例#1
0
func TestListInstances(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	fixture.SetupHandler(t, resURL+"/instances", "GET", "", ListInstancesJSON, 200)

	expectedInstance := instances.Instance{
		ID:   "d4603f69-ec7e-4e9b-803f-600b9205576f",
		Name: "json_rack_instance",
	}

	pages := 0
	err := ListInstances(fake.ServiceClient(), configID).EachPage(func(page pagination.Page) (bool, error) {
		pages++

		actual, err := instances.ExtractInstances(page)
		if err != nil {
			return false, err
		}

		th.AssertDeepEquals(t, actual, []instances.Instance{expectedInstance})

		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, pages)
}
示例#2
0
func (c *context) listConfigGrpInstances() {
	c.Logf("Listing all instances associated with config group %s", c.configGroupID)

	err := config.ListInstances(c.client, c.configGroupID).EachPage(func(page pagination.Page) (bool, error) {
		instanceList, err := instances.ExtractInstances(page)
		c.AssertNoErr(err)

		for _, instance := range instanceList {
			c.Logf("Instance: %#v", instance)
		}

		return true, nil
	})

	c.AssertNoErr(err)
}
示例#3
0
func (c *context) listInstances() {
	c.Logf("Listing instances")

	err := instances.List(c.client, nil).EachPage(func(page pagination.Page) (bool, error) {
		instanceList, err := instances.ExtractInstances(page)
		c.AssertNoErr(err)

		for _, i := range instanceList {
			c.Logf("Instance: ID [%s] Name [%s] Status [%s] VolSize [%d] Datastore Type [%s]",
				i.ID, i.Name, i.Status, i.Volume.Size, i.Datastore.Type)
		}

		return true, nil
	})

	c.AssertNoErr(err)
}