Skip to content

Commit

Permalink
Merge pull request #291 from receptron/more_version03_3
Browse files Browse the repository at this point in the history
More version03 3
  • Loading branch information
snakajima authored May 9, 2024
2 parents 06c589d + 14a0e84 commit ab4ff79
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions tests/graphai/test_source_prop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import test from "node:test";
import assert from "node:assert";

const graphData = {
version: 0.2,
version: 0.3,
nodes: {
input: {
agent: "testAgent",
},
test: {
agent: "testAgent",
inputs: ["input"],
inputs: [":input"],
},
test2: {
agent: "testAgent",
inputs: ["test.hoge"],
inputs: [":test.hoge"],
},
},
};
Expand All @@ -31,7 +31,7 @@ test("test source props test", async () => {
});

const graphData_literal = {
version: 0.2,
version: 0.3,
nodes: {
source: {
value: "apple",
Expand All @@ -44,12 +44,12 @@ const graphData_literal = {
params: {
template: "${0}, ${1}, ${2}.",
},
inputs: ["source", "\"orange\"", undefined],
inputs: [":source", "orange", undefined],
isResult: true,
},
step2: {
agent: "sleeperAgent",
inputs: ["source2", { lemon: "yellow" }],
inputs: [":source2", { lemon: "yellow" }],
isResult: true,
},
},
Expand Down
12 changes: 6 additions & 6 deletions tests/graphai/test_validator_graph_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const nodes = {
// loop test
test("test loop error", async () => {
const graphdata = {
version: 0.2,
version: 0.3,
loop: {},
nodes,
};
Expand All @@ -25,7 +25,7 @@ test("test loop error", async () => {

test("test loop error 1", async () => {
const graphdata = {
version: 0.2,
version: 0.3,
loop: {
count: 1,
while: "123",
Expand All @@ -38,7 +38,7 @@ test("test loop error 1", async () => {
// concurrency test
test("test concurrency error zero", async () => {
const graphdata = {
version: 0.2,
version: 0.3,
concurrency: 0,
nodes,
};
Expand All @@ -47,7 +47,7 @@ test("test concurrency error zero", async () => {

test("test concurrency error nagative", async () => {
const graphdata = {
version: 0.2,
version: 0.3,
concurrency: -1,
nodes,
};
Expand All @@ -56,7 +56,7 @@ test("test concurrency error nagative", async () => {

test("test concurrency error float", async () => {
const graphdata = {
version: 0.2,
version: 0.3,
concurrency: 0.1,
nodes,
};
Expand All @@ -65,7 +65,7 @@ test("test concurrency error float", async () => {

test("test concurrency error string", async () => {
const graphdata = anonymization({
version: 0.2,
version: 0.3,
concurrency: "1",
nodes,
});
Expand Down
12 changes: 6 additions & 6 deletions tests/units/graph_data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const graph_data = {
version: 0.2,
version: 0.3,
nodes: {
echo: {
agent: "echoAgent",
Expand All @@ -9,28 +9,28 @@ export const graph_data = {
},
bypassAgent: {
agent: "bypassAgent",
inputs: ["echo"],
inputs: [":echo"],
},
bypassAgent2: {
agent: "bypassAgent",
inputs: ["bypassAgent"],
inputs: [":bypassAgent"],
},
},
};

export const graph_injection_data = {
version: 0.2,
version: 0.3,
nodes: {
echo: {
agent: "echoAgent",
},
bypassAgent: {
agent: "injectAgent",
inputs: ["echo"],
inputs: [":echo"],
},
bypassAgent2: {
agent: "bypassAgent",
inputs: ["bypassAgent"],
inputs: [":bypassAgent"],
},
},
};
32 changes: 16 additions & 16 deletions tests/units/test_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,83 +4,83 @@ import test from "node:test";
import assert from "node:assert";

test("test getDataFromSource", async () => {
const inputId = "node1";
const inputId = ":node1";
const result = { data: "123" };
const data = { data: "123" };

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

test("test getDataFromSource parseId", async () => {
const inputId = "node1.data";
const inputId = ":node1.data";
const result = { data: "123" };
const data = "123";

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

test("test getDataFromSource array", async () => {
const inputId = "node1";
const inputId = ":node1";
const result = ["123"];
const data = ["123"];

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

test("test getDataFromSource array $0", async () => {
const inputId = "node1.$0";
const inputId = ":node1.$0";
const result = ["000", "111"];
const data = "000";

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

test("test getDataFromSource array $1", async () => {
const inputId = "node1.$1";
const inputId = ":node1.$1";
const result = ["000", "111"];
const data = "111";

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

// nested propId

test("test getDataFromSource nested object", async () => {
const inputId = "node1.data.sample";
const inputId = ":node1.data.sample";
const result = { data: { sample: "123" } };
const data = "123";

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

test("test getDataFromSource nested array", async () => {
const inputId = "node1.data.sample.$2";
const inputId = ":node1.data.sample.$2";
const result = { data: { sample: [0, 1, 2, 3] } };
const data = 2;

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

test("test getDataFromSource nested array last", async () => {
const inputId = "node1.data.sample.$last";
const inputId = ":node1.data.sample.$last";
const result = { data: { sample: [0, 1, 2, 3] } };
const data = 3;

const source = parseNodeName(inputId, 0.2);
const source = parseNodeName(inputId, 0.3);
const res = getDataFromSource(result, source);
assert.deepStrictEqual(res, data);
});

0 comments on commit ab4ff79

Please sign in to comment.