-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some testing and latest import details
- Loading branch information
1 parent
bb995f4
commit 4c1ba7f
Showing
8 changed files
with
408 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package rediscloud_api | ||
|
||
import ( | ||
"context" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetLatestBackup(t *testing.T) { | ||
server := httptest.NewServer( | ||
testServer( | ||
"key", | ||
"secret", | ||
getRequest( | ||
t, | ||
"/subscriptions/12/databases/34/backup", | ||
`{ | ||
"taskId": "50ec6172-8475-4ef6-8b3c-d61e688d8fe5", | ||
"commandType": "databaseBackupStatusRequest", | ||
"status": "received", | ||
"description": "Task request received and is being queued for processing.", | ||
"timestamp": "2024-04-15T09:08:04.222268Z", | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/50ec6172-8475-4ef6-8b3c-d61e688d8fe5", | ||
"type": "GET", | ||
"rel": "task" | ||
} | ||
] | ||
}`, | ||
), | ||
getRequest( | ||
t, | ||
"/tasks/50ec6172-8475-4ef6-8b3c-d61e688d8fe5", | ||
`{ | ||
"taskId": "50ec6172-8475-4ef6-8b3c-d61e688d8fe5", | ||
"commandType": "databaseBackupStatusRequest", | ||
"status": "processing-completed", | ||
"description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.", | ||
"timestamp": "2024-04-15T09:08:07.537915Z", | ||
"response": { | ||
"resourceId": 51051292, | ||
"additionalResourceId": 12, | ||
"resource": {} | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/50ec6172-8475-4ef6-8b3c-d61e688d8fe5", | ||
"type": "GET", | ||
"rel": "self" | ||
} | ||
] | ||
}`, | ||
), | ||
)) | ||
|
||
subject, err := clientFromTestServer(server, "key", "secret") | ||
require.NoError(t, err) | ||
|
||
_, err = subject.LatestBackup.Get(context.TODO(), 12, 34) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestGetAALatestBackup(t *testing.T) { | ||
server := httptest.NewServer( | ||
testServer( | ||
"key", | ||
"secret", | ||
getRequest( | ||
t, | ||
"/subscriptions/12/databases/34/backup?regionName=eu-west-2", | ||
`{ | ||
"taskId": "ce2cbfea-9b15-4250-a516-f014161a8dd3", | ||
"commandType": "databaseBackupStatusRequest", | ||
"status": "received", | ||
"description": "Task request received and is being queued for processing.", | ||
"timestamp": "2024-04-15T09:52:23.963337Z", | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/ce2cbfea-9b15-4250-a516-f014161a8dd3", | ||
"type": "GET", | ||
"rel": "task" | ||
} | ||
] | ||
}`, | ||
), | ||
getRequest( | ||
t, | ||
"/tasks/ce2cbfea-9b15-4250-a516-f014161a8dd3", | ||
`{ | ||
"taskId": "ce2cbfea-9b15-4250-a516-f014161a8dd3", | ||
"commandType": "databaseBackupStatusRequest", | ||
"status": "processing-error", | ||
"description": "Task request failed during processing. See error information for failure details.", | ||
"timestamp": "2024-04-15T09:52:26.101936Z", | ||
"response": { | ||
"error": { | ||
"type": "DATABASE_BACKUP_DISABLED", | ||
"status": "400 BAD_REQUEST", | ||
"description": "Database backup is disabled" | ||
} | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/ce2cbfea-9b15-4250-a516-f014161a8dd3", | ||
"type": "GET", | ||
"rel": "self" | ||
} | ||
] | ||
}`, | ||
), | ||
)) | ||
|
||
subject, err := clientFromTestServer(server, "key", "secret") | ||
require.NoError(t, err) | ||
|
||
_, err = subject.LatestBackup.GetActiveActive(context.TODO(), 12, 34, "eu-west-2") | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
package rediscloud_api | ||
|
||
import ( | ||
"context" | ||
"net/http/httptest" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestGetLatestImportTooEarly(t *testing.T) { | ||
server := httptest.NewServer( | ||
testServer( | ||
"key", | ||
"secret", | ||
getRequest( | ||
t, | ||
"/subscriptions/12/databases/34/import", | ||
`{ | ||
"taskId": "1dfd6084-21df-40c6-829c-e9b4790e207e", | ||
"commandType": "databaseImportStatusRequest", | ||
"status": "received", | ||
"description": "Task request received and is being queued for processing.", | ||
"timestamp": "2024-04-15T10:19:06.710686Z", | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/1dfd6084-21df-40c6-829c-e9b4790e207e", | ||
"type": "GET", | ||
"rel": "task" | ||
} | ||
] | ||
}`, | ||
), | ||
getRequest( | ||
t, | ||
"/tasks/1dfd6084-21df-40c6-829c-e9b4790e207e", | ||
`{ | ||
"taskId": "1dfd6084-21df-40c6-829c-e9b4790e207e", | ||
"commandType": "databaseImportStatusRequest", | ||
"status": "processing-error", | ||
"description": "Task request failed during processing. See error information for failure details.", | ||
"timestamp": "2024-04-15T10:19:07.331898Z", | ||
"response": { | ||
"error": { | ||
"type": "SUBSCRIPTION_NOT_ACTIVE", | ||
"status": "403 FORBIDDEN", | ||
"description": "Cannot preform any actions for subscription that is not in an active state" | ||
} | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/1dfd6084-21df-40c6-829c-e9b4790e207e", | ||
"type": "GET", | ||
"rel": "self" | ||
} | ||
] | ||
}`, | ||
), | ||
)) | ||
|
||
subject, err := clientFromTestServer(server, "key", "secret") | ||
require.NoError(t, err) | ||
|
||
_, err = subject.LatestImport.Get(context.TODO(), 12, 34) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestGetLatestImport(t *testing.T) { | ||
server := httptest.NewServer( | ||
testServer( | ||
"key", | ||
"secret", | ||
getRequest( | ||
t, | ||
"/subscriptions/12/databases/34/import", | ||
`{ | ||
"taskId": "e9232e43-3781-4263-a38e-f4d150e03475", | ||
"commandType": "databaseImportStatusRequest", | ||
"status": "received", | ||
"description": "Task request received and is being queued for processing.", | ||
"timestamp": "2024-04-15T10:44:34.325298Z", | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/e9232e43-3781-4263-a38e-f4d150e03475", | ||
"type": "GET", | ||
"rel": "task" | ||
} | ||
] | ||
}`, | ||
), | ||
getRequest( | ||
t, | ||
"/tasks/e9232e43-3781-4263-a38e-f4d150e03475", | ||
`{ | ||
"taskId": "e9232e43-3781-4263-a38e-f4d150e03475", | ||
"commandType": "databaseImportStatusRequest", | ||
"status": "processing-completed", | ||
"description": "Request processing completed successfully and its resources are now being provisioned / de-provisioned.", | ||
"timestamp": "2024-04-15T10:44:35.225468Z", | ||
"response": { | ||
"resourceId": 51051302, | ||
"additionalResourceId": 110777, | ||
"resource": {} | ||
}, | ||
"links": [ | ||
{ | ||
"href": "https://api-staging.qa.redislabs.com/v1/tasks/e9232e43-3781-4263-a38e-f4d150e03475", | ||
"type": "GET", | ||
"rel": "self" | ||
} | ||
] | ||
}`, | ||
), | ||
)) | ||
|
||
subject, err := clientFromTestServer(server, "key", "secret") | ||
require.NoError(t, err) | ||
|
||
_, err = subject.LatestImport.Get(context.TODO(), 12, 34) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.