-
Notifications
You must be signed in to change notification settings - Fork 2
/
pricing_test.go
63 lines (56 loc) · 1.38 KB
/
pricing_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
55
56
57
58
59
60
61
62
63
package rediscloud_api
import (
"context"
"net/http/httptest"
"testing"
"github.com/RedisLabs/rediscloud-go-api/redis"
"github.com/RedisLabs/rediscloud-go-api/service/pricing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGet(t *testing.T) {
server := httptest.NewServer(
testServer(
"key",
"secret",
getRequest(
t,
"/subscriptions/20000/pricing",
`{
"pricing": [
{
"type": "Shards",
"typeDetails": "micro",
"quantity": 1,
"quantityMeasurement": "shards",
"pricePerUnit": 0.027,
"priceCurrency": "USD",
"pricePeriod": "hour"
}
],
"links": [
{
"rel": "self",
"href": "https://api-staging.qa.redislabs.com/v1/subscriptions/110777/pricing",
"type": "GET"
}
]
}`,
),
))
subject, err := clientFromTestServer(server, "key", "secret")
require.NoError(t, err)
actual, err := subject.Pricing.List(context.TODO(), 20000)
require.NoError(t, err)
assert.Equal(t, []*pricing.Pricing{
{
Type: redis.String("Shards"),
TypeDetails: redis.String("micro"),
Quantity: redis.Int(1),
QuantityMeasurement: redis.String("shards"),
PricePerUnit: redis.Float64(0.027),
PriceCurrency: redis.String("USD"),
PricePeriod: redis.String("hour"),
},
}, actual)
}