Skip to content

Commit

Permalink
#70: Add test of image duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-sita committed Jul 19, 2024
1 parent 74f5fd1 commit c7df876
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import place.sita.labelle.core.TestContainersTest;
import place.sita.labelle.core.cache.CacheRegistry;
import place.sita.labelle.core.images.imagelocator.ImageLocatorService;
import place.sita.labelle.core.repository.inrepository.delta.DeltaService;
import place.sita.labelle.core.repository.inrepository.image.ImageRepository;
import place.sita.labelle.core.repository.inrepository.image.ImageResponse;
import place.sita.labelle.core.repository.inrepository.tags.Tag;
import place.sita.labelle.core.repository.repositories.Repository;
import place.sita.labelle.core.repository.repositories.RepositoryService;
import place.sita.labelle.datasource.NonUniqueAnswerException;
Expand Down Expand Up @@ -41,11 +43,15 @@ public class ImageRepositoryTest extends TestContainersTest {
@Autowired
private ImageLocatorService imageLocatorService;

@Autowired
private DeltaService deltaService;

@Autowired
private CacheRegistry cacheRegistry;

@AfterEach
public void cleanup() {
context.delete(Tables.TAG_DELTA).execute();
context.delete(Tables.TAG_IMAGE).execute();
context.delete(Tables.TAG).execute();
context.delete(Tables.TAG_CATEGORY).execute();
Expand Down Expand Up @@ -478,4 +484,24 @@ public void shouldReturnCorrectIndexOf() {
assertThat(imageRepository.images().indexOf(sixthImage)).isEqualTo(5);
}

@Test
public void shouldCreateDuplicateOfImage() {
// given
Repository repo = repositoryService.addRepository("Test repo");
var imageId = inRepositoryService.addEmptySyntheticImage(repo.id());
inRepositoryService.addTag(imageId, repo.id(), new Tag("First category", "First tag"));
inRepositoryService.addTag(imageId, repo.id(), new Tag("Second category", "Second tag"));
// todo test deltas

// when
var duplicateId = inRepositoryService.duplicateImage(imageId);

// then
assertThat(inRepositoryService.getTags(duplicateId)).contains(new Tag("First category", "First tag"));
assertThat(inRepositoryService.getTags(duplicateId)).contains(new Tag("Second category", "Second tag"));
assertThat(inRepositoryService.getTags(duplicateId)).hasSize(2);
// todo test persistent IDs
}


}

0 comments on commit c7df876

Please sign in to comment.