-
Notifications
You must be signed in to change notification settings - Fork 3
/
computeResourcesStorage_test.go
50 lines (40 loc) · 1.36 KB
/
computeResourcesStorage_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package solus
import (
"context"
"net/http"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestComputeResourcesService_StorageCreate(t *testing.T) {
data := ComputeResourceStorageCreateRequest{
Type: StorageTypeNameFB,
Path: "fake path",
ThinPool: "fake thinpool",
IsAvailableForBalancing: true,
}
s := startTestServer(t, func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/compute_resources/42/storages", r.URL.Path)
assert.Equal(t, http.MethodPost, r.Method)
assertRequestBody(t, r, data)
writeResponse(t, w, http.StatusCreated, fakeStorage)
})
defer s.Close()
actual, err := createTestClient(t, s.URL).ComputeResources.StorageCreate(context.Background(), 42, data)
require.NoError(t, err)
require.Equal(t, fakeStorage, actual)
}
func TestComputeResourcesService_StorageList(t *testing.T) {
expected := []Storage{
fakeStorage,
}
s := startTestServer(t, func(w http.ResponseWriter, r *http.Request) {
assert.Equal(t, "/compute_resources/42/storages", r.URL.Path)
assert.Equal(t, http.MethodGet, r.Method)
writeResponse(t, w, http.StatusOK, expected)
})
defer s.Close()
actual, err := createTestClient(t, s.URL).ComputeResources.StorageList(context.Background(), 42)
require.NoError(t, err)
require.Equal(t, expected, actual)
}