-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed0cb98
commit 5fb3b5c
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package lib | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_Backups_GetBackups_OK(t *testing.T) { | ||
server, client := getTestServerAndClient(http.StatusOK, `{ | ||
"543d340f6dbce": { | ||
"BACKUPID": "543d340f6dbce", | ||
"date_created": "2014-10-13 16:11:46", | ||
"description": "a", | ||
"size": "10000000", | ||
"status": "complete" | ||
}, | ||
"543d34149403a": { | ||
"BACKUPID": "543d34149403a", | ||
"date_created": "2014-10-14 12:40:40", | ||
"description": "Automatic server backup", | ||
"size": "42949672960", | ||
"status": "complete" | ||
} | ||
}`) | ||
defer server.Close() | ||
|
||
snapshots, err := client.GetBackups() | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
if assert.NotNil(t, snapshots) { | ||
assert.Equal(t, 2, len(snapshots)) | ||
|
||
assert.Equal(t, "543d340f6dbce", snapshots[0].ID) | ||
assert.Equal(t, "2014-10-13 16:11:46", snapshots[0].Created) | ||
assert.Equal(t, "a", snapshots[0].Description) | ||
assert.Equal(t, "10000000", snapshots[0].Size) | ||
assert.Equal(t, "complete", snapshots[0].Status) | ||
|
||
assert.Equal(t, "543d34149403a", snapshots[0].ID) | ||
assert.Equal(t, "2014-10-14 12:40:40", snapshots[0].Created) | ||
assert.Equal(t, "Automatic server backup", snapshots[0].Description) | ||
assert.Equal(t, "42949672960", snapshots[0].Size) | ||
assert.Equal(t, "complete", snapshots[0].Status) | ||
} | ||
} |