Skip to content

Commit

Permalink
Add e2e test reproducing the bug
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienmaillard committed Oct 11, 2023
1 parent addb746 commit 97b041c
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ export default () => Goal.CoexistenceGoal({
startsAt: TimingConstraint.singleton(WindowProperty.START)
})""";

private final String bakeBananaGoalDefinition =
"""
export default (): Goal =>
Goal.ActivityRecurrenceGoal({
activityTemplate: ActivityTemplates.BakeBananaBread({
temperature: 325.0,
tbSugar: 2,
glutenFree: false,
}),
interval: Temporal.Duration.from({ hours: 12 }),
});""";

@BeforeAll
void beforeAll() {
// Setup Requests
Expand Down Expand Up @@ -125,6 +137,30 @@ private void insertActivities() throws IOException {
hasura.updatePlanRevisionSchedulingSpec(planId);
}

//reproduces issue #1165
@Test
void twoInARow() throws IOException {
// Setup: Add Goal
final int bakeBananaBreadGoalId = hasura.insertSchedulingGoal(
"BakeBanana Scheduling Test Goal",
modelId,
bakeBananaGoalDefinition);
hasura.createSchedulingSpecGoal(bakeBananaBreadGoalId, schedulingSpecId, 0);
try {
// Schedule and get Plan
hasura.awaitScheduling(schedulingSpecId);
hasura.updatePlanRevisionSchedulingSpec(planId);
hasura.awaitScheduling(schedulingSpecId);
final var plan = hasura.getPlan(planId);
final var activities = plan.activityDirectives();
assertEquals(2, activities.size());
activities.forEach(a->assertEquals("BakeBananaBread", a.type()));
} finally {
// Teardown: Delete Goal
hasura.deleteSchedulingGoal(bakeBananaBreadGoalId);
}
}

@Test
void getSchedulingDSLTypeScript() throws IOException {
final var schedulingDslTypes = hasura.getSchedulingDslTypeScript(modelId);
Expand Down

0 comments on commit 97b041c

Please sign in to comment.