mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-20 22:11:01 +08:00
22 lines
681 B
Java
22 lines
681 B
Java
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() {
|
|
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));
|
|
assertTrue(url.matches("http://cos.example.com/[a-f0-9]{32}\\.png"));
|
|
}
|
|
}
|