MCPcopy
hub / github.com/Vincit/objection.js / test

Function test

tests/integration/graph/GraphInsert.js:1023–1071  ·  view source on GitHub ↗
({
      modelClass,
      graphIn,
      graphOptions: rawGraphOptions = {},
      queryOut,
      graphOut,
      postgresNumQueries = null,
      check,
    })

Source from the content-addressed store, hash-verified

1021 });
1022
1023 function test({
1024 modelClass,
1025 graphIn,
1026 graphOptions: rawGraphOptions = {},
1027 queryOut,
1028 graphOut,
1029 postgresNumQueries = null,
1030 check,
1031 }) {
1032 const builder = modelClass.query();
1033 const models = modelClass.ensureModelArray(graphIn, { skipValidation: true });
1034 rawGraphOptions = Object.assign({}, rawGraphOptions, { insertMissing: true });
1035 const graphOptions = new GraphOptions(rawGraphOptions);
1036 const graph = assignDbRefsAsRelateProps(ModelGraph.create(modelClass, models));
1037 const nodeDbExistence = GraphNodeDbExistence.createEveryNodeExistsExistence();
1038
1039 return GraphFetcher.fetchCurrentGraph({ builder, graph, graphOptions })
1040 .then((currentGraph) => {
1041 numExecutedQueries = 0;
1042
1043 const graphInsert = new GraphInsert({
1044 graph,
1045 currentGraph,
1046 graphOptions,
1047 nodeDbExistence,
1048 });
1049 const actions = graphInsert.createActions();
1050 let promise = Promise.resolve();
1051
1052 actions.forEach((action) => {
1053 promise = promise.then(() => action.run(builder));
1054 });
1055
1056 return promise;
1057 })
1058 .then(() => {
1059 if (session.isPostgres() && postgresNumQueries) {
1060 expect(numExecutedQueries).to.equal(postgresNumQueries);
1061 }
1062 })
1063 .then(() => queryOut(modelClass.query()))
1064 .then((result) => {
1065 expect(result).to.containSubset(graphOut);
1066
1067 if (check) {
1068 check(result);
1069 }
1070 });
1071 }
1072
1073 function assignDbRefsAsRelateProps(graph) {
1074 for (const node of graph.nodes) {

Callers 1

GraphInsert.jsFile · 0.70

Calls 13

createActionsMethod · 0.95
ensureModelArrayMethod · 0.80
thenMethod · 0.80
fetchCurrentGraphMethod · 0.80
resolveMethod · 0.80
forEachMethod · 0.80
isPostgresMethod · 0.80
checkFunction · 0.70
queryMethod · 0.65
createMethod · 0.45

Tested by

no test coverage detected