Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More version03 3 #291

Merged
merged 5 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});