Add image reference tracking

This commit is contained in:
Tim
2025-07-24 13:42:16 +08:00
parent f80bee1281
commit 0081e51459
9 changed files with 176 additions and 16 deletions

View File

@@ -2,6 +2,7 @@ package com.openisle.service;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.model.PutObjectRequest;
import com.openisle.repository.ImageRepository;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
@@ -11,7 +12,8 @@ class CosImageUploaderTest {
@Test
void uploadReturnsUrl() {
COSClient client = mock(COSClient.class);
CosImageUploader uploader = new CosImageUploader(client, "bucket", "http://cos.example.com");
ImageRepository repo = mock(ImageRepository.class);
CosImageUploader uploader = new CosImageUploader(client, repo, "bucket", "http://cos.example.com");
String url = uploader.upload("data".getBytes(), "img.png").join();

View File

@@ -24,11 +24,12 @@ class PostServiceTest {
PostSubscriptionRepository subRepo = mock(PostSubscriptionRepository.class);
NotificationRepository notificationRepo = mock(NotificationRepository.class);
PostReadService postReadService = mock(PostReadService.class);
ImageUploader imageUploader = mock(ImageUploader.class);
PostService service = new PostService(postRepo, userRepo, catRepo, tagRepo,
notifService, subService, commentService, commentRepo,
reactionRepo, subRepo, notificationRepo, postReadService,
PublishMode.DIRECT);
imageUploader, PublishMode.DIRECT);
Post post = new Post();
post.setId(1L);