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

Build out index tags tests a bit more #319

Merged
merged 4 commits into from
Jan 7, 2025
Merged
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
54 changes: 51 additions & 3 deletions src/integration/control/configureIndex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,65 @@ describe('configure index', () => {
});
});

test('Remove index tag from serverless index', async () => {
test('Add/remove index tag(s) on serverless index', async () => {
const description = await pinecone.describeIndex(serverlessIndexName);
expect(description.tags).toEqual({
project: 'pinecone-integration-tests',
});

// Add a tag
await pinecone.configureIndex(serverlessIndexName, {
tags: { project: '' },
tags: { testTag: 'testValue' },
});
const description2 = await pinecone.describeIndex(serverlessIndexName);
expect(description2.tags).toBeUndefined();
expect(description2.tags).toEqual({
project: 'pinecone-integration-tests',
testTag: 'testValue',
});

// Remove that tag
await pinecone.configureIndex(serverlessIndexName, {
tags: { testTag: '' }, // Passing null/undefined here is not allowed due to type safety (must eval to string)
});
const description3 = await pinecone.describeIndex(serverlessIndexName);
if (description3.tags != null) {
expect(description3.tags['testTag']).toBeUndefined();
expect(description3.tags['project']).toEqual(
'pinecone-integration-tests'
);
}

// Confirm when config'ing other things about the index, tags are not changed
await pinecone.configureIndex(serverlessIndexName, {
deletionProtection: 'enabled',
});
const description4 = await pinecone.describeIndex(serverlessIndexName);
if (description4.tags != null) {
expect(description4.tags['testTag']).toBeUndefined();
expect(description4.tags['project']).toEqual(
'pinecone-integration-tests'
);
}

// (Cleanup) Disable deletion protection
await pinecone.configureIndex(serverlessIndexName, {
deletionProtection: 'disabled',
});
});

test('Update a tag value in a serverless index', async () => {
const description = await pinecone.describeIndex(serverlessIndexName);
expect(description.tags).toEqual({
project: 'pinecone-integration-tests',
});

await pinecone.configureIndex(serverlessIndexName, {
tags: { project: 'updated-project' },
});
const description2 = await pinecone.describeIndex(serverlessIndexName);
if (description2.tags != null) {
expect(description2.tags['project']).toEqual('updated-project');
}
});
});

Expand Down
Loading