Skip to content

Commit

Permalink
Add more tests to improve code coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Widdis <[email protected]>
  • Loading branch information
dbwiddis committed Sep 16, 2023
1 parent 23f885c commit d5e4d71
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
codecov:
require_ci_to_pass: yes

# ignore files in demo package
ignore:
- "demo"

coverage:
precision: 2
round: down
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.opensearch.flowframework.workflow.WorkflowStep;
import org.opensearch.test.OpenSearchTestCase;

import java.util.Collections;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
Expand All @@ -41,21 +42,24 @@ public CompletableFuture<WorkflowData> execute(List<WorkflowData> data) {
public String getName() {
return "test";
}
}, WorkflowData.EMPTY);
});
assertEquals("A", nodeA.id());
assertEquals("test", nodeA.workflowStep().getName());
assertEquals(WorkflowData.EMPTY, nodeA.input());
assertEquals(Collections.emptySet(), nodeA.getPredecessors());
assertEquals("A", nodeA.toString());

// TODO: Once we can get OpenSearch Thread Pool for this execute method, create an IT and don't test execute here
CompletableFuture<WorkflowData> f = nodeA.execute();
assertEquals(f, nodeA.getFuture());
f.orTimeout(5, TimeUnit.SECONDS);
assertTrue(f.isDone());
assertEquals(WorkflowData.EMPTY, f.get());

ProcessNode nodeB = new ProcessNode("B", null, null);
ProcessNode nodeB = new ProcessNode("B", null);
assertNotEquals(nodeA, nodeB);

ProcessNode nodeA2 = new ProcessNode("A", null, null);
ProcessNode nodeA2 = new ProcessNode("A", null);
assertEquals(nodeA, nodeA2);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/
package org.opensearch.flowframework.workflow;

import org.opensearch.test.OpenSearchTestCase;

import java.util.Collections;

public class WorkflowDataTests extends OpenSearchTestCase {

@Override
public void setUp() throws Exception {
super.setUp();
}

public void testWorkflowData() {
WorkflowData data = new WorkflowData() {
};
assertEquals(Collections.emptyMap(), data.getParams());
assertEquals(Collections.emptyMap(), data.getContent());
}
}

0 comments on commit d5e4d71

Please sign in to comment.