mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-21 14:30:59 +08:00
Implement real async COS image upload
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
package com.openisle.service;
|
||||
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.model.PutObjectRequest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class CosImageUploaderTest {
|
||||
@Test
|
||||
void uploadReturnsUrl() {
|
||||
CosImageUploader uploader = new CosImageUploader("http://cos.example.com");
|
||||
String url = uploader.upload("data".getBytes(), "img.png");
|
||||
COSClient client = mock(COSClient.class);
|
||||
CosImageUploader uploader = new CosImageUploader(client, "bucket", "http://cos.example.com");
|
||||
|
||||
String url = uploader.upload("data".getBytes(), "img.png").join();
|
||||
|
||||
verify(client).putObject(any(PutObjectRequest.class));
|
||||
assertEquals("http://cos.example.com/img.png", url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user