Skip to content

Commit d110359

Browse files
chore: move test config out of functions
1 parent c70cb89 commit d110359

15 files changed

+403
-401
lines changed
Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2-
import { AccuracyTestConfig } from "./sdk/describeAccuracyTests.js";
32

4-
function callsCollectionIndexes(prompt: string): AccuracyTestConfig {
5-
return {
6-
prompt: prompt,
3+
describeAccuracyTests([
4+
{
5+
prompt: "How many indexes do I have in 'mflix.movies' namespace?",
76
expectedToolCalls: [
87
{
98
toolName: "collection-indexes",
@@ -13,13 +12,29 @@ function callsCollectionIndexes(prompt: string): AccuracyTestConfig {
1312
},
1413
},
1514
],
16-
};
17-
}
18-
19-
describeAccuracyTests([
20-
callsCollectionIndexes("How many indexes do I have in 'mflix.movies' namespace?"),
21-
callsCollectionIndexes("List all the indexes in movies collection in mflix database"),
22-
callsCollectionIndexes(
23-
`Is the following query: ${JSON.stringify({ runtime: { $lt: 100 } })} on the namespace 'mflix.movies' indexed?`
24-
),
15+
},
16+
{
17+
prompt: "List all the indexes in movies collection in mflix database",
18+
expectedToolCalls: [
19+
{
20+
toolName: "collection-indexes",
21+
parameters: {
22+
database: "mflix",
23+
collection: "movies",
24+
},
25+
},
26+
],
27+
},
28+
{
29+
prompt: `Is the following query: ${JSON.stringify({ runtime: { $lt: 100 } })} on the namespace 'mflix.movies' indexed?`,
30+
expectedToolCalls: [
31+
{
32+
toolName: "collection-indexes",
33+
parameters: {
34+
database: "mflix",
35+
collection: "movies",
36+
},
37+
},
38+
],
39+
},
2540
]);
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2-
import { AccuracyTestConfig } from "./sdk/describeAccuracyTests.js";
32

4-
function callsCollectionSchema(prompt: string): AccuracyTestConfig {
5-
return {
6-
prompt: prompt,
3+
describeAccuracyTests([
4+
{
5+
prompt: "Is there a title field in 'db1.coll1' namespace?",
76
expectedToolCalls: [
87
{
98
toolName: "collection-schema",
@@ -13,10 +12,17 @@ function callsCollectionSchema(prompt: string): AccuracyTestConfig {
1312
},
1413
},
1514
],
16-
};
17-
}
18-
19-
describeAccuracyTests([
20-
callsCollectionSchema("Is there a title field in 'db1.coll1' namespace?"),
21-
callsCollectionSchema("What is the type of value stored in title field in coll1 collection in db1 database?"),
15+
},
16+
{
17+
prompt: "What is the type of value stored in title field in coll1 collection in db1 database?",
18+
expectedToolCalls: [
19+
{
20+
toolName: "collection-schema",
21+
parameters: {
22+
database: "db1",
23+
collection: "coll1",
24+
},
25+
},
26+
],
27+
},
2228
]);

tests/accuracy/count.test.ts

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,41 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2-
import { AccuracyTestConfig } from "./sdk/describeAccuracyTests.js";
32

4-
function callsCountToolWithEmptyQuery(prompt: string, database = "mflix", collection = "movies"): AccuracyTestConfig {
5-
return {
6-
prompt: prompt,
3+
describeAccuracyTests([
4+
{
5+
prompt: "Count number of documents in 'mflix.movies' namespace.",
76
expectedToolCalls: [
87
{
98
toolName: "count",
109
parameters: {
11-
database,
12-
collection,
10+
database: "mflix",
11+
collection: "movies",
1312
},
1413
},
1514
],
16-
};
17-
}
18-
19-
function callsCountToolWithQuery(
20-
prompt: string,
21-
database = "mflix",
22-
collection = "movies",
23-
query: Record<string, unknown> = {}
24-
): AccuracyTestConfig {
25-
return {
26-
prompt: prompt,
15+
},
16+
{
17+
prompt: "How many documents are there in 'characters' collection in 'comics' database?",
2718
expectedToolCalls: [
2819
{
2920
toolName: "count",
3021
parameters: {
31-
database,
32-
collection,
33-
query,
22+
database: "comics",
23+
collection: "characters",
3424
},
3525
},
3626
],
37-
};
38-
}
39-
40-
describeAccuracyTests([
41-
callsCountToolWithEmptyQuery("Count number of documents in 'mflix.movies' namespace."),
42-
callsCountToolWithEmptyQuery(
43-
"How many documents are there in 'characters' collection in 'comics' database?",
44-
"comics",
45-
"characters"
46-
),
47-
callsCountToolWithQuery(
48-
"Count all the documents in 'mflix.movies' namespace with runtime less than 100?",
49-
"mflix",
50-
"movies",
51-
{ runtime: { $lt: 100 } }
52-
),
27+
},
28+
{
29+
prompt: "Count all the documents in 'mflix.movies' namespace with runtime less than 100?",
30+
expectedToolCalls: [
31+
{
32+
toolName: "count",
33+
parameters: {
34+
database: "mflix",
35+
collection: "movies",
36+
query: { runtime: { $lt: 100 } },
37+
},
38+
},
39+
],
40+
},
5341
]);
Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,33 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2-
import { AccuracyTestConfig } from "./sdk/describeAccuracyTests.js";
3-
import { ExpectedToolCall } from "./sdk/accuracyResultStorage/resultStorage.js";
42

5-
function callsCreateCollection(prompt: string, database: string, collection: string): AccuracyTestConfig {
6-
return {
7-
prompt: prompt,
3+
describeAccuracyTests([
4+
{
5+
prompt: "Create a new namespace 'mflix.documentaries'",
86
expectedToolCalls: [
97
{
108
toolName: "create-collection",
119
parameters: {
12-
database,
13-
collection,
10+
database: "mflix",
11+
collection: "documentaries",
1412
},
1513
},
1614
],
17-
};
18-
}
19-
20-
function callsCreateCollectionWithListCollections(prompt: string, expectedToolCalls: ExpectedToolCall[]) {
21-
return {
22-
injectConnectedAssumption: true,
23-
prompt: prompt,
24-
mockedTools: {},
25-
expectedToolCalls,
26-
};
27-
}
28-
29-
describeAccuracyTests([
30-
callsCreateCollection("Create a new namespace 'mflix.documentaries'", "mflix", "documentaries"),
31-
callsCreateCollection("Create a new collection villains in comics database", "comics", "villains"),
32-
callsCreateCollectionWithListCollections(
33-
"If and only if, the namespace 'mflix.documentaries' does not exist, then create it",
34-
[
15+
},
16+
{
17+
prompt: "Create a new collection villains in comics database",
18+
expectedToolCalls: [
19+
{
20+
toolName: "create-collection",
21+
parameters: {
22+
database: "comics",
23+
collection: "villains",
24+
},
25+
},
26+
],
27+
},
28+
{
29+
prompt: "If and only if, the namespace 'mflix.documentaries' does not exist, then create it",
30+
expectedToolCalls: [
3531
{
3632
toolName: "list-collections",
3733
parameters: {
@@ -45,6 +41,6 @@ describeAccuracyTests([
4541
collection: "documentaries",
4642
},
4743
},
48-
]
49-
),
44+
],
45+
},
5046
]);

tests/accuracy/dbStats.test.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2-
import { AccuracyTestConfig } from "./sdk/describeAccuracyTests.js";
32

4-
function callsListDatabases(prompt: string, database = "mflix"): AccuracyTestConfig {
5-
return {
6-
prompt: prompt,
3+
describeAccuracyTests([
4+
{
5+
prompt: "What is the size occupied by database mflix?",
76
expectedToolCalls: [
87
{
98
toolName: "db-stats",
109
parameters: {
11-
database,
10+
database: "mflix",
1211
},
1312
},
1413
],
15-
};
16-
}
17-
18-
describeAccuracyTests([callsListDatabases("What is the size occupied by database mflix?")]);
14+
},
15+
]);

tests/accuracy/deleteMany.test.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { describeAccuracyTests } from "./sdk/describeAccuracyTests.js";
2-
import { AccuracyTestConfig } from "./sdk/describeAccuracyTests.js";
32

4-
function callsDeleteManyWithEmptyFilters(prompt: string): AccuracyTestConfig {
5-
return {
6-
prompt: prompt,
3+
describeAccuracyTests([
4+
{
5+
prompt: "Delete all the documents from 'mflix.movies' namespace",
76
expectedToolCalls: [
87
{
98
toolName: "delete-many",
@@ -13,27 +12,29 @@ function callsDeleteManyWithEmptyFilters(prompt: string): AccuracyTestConfig {
1312
},
1413
},
1514
],
16-
};
17-
}
18-
19-
function callsDeleteManyWithFilters(prompt: string): AccuracyTestConfig {
20-
return {
21-
prompt: prompt,
15+
},
16+
{
17+
prompt: "Purge the collection 'movies' in database 'mflix'",
2218
expectedToolCalls: [
2319
{
2420
toolName: "delete-many",
2521
parameters: {
2622
database: "mflix",
2723
collection: "movies",
28-
filter: { runtime: { $lt: 100 } },
2924
},
3025
},
3126
],
32-
};
33-
}
34-
35-
describeAccuracyTests([
36-
callsDeleteManyWithEmptyFilters("Delete all the documents from 'mflix.movies' namespace"),
37-
callsDeleteManyWithEmptyFilters("Purge the collection 'movies' in database 'mflix'"),
38-
callsDeleteManyWithFilters("Remove all the documents from namespace 'mflix.movies' where runtime is less than 100"),
27+
},
28+
{
29+
prompt: "Remove all the documents from namespace 'mflix.movies' where runtime is less than 100",
30+
expectedToolCalls: [
31+
{
32+
toolName: "delete-many",
33+
parameters: {
34+
database: "mflix",
35+
collection: "movies",
36+
},
37+
},
38+
],
39+
},
3940
]);

0 commit comments

Comments
 (0)