@@ -6,13 +6,14 @@ import (
6
6
"testing"
7
7
"time"
8
8
9
+ "github.com/RedisLabs/rediscloud-go-api/redis"
9
10
"github.com/RedisLabs/rediscloud-go-api/service/databases"
10
11
"github.com/stretchr/testify/assert"
11
12
"github.com/stretchr/testify/require"
12
13
)
13
14
14
15
func TestDatabase_List (t * testing.T ) {
15
- s := httptest .NewServer (testServer ("apiKey" , "secret" , getRequest (t , "/subscriptions/23456/databases" , `{
16
+ s := httptest .NewServer (testServer ("apiKey" , "secret" , getRequest (t , "/subscriptions/23456/databases?limit=100&offset=0 " , `{
16
17
"accountId": 2,
17
18
"subscription": [
18
19
{
@@ -46,25 +47,26 @@ func TestDatabase_List(t *testing.T) {
46
47
subject , err := NewClient (BaseUrl (s .URL ), Auth ("apiKey" , "secret" ), Transporter (s .Client ().Transport ))
47
48
require .NoError (t , err )
48
49
49
- actual , err := subject .Database .List (context .TODO (), 23456 )
50
- require .NoError (t , err )
50
+ actual := subject .Database .List (context .TODO (), 23456 )
51
51
52
+ assert .True (t , actual .Next ())
53
+ assert .NoError (t , actual .Err ())
52
54
assert .ElementsMatch (t , []* databases.Database {
53
55
{
54
- ID : 42 ,
55
- Name : "first-example" ,
56
- Protocol : "redis" ,
57
- Provider : "AWS" ,
58
- Region : "eu-west-1" ,
56
+ ID : redis . Int ( 42 ) ,
57
+ Name : redis . String ( "first-example" ) ,
58
+ Protocol : redis . String ( "redis" ) ,
59
+ Provider : redis . String ( "AWS" ) ,
60
+ Region : redis . String ( "eu-west-1" ) ,
59
61
},
60
62
{
61
- ID : 43 ,
62
- Name : "second-example" ,
63
- Protocol : "redis" ,
64
- Provider : "AWS" ,
65
- Region : "eu-west-1" ,
63
+ ID : redis . Int ( 43 ) ,
64
+ Name : redis . String ( "second-example" ) ,
65
+ Protocol : redis . String ( "redis" ) ,
66
+ Provider : redis . String ( "AWS" ) ,
67
+ Region : redis . String ( "eu-west-1" ) ,
66
68
},
67
- }, actual )
69
+ }, actual . Value () )
68
70
}
69
71
70
72
func TestDatabase_Get (t * testing.T ) {
@@ -130,24 +132,38 @@ func TestDatabase_Get(t *testing.T) {
130
132
require .NoError (t , err )
131
133
132
134
assert .Equal (t , & databases.Database {
133
- ID : 98765 ,
134
- Name : "Example" ,
135
- Protocol : "redis" ,
136
- Provider : "AWS" ,
137
- Region : "eu-west-1" ,
138
- Status : "active" ,
139
- MemoryLimitInGb : 7 ,
140
- MemoryUsedInMb : 5 ,
141
- SupportOSSClusterApi : true ,
142
- DataPersistence : "none" ,
143
- Replication : false ,
144
- DataEvictionPolicy : "volatile-random" ,
145
- ActivatedOn : time .Date (2020 , 11 , 3 , 9 , 3 , 30 , 0 , time .UTC ),
146
- LastModified : time .Date (2020 , 11 , 3 , 9 , 3 , 30 , 0 , time .UTC ),
147
- MemoryStorage : "ram" ,
148
- PrivateEndpoint : "example.net:16668" ,
149
- PublicEndpoint : "example.com:16668" ,
150
- RedisVersionCompliance : "6.0.5" ,
135
+ ID : redis .Int (98765 ),
136
+ Name : redis .String ("Example" ),
137
+ Protocol : redis .String ("redis" ),
138
+ Provider : redis .String ("AWS" ),
139
+ Region : redis .String ("eu-west-1" ),
140
+ Status : redis .String ("active" ),
141
+ MemoryLimitInGb : redis .Float64 (7 ),
142
+ MemoryUsedInMb : redis .Float64 (5 ),
143
+ SupportOSSClusterApi : redis .Bool (true ),
144
+ DataPersistence : redis .String ("none" ),
145
+ Replication : redis .Bool (false ),
146
+ DataEvictionPolicy : redis .String ("volatile-random" ),
147
+ ActivatedOn : redis .Time (time .Date (2020 , 11 , 3 , 9 , 3 , 30 , 0 , time .UTC )),
148
+ LastModified : redis .Time (time .Date (2020 , 11 , 3 , 9 , 3 , 30 , 0 , time .UTC )),
149
+ MemoryStorage : redis .String ("ram" ),
150
+ PrivateEndpoint : redis .String ("example.net:16668" ),
151
+ PublicEndpoint : redis .String ("example.com:16668" ),
152
+ RedisVersionCompliance : redis .String ("6.0.5" ),
153
+ ThroughputMeasurement : & databases.Throughput {
154
+ By : redis .String ("operations-per-second" ),
155
+ Value : redis .Int (10_000 ),
156
+ },
157
+ Clustering : & databases.Clustering {
158
+ NumberOfShards : redis .Int (1 ),
159
+ },
160
+ Security : & databases.Security {
161
+ SslClientAuthentication : redis .Bool (false ),
162
+ SourceIps : redis .StringSlice ("0.0.0.0/0" ),
163
+ Password : redis .String ("test" ),
164
+ },
165
+ Modules : []* databases.Module {},
166
+ Alerts : []* databases.Alert {},
151
167
}, actual )
152
168
}
153
169
0 commit comments