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

	pages := 0

	err := ListBackups(fake.ServiceClient(), instanceID).EachPage(func(page pagination.Page) (bool, error) {
		pages++
		actual, err := backups.ExtractBackups(page)
		th.AssertNoErr(t, err)

		expected := []backups.Backup{
			backups.Backup{
				Created:     timeVal,
				Description: "Backup from Restored Instance",
				ID:          "87972694-4be2-40f5-83f8-501656e0032a",
				InstanceID:  "29af2cd9-0674-48ab-b87a-b160f00208e6",
				LocationRef: "http://localhost/path/to/backup",
				Name:        "restored_backup",
				ParentID:    "",
				Size:        0.141026,
				Status:      "COMPLETED",
				Updated:     timeVal,
				Datastore:   datastores.DatastorePartial{Version: "5.1", Type: "MySQL", VersionID: "20000000-0000-0000-0000-000000000002"},
			},
		}

		th.AssertDeepEquals(t, expected, actual)
		return true, nil
	})

	th.AssertNoErr(t, err)
	th.AssertEquals(t, 1, pages)
}
示例#2
0
func (c *context) listInstanceBackups() {
	c.Logf("Listing backups for instance %s", c.instanceID)

	err := instances.ListBackups(c.client, c.instanceID).EachPage(func(page pagination.Page) (bool, error) {
		backupList, err := backups.ExtractBackups(page)
		c.AssertNoErr(err)

		for _, b := range backupList {
			c.Logf("Backup: %#v", b)
		}

		return true, nil
	})

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

	err := backups.List(c.client, nil).EachPage(func(page pagination.Page) (bool, error) {
		backupList, err := backups.ExtractBackups(page)
		c.AssertNoErr(err)

		for _, b := range backupList {
			c.Logf("Backup: %#v", b)
		}

		return true, nil
	})

	c.AssertNoErr(err)
}