-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminentitlement_test.go
54 lines (49 loc) · 1.41 KB
/
adminentitlement_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
51
52
53
54
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package nvidiagpucloud_test
import (
"bytes"
"context"
"errors"
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/stainless-sdks/nvidia-gpu-cloud-go"
"github.com/stainless-sdks/nvidia-gpu-cloud-go/option"
)
func TestAdminEntitlementListWithOptionalParams(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(200)
w.Write([]byte("abc"))
}))
defer server.Close()
baseURL := server.URL
client := nvidiagpucloud.NewClient(
option.WithBaseURL(baseURL),
option.WithAPIKey("My API Key"),
option.WithBearerToken("My Bearer Token"),
)
resp, err := client.Admin.Entitlements.List(context.TODO(), nvidiagpucloud.AdminEntitlementListParams{
IsPaidSubscription: nvidiagpucloud.F(true),
ProductName: nvidiagpucloud.F("product-name"),
})
if err != nil {
var apierr *nvidiagpucloud.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
var apierr *nvidiagpucloud.Error
if errors.As(err, &apierr) {
t.Log(string(apierr.DumpRequest(true)))
}
t.Fatalf("err should be nil: %s", err.Error())
}
if !bytes.Equal(b, []byte("abc")) {
t.Fatalf("return value not %s: %s", "abc", b)
}
}