Skip to content

Commit 457a9a1

Browse files
committed
test: make the test independent of others
This test fast failing with 'source not well formed' error message, which is Weaviate's speak for 'I dont think this property is a reference'. Still not sure why, but I figured it may have to do with how the test-suite is structured; namely, that each test relies on the state produced/left by the previous test. To test reference deletion, we instead simply create 2 objects, reference one from the other and then delete that reference. No external state.
1 parent 5c4c1bf commit 457a9a1

File tree

2 files changed

+60
-46
lines changed

2 files changed

+60
-46
lines changed

src/collections/data/integration.test.ts

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,11 @@ describe('Testing of the collection.data methods with a single target reference'
3131
const toBeDeletedID = v4();
3232
const nonExistingID = v4();
3333

34-
afterAll(() => {
35-
return client.collections.delete(collectionName).catch((err) => {
36-
console.error(err);
37-
throw err;
38-
});
39-
});
40-
4134
beforeAll(async () => {
4235
client = await weaviate.connectToLocal();
36+
37+
await client.collections.delete(collectionName);
38+
4339
collection = client.collections.use(collectionName);
4440
await client.collections
4541
.create<TestCollectionData>({
@@ -344,25 +340,43 @@ describe('Testing of the collection.data methods with a single target reference'
344340
});
345341

346342
it('should be able to delete a reference between two objects', () => {
347-
return Promise.all([
348-
collection.data.referenceDelete({
349-
fromProperty: 'ref',
350-
fromUuid: toBeUpdatedID,
351-
to: Reference.to(existingID),
352-
}),
353-
collection.data.referenceDelete({
354-
fromProperty: 'ref',
355-
fromUuid: toBeUpdatedID,
356-
to: toBeUpdatedID,
357-
}),
358-
collection.data.referenceDelete({
359-
fromProperty: 'ref',
360-
fromUuid: toBeUpdatedID,
361-
to: [toBeReplacedID],
362-
}),
343+
// Insert 2 objects
344+
return collection.data.insertMany([
345+
{ testProp: "refLeft" }, { testProp: "refRight" },
363346
])
364-
.then(() =>
365-
collection.query.fetchObjectById(toBeUpdatedID, {
347+
// Create a reference between them
348+
.then(inserted => collection.data.referenceAdd({
349+
fromProperty: 'ref',
350+
fromUuid: inserted.allResponses[0] as string,
351+
to: inserted.allResponses[1] as string,
352+
}).then(() => inserted))
353+
354+
// Assert that the reference exists
355+
.then(inserted =>
356+
collection.query.fetchObjectById(inserted.allResponses[0] as string, {
357+
returnReferences: [{ linkOn: 'ref' }],
358+
})
359+
.then((obj) => {
360+
expect(obj).not.toBeNull();
361+
expect(obj?.references?.ref?.objects).toHaveLength(1);
362+
363+
// Propagate the list of inserted IDs
364+
return Promise.resolve(inserted);
365+
})
366+
)
367+
368+
// Delete reference between them
369+
.then(inserted =>
370+
collection.data.referenceDelete({
371+
fromProperty: 'ref',
372+
fromUuid: inserted.allResponses[0] as string,
373+
to: inserted.allResponses[1] as string,
374+
})
375+
.then(() => inserted))
376+
377+
// Assert the reference does not exist
378+
.then(inserted =>
379+
collection.query.fetchObjectById(inserted.allResponses[0] as string, {
366380
returnReferences: [{ linkOn: 'ref' }],
367381
})
368382
)

src/schema/journey.test.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -734,19 +734,19 @@ async function newClassObject(className: string, client: WeaviateClient): Promis
734734
maxConnections: 64,
735735
multivector: (await isVer(client, 29, 0))
736736
? {
737-
aggregation: 'maxSim',
738-
enabled: false,
739-
...((await isVer(client, 31, 0))
740-
? {
741-
muvera: {
742-
enabled: false,
743-
dprojections: 16,
744-
ksim: 4,
745-
repetitions: 10,
746-
},
747-
}
748-
: {}),
749-
}
737+
aggregation: 'maxSim',
738+
enabled: false,
739+
...((await isVer(client, 31, 0))
740+
? {
741+
muvera: {
742+
enabled: false,
743+
dprojections: 16,
744+
ksim: 4,
745+
repetitions: 10,
746+
},
747+
}
748+
: {}),
749+
}
750750
: undefined,
751751
pq: {
752752
bitCompression: false,
@@ -764,17 +764,17 @@ async function newClassObject(className: string, client: WeaviateClient): Promis
764764
},
765765
sq: (await isVer(client, 26, 0))
766766
? {
767-
enabled: false,
768-
rescoreLimit: 20,
769-
trainingLimit: 100000,
770-
}
767+
enabled: false,
768+
rescoreLimit: 20,
769+
trainingLimit: 100000,
770+
}
771771
: undefined,
772772
rq: (await isVer(client, 32, 0))
773773
? {
774-
enabled: false,
775-
bits: 8,
776-
rescoreLimit: 20,
777-
}
774+
enabled: false,
775+
bits: 8,
776+
rescoreLimit: 20,
777+
}
778778
: undefined,
779779
skip: false,
780780
efConstruction: 128,

0 commit comments

Comments
 (0)