Skip to content

Commit

Permalink
add backup_test.go file
Browse files Browse the repository at this point in the history
  • Loading branch information
allen-munsch committed Oct 14, 2018
1 parent ed0cb98 commit 5fb3b5c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions lib/backup_test.go
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)
}
}

0 comments on commit 5fb3b5c

Please sign in to comment.