-
Notifications
You must be signed in to change notification settings - Fork 3
Fix --tags not being applied to integrated indexes, refactor /index/create.go for unit tests
#51
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
Conversation
…ignatures for index/create.go and add unit to validate arguments are applied as we expect when passed to the SDK
|
Claude finished @austin-denoble's task —— View job PR Review Progress
|
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // Abstracts the Pinecone Go SDK for testing purposes |
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.
Interface abstraction to allow passing in a mock service to represent the SDK in unit tests.
| ReadParameters: &readParams, | ||
| WriteParameters: &writeParams, | ||
| }, | ||
| Tags: indexTags, |
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.
This is the actual "fix" for the bug.
| assert.Equal(t, pinecone.IndexTags(options.tags), *svc.lastIntegrated.Tags) | ||
| } | ||
|
|
||
| func TestCreateIndexOptions_DeriveIndexType(t *testing.T) { |
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.
These tests were moved here from the old index_test.go file since they're focused on index creation anyways.
| github.com/rs/zerolog v1.32.0 | ||
| github.com/spf13/cobra v1.8.0 | ||
| github.com/spf13/viper v1.18.2 | ||
| github.com/stretchr/testify v1.10.0 |
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.
Pulling this in mainly to use the assert stuff for now, because I really don't want to bloat tests further with a bunch of if statements. Eventually would like to use testify for integration suites, etc.
bradumbaugh
left a comment
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.
@austin-denoble This approach makes sense to me, and I see the tags fix in there, too. Probably good to get someone more familiar than me with Go to take a look, though.

Problem
@bradumbaugh flagged a bug around the
--tagsargument not being applied when creating new integrated indexes through the CLI. The argument itself was not being passed to the Go SDK, which was an easy fix.Because of our general lack of unit testing, and the importance of index creation and the business logic that's applied, we really needed unit tests for this command.
Solution
There were a few functional unit tests validating some of the logic around inferring index type, but ultimately we need more coverage around the core logic inside of the
pc index createcommand.--tagsnot being applied to integrated indexes./index/create.gofunction signatures and add an interface to allow for dependency injection and unit testing. None of the logic itself has changed, but I added a newrunCreateIndexWithServicefunction and aCreateIndexServiceinterface to allow injecting a mock Go SDK to allow asserting on what gets provided.Type of Change
Test Plan
Test index creation flows for serverless, integrated, and pod indexes.