Skip to content

Commit

Permalink
Add missing test for projectnessie#6758
Browse files Browse the repository at this point in the history
  • Loading branch information
snazy committed May 6, 2023
1 parent 1cd147d commit 52dfd23
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static org.projectnessie.versioned.storage.common.logic.Logics.repositoryLogic;

import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
Expand All @@ -29,8 +30,11 @@
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.projectnessie.nessie.relocated.protobuf.ByteString;
import org.projectnessie.versioned.storage.common.config.StoreConfig;
import org.projectnessie.versioned.storage.common.logic.RepositoryLogic;
import org.projectnessie.versioned.storage.common.objtypes.Compression;
import org.projectnessie.versioned.storage.common.objtypes.StringObj;
import org.projectnessie.versioned.storage.common.persist.Backend;
import org.projectnessie.versioned.storage.common.persist.CloseableIterator;
import org.projectnessie.versioned.storage.common.persist.Obj;
Expand All @@ -49,12 +53,36 @@ public class AbstractBackendRepositoryTests {
@NessiePersist protected PersistFactory persistFactory;

@Test
public void createEraseRepoViaPersist() {
public void createEraseRepoViaPersist() throws Exception {
Persist repo1 = newRepo();

RepositoryLogic repositoryLogic = repositoryLogic(repo1);
repositoryLogic.initialize("foo-main");
soft.assertThat(repositoryLogic.repositoryExists()).isTrue();

int objs = 250;
soft.assertThat(
repo1.storeObjs(
IntStream.range(0, objs)
.mapToObj(
x ->
StringObj.stringData(
"content-type",
Compression.NONE,
"file-" + x,
Collections.emptyList(),
ByteString.copyFromUtf8("text-" + x)))
.toArray(Obj[]::new)))
.hasSize(objs)
.doesNotContain(false);
try (CloseableIterator<Obj> scan = repo1.scanAllObjects(EnumSet.allOf(ObjType.class))) {
soft.assertThat(scan)
.toIterable()
.filteredOn(
o -> o instanceof StringObj && ((StringObj) o).contentType().equals("content-type"))
.hasSize(objs);
}

repo1.erase();
soft.assertThat(repositoryLogic.repositoryExists()).isFalse();
try (CloseableIterator<Obj> scan = repo1.scanAllObjects(EnumSet.allOf(ObjType.class))) {
Expand Down

0 comments on commit 52dfd23

Please sign in to comment.