Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"fmt" |
| 6 | 5 |
"net/http" |
| 7 | 6 |
"testing" |
| ... | ... |
@@ -16,7 +15,7 @@ import ( |
| 16 | 16 |
func TestDiskUsageError(t *testing.T) {
|
| 17 | 17 |
client, err := New(WithMockClient(errorMock(http.StatusInternalServerError, "Server error"))) |
| 18 | 18 |
assert.NilError(t, err) |
| 19 |
- _, err = client.DiskUsage(context.Background(), DiskUsageOptions{})
|
|
| 19 |
+ _, err = client.DiskUsage(t.Context(), DiskUsageOptions{})
|
|
| 20 | 20 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 21 | 21 |
} |
| 22 | 22 |
|
| ... | ... |
@@ -39,7 +38,7 @@ func TestDiskUsage(t *testing.T) {
|
| 39 | 39 |
})) |
| 40 | 40 |
assert.NilError(t, err) |
| 41 | 41 |
|
| 42 |
- du, err := client.DiskUsage(context.Background(), DiskUsageOptions{})
|
|
| 42 |
+ du, err := client.DiskUsage(t.Context(), DiskUsageOptions{})
|
|
| 43 | 43 |
assert.NilError(t, err) |
| 44 | 44 |
assert.Equal(t, du.Images.ActiveImages, int64(0)) |
| 45 | 45 |
assert.Equal(t, du.Images.TotalImages, int64(0)) |
| ... | ... |
@@ -116,7 +115,7 @@ func TestDiskUsageWithOptions(t *testing.T) {
|
| 116 | 116 |
|
| 117 | 117 |
for _, tt := range tests {
|
| 118 | 118 |
t.Run(fmt.Sprintf("options=%+v", tt.options), func(t *testing.T) {
|
| 119 |
- client, err := NewClientWithOpts(WithMockClient(func(req *http.Request) (*http.Response, error) {
|
|
| 119 |
+ client, err := New(WithMockClient(func(req *http.Request) (*http.Response, error) {
|
|
| 120 | 120 |
if err := assertRequestWithQuery(req, http.MethodGet, expectedURL, tt.expectedQuery); err != nil {
|
| 121 | 121 |
return nil, err |
| 122 | 122 |
} |
| ... | ... |
@@ -133,7 +132,7 @@ func TestDiskUsageWithOptions(t *testing.T) {
|
| 133 | 133 |
func TestLegacyDiskUsage(t *testing.T) {
|
| 134 | 134 |
const legacyVersion = "1.51" |
| 135 | 135 |
const expectedURL = "/system/df" |
| 136 |
- client, err := NewClientWithOpts( |
|
| 136 |
+ client, err := New( |
|
| 137 | 137 |
WithVersion(legacyVersion), |
| 138 | 138 |
WithMockClient(func(req *http.Request) (*http.Response, error) {
|
| 139 | 139 |
if err := assertRequest(req, http.MethodGet, "/v"+legacyVersion+expectedURL); err != nil {
|
| ... | ... |
@@ -149,7 +148,7 @@ func TestLegacyDiskUsage(t *testing.T) {
|
| 149 | 149 |
})) |
| 150 | 150 |
assert.NilError(t, err) |
| 151 | 151 |
|
| 152 |
- du, err := client.DiskUsage(context.Background(), DiskUsageOptions{})
|
|
| 152 |
+ du, err := client.DiskUsage(t.Context(), DiskUsageOptions{})
|
|
| 153 | 153 |
assert.NilError(t, err) |
| 154 | 154 |
assert.Equal(t, du.Images.ActiveImages, int64(0)) |
| 155 | 155 |
assert.Equal(t, du.Images.TotalImages, int64(0)) |