@@ -420,17 +420,17 @@ func TestRESTRequests(t *testing.T) {
420420 {
421421 name : "create backup request" ,
422422 req : & api.CreateBackupRequest {
423- Backend : "filesystem" ,
424- ID : "bak-1" ,
425- BackupPath : "/path/to/backup" ,
426- Endpoint : "s3.amazonaws.com" ,
427- Bucket : "my-backups" ,
428- IncludeCollections : []string {"Songs" },
429- ExcludeCollections : []string {"Pizza" },
430- MaxCPUPercentage : 92 ,
431- ChunkSizeMiB : 20 ,
432- CompressionLevel : api . BackupCompressionLevelDefault ,
433- IncrementalBackupBaseID : "incr-bak-" ,
423+ Backend : "filesystem" ,
424+ ID : "bak-1" ,
425+ BackupPath : "/path/to/backup" ,
426+ Endpoint : "s3.amazonaws.com" ,
427+ Bucket : "my-backups" ,
428+ IncludeCollections : []string {"Songs" },
429+ ExcludeCollections : []string {"Pizza" },
430+ PrefixIncremental : "incr-bak-" ,
431+ MaxCPUPercentage : 92 ,
432+ ChunkSizeMiB : 20 ,
433+ CompressionLevel : api . BackupCompressionLevelDefault ,
434434 },
435435 wantMethod : http .MethodPost ,
436436 wantPath : "/backups/filesystem" ,
@@ -836,6 +836,104 @@ func TestRESTResponses(t *testing.T) {
836836 },
837837 },
838838 },
839+ {
840+ name : "backup create response" ,
841+ body : & rest.BackupCreateResponse {
842+ Backend : "filesystem" ,
843+ Id : "bak-1" ,
844+ Bucket : "my-backups" ,
845+ Path : "/path/to/backup" ,
846+ Classes : []string {"Songs" },
847+ Error : "whaam!" ,
848+ Status : rest .BackupCreateResponseStatusFAILED ,
849+ },
850+ dest : new (api.BackupInfo ),
851+ want : & api.BackupInfo {
852+ Backend : "filesystem" ,
853+ ID : "bak-1" ,
854+ Bucket : "my-backups" ,
855+ Path : "/path/to/backup" ,
856+ IncludesCollections : []string {"Songs" },
857+ Error : "whaam!" ,
858+ Status : api .BackupStatusFailed ,
859+ },
860+ },
861+ {
862+ name : "backup restore response" ,
863+ body : & rest.BackupRestoreResponse {
864+ Backend : "filesystem" ,
865+ Id : "bak-1" ,
866+ Path : "/path/to/backup" ,
867+ Classes : []string {"Songs" },
868+ Error : "whaam!" ,
869+ Status : rest .BackupRestoreResponseStatusFAILED ,
870+ },
871+ dest : new (api.BackupInfo ),
872+ want : & api.BackupInfo {
873+ Backend : "filesystem" ,
874+ ID : "bak-1" ,
875+ Path : "/path/to/backup" ,
876+ IncludesCollections : []string {"Songs" },
877+ Error : "whaam!" ,
878+ Status : api .BackupStatusFailed ,
879+ },
880+ },
881+ {
882+ name : "backup create status response" ,
883+ body : & rest.BackupCreateStatusResponse {
884+ Backend : "filesystem" ,
885+ Id : "bak-1" ,
886+ Path : "/path/to/backup" ,
887+ Status : rest .BackupCreateStatusResponseStatusSUCCESS ,
888+ Size : 92 ,
889+ },
890+ dest : new (api.BackupInfo ),
891+ want : & api.BackupInfo {
892+ Backend : "filesystem" ,
893+ ID : "bak-1" ,
894+ Path : "/path/to/backup" ,
895+ Status : api .BackupStatusSuccess ,
896+ SizeGiB : testkit.Ptr [float32 ](92 ),
897+ StartedAt : testkit .Ptr (time.Time {}),
898+ CompletedAt : testkit .Ptr (time.Time {}),
899+ },
900+ },
901+ {
902+ name : "backup list response" ,
903+ body : rest.BackupListResponse {
904+ {
905+ Id : "bak-1" ,
906+ Classes : []string {"Artists" },
907+ Status : rest .BackupListResponseStatusTRANSFERRING ,
908+ Size : 92 ,
909+ },
910+ {
911+ Id : "bak-2" ,
912+ Classes : []string {"Songs" },
913+ Status : rest .BackupListResponseStatusTRANSFERRED ,
914+ Size : 80085 ,
915+ },
916+ },
917+ dest : new ([]api.BackupInfo ),
918+ want : & []api.BackupInfo {
919+ {
920+ ID : "bak-1" ,
921+ IncludesCollections : []string {"Artists" },
922+ Status : api .BackupStatusTransferring ,
923+ SizeGiB : testkit.Ptr [float32 ](92 ),
924+ StartedAt : testkit .Ptr (time.Time {}),
925+ CompletedAt : testkit .Ptr (time.Time {}),
926+ },
927+ {
928+ ID : "bak-2" ,
929+ IncludesCollections : []string {"Songs" },
930+ Status : api .BackupStatusTransferred ,
931+ SizeGiB : testkit.Ptr [float32 ](80085 ),
932+ StartedAt : testkit .Ptr (time.Time {}),
933+ CompletedAt : testkit .Ptr (time.Time {}),
934+ },
935+ },
936+ },
839937 } {
840938 t .Run (tt .name , func (t * testing.T ) {
841939 require .NotNil (t , tt .body , "incomplete test case: body is nil" )
0 commit comments