-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(engine): support node return error
- Loading branch information
1 parent
d24533c
commit 7373bf2
Showing
7 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Engine, { TaskNode } from '../src/index'; | ||
|
||
describe('@logicflow/engine error', () => { | ||
class DataNode extends TaskNode { | ||
async action() { | ||
this.globalData['dataSource'] = { | ||
time: this.context.getTime(), | ||
} | ||
return { | ||
status: 'error', | ||
detail: { | ||
errorMsg: this.context.getTime(), | ||
} | ||
} | ||
} | ||
} | ||
const engine = new Engine({ | ||
context: { | ||
getTime() { | ||
return new Date().getTime(); | ||
} | ||
} | ||
}); | ||
engine.register({ | ||
type: 'DataNode', | ||
model: DataNode, | ||
}) | ||
const flowData = { | ||
/** node1 |--> node2(DataNode) */ | ||
graphData: { | ||
nodes: [ | ||
{ | ||
id: 'node1', | ||
type: 'StartNode', | ||
properties: { | ||
text: '开始', | ||
}, | ||
}, | ||
{ | ||
id: 'node2', | ||
type: 'DataNode', | ||
properties: { | ||
text: '数据节点', | ||
}, | ||
} | ||
], | ||
edges: [ | ||
{ | ||
id: 'edge1', | ||
type: 'line', | ||
sourceNodeId: 'node1', | ||
targetNodeId: 'node2', | ||
properties: {} | ||
|
||
} | ||
] | ||
}, | ||
}; | ||
engine.load(flowData); | ||
test('return error status', async () => { | ||
const executeData = await engine.execute(flowData); | ||
expect(executeData.status).toEqual('error'); | ||
const execution = await engine.getExecutionRecord(executeData.executionId); | ||
expect(execution.length).toBe(2); | ||
expect(execution[1].status).toEqual('error'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters