Skip to content

Commit

Permalink
added postman test collection and update to DefaultBranchService.java
Browse files Browse the repository at this point in the history
  • Loading branch information
borozcod committed Feb 27, 2024
1 parent 9f86bb6 commit af678d9
Show file tree
Hide file tree
Showing 3 changed files with 659 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ jobs:
docker create -v /etc/newman --name mms_test_configs alpine:3.4 /bin/true
docker cp example/. mms_test_configs:/etc/newman
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run crud.postman_collection.json -e test-env.json --delay-request 500
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run getAtCommits.postman_collection.json -e test-env.json --delay-request 500
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run getAtCommits.postman_collection.json -e test-env.json --delay-request 500
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run makeBranchFromCommit.postman_collection.json -e test-env.json --delay-request 500
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run cameo.postman_collection.json -e test-env.json --delay-request 1000
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run jupyter.postman_collection.json -e test-env.json --delay-request 500
docker run --volumes-from mms_test_configs --network container:mms -t postman/newman run localauth.postman_collection.json -e test-env.json --delay-request 500
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public RefJson createBranch(String projectId, RefJson branch) {
branch.setDeleted(false);
branch.setProjectId(projectId);
branch.setStatus("created");
boolean fromCommit = !branch.getParentCommitId().isEmpty();

if (branch.getDocId() == null || branch.getDocId().isEmpty()) {
String docId = branchIndex.createDocId(branch);
Expand Down Expand Up @@ -182,7 +183,7 @@ public RefJson createBranch(String projectId, RefJson branch) {
try {
branchIndex.update(branch);
branchRepository.save(b);
if(branch.getParentCommitId() == null) {
if(!fromCommit) {
Set<String> docIds = new HashSet<>();
for (Node n: nodeRepository.findAllByDeleted(false)) {
docIds.add(n.getDocId());
Expand Down Expand Up @@ -222,7 +223,7 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe

RefJson branchFromCommit = this.createBranch(projectId, parentCommitIdRef);

ContextHolder.setContext(projectId, branchFromCommit.getRefId());
ContextHolder.setContext(projectId, branchFromCommit.getId());

// Get current nodes from database
List<Node> nodes = nodeRepository.findAll();
Expand All @@ -236,21 +237,19 @@ public RefJson createBranchfromCommit(String projectId, RefJson parentCommitIdRe
}

// Update database table to match index
Set<String> docIds = new HashSet<>();
for (Node node : nodes) {
if(nodeCommitData.containsKey(node.getNodeId())){
node.setDocId(nodeCommitData.get(node.getNodeId()).getDocId());
node.setLastCommit(nodeCommitData.get(node.getNodeId()).getCommitId());
node.setDeleted(false);
docIds.add(node.getDocId());
} else {
node.setDeleted(true);
}
}
nodeRepository.updateAll(nodes);

Set<String> docIds = new HashSet<>();
for (Node n: nodeRepository.findAllByDeleted(false)) {
docIds.add(n.getDocId());
}
try { nodeIndex.addToRef(docIds); } catch(Exception e) {}

return branchFromCommit;
Expand Down
Loading

0 comments on commit af678d9

Please sign in to comment.