-
Notifications
You must be signed in to change notification settings - Fork 38
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,17 +136,52 @@ describe('configure index', () => { | |
}); | ||
}); | ||
|
||
test('Add index tag to a serverless index', async () => { | ||
const description = await pinecone.describeIndex(serverlessIndexName); | ||
expect(description.tags).toEqual({ | ||
project: 'pinecone-integration-tests', | ||
}); | ||
|
||
await pinecone.configureIndex(serverlessIndexName, { | ||
tags: { testTag: 'testValue' }, | ||
}); | ||
const description2 = await pinecone.describeIndex(serverlessIndexName); | ||
expect(description2.tags).toEqual({ | ||
project: 'pinecone-integration-tests', | ||
testTag: 'testValue', | ||
}); | ||
}); | ||
|
||
test('Remove index tag from serverless index', async () => { | ||
const description = await pinecone.describeIndex(serverlessIndexName); | ||
expect(description.tags).toEqual({ | ||
project: 'pinecone-integration-tests', | ||
testTag: 'testValue', | ||
}); | ||
|
||
await pinecone.configureIndex(serverlessIndexName, { | ||
tags: { project: '' }, | ||
}); | ||
const description2 = await pinecone.describeIndex(serverlessIndexName); | ||
expect(description2.tags).toBeUndefined(); | ||
if (description2.tags != null) { | ||
expect(description2.tags['project']).toBeUndefined(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is interesting. I'm sure this has already been discussed, but I'd expect to have to explicitly pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the tag itself (the key value) is still present, but the value can be an empty string. If it's an empty string, then it's undefined. Does that make sense? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely more on the implementation side and agnostic to the SDK, but if I understand correctly that json responses don't really encode so i'd expect something like
whereas this test tells me
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
expect(description2.tags['testTag']).toEqual('testValue'); | ||
} | ||
}); | ||
|
||
test('Update a tag value in a serverless index', async () => { | ||
const description = await pinecone.describeIndex(serverlessIndexName); | ||
expect(description.tags).toEqual({ | ||
testTag: 'testValue', | ||
}); | ||
|
||
await pinecone.configureIndex(serverlessIndexName, { | ||
tags: { testTag: 'newValue' }, | ||
}); | ||
const description2 = await pinecone.describeIndex(serverlessIndexName); | ||
if (description2.tags != null) { | ||
expect(description2.tags['testTag']).toEqual('newValue'); | ||
} | ||
}); | ||
}); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
undefined != null
, does this block still run?Separately, are tags always returned, even if they're empty? I guess that would be my expectation as a user of the SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question 1:
undefined
does equalnull
.Question2 : Yes!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok, so the conflation of
null
andundefined
are intentional here because tags should always be{}
regardless of whether they've been added to the response or not? That would make sense to me!