Skip to content

Commit

Permalink
make it possible to set a custom http header (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmenglund authored Aug 23, 2023
1 parent a4f9954 commit 338f6cd
Show file tree
Hide file tree
Showing 45 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion query_lambdas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func TestRockClient_CreateQueryLambda(t *testing.T) {
// test fixtures
const (
qlName = "events"
qlVersion = "1921bcad817b5cc2"
qlVersion = "0eb7783c81ef339e"
qlTag = "test"
)

Expand Down
7 changes: 7 additions & 0 deletions rockset.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ func WithHTTPClient(c *http.Client) RockOption {
}
}

// WithCustomHeader sets a custom HTTP header for all Rockset API calls.
func WithCustomHeader(key, value string) RockOption {
return func(rc *RockConfig) {
rc.cfg.AddDefaultHeader(key, value)
}
}

// WithRetry sets the Retrier the RockClient uses to retry requests which return a Error that can be retried.
// The errors which can be retried are configurable using the ExponentialRetry field RetryableErrorCheck.
//
Expand Down
7 changes: 6 additions & 1 deletion rockset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func vcrClient(name string) (*rockset.RockClient, func(string) string, error) {
}

vcr := govcr.NewVCR(govcr.NewCassetteLoader(path), settings...)
options = append(options, rockset.WithHTTPClient(vcr.HTTPClient()))
options = append(options, rockset.WithHTTPClient(vcr.HTTPClient()),
rockset.WithCustomHeader("x-rockset-test", "go-client"))

rc, err := rockset.NewClient(options...)
return rc, randFn, err
Expand Down Expand Up @@ -168,6 +169,10 @@ func vcrSettings(offline bool) []govcr.Setting {
return govcr.DefaultHeaderMatcher(httpRequest, trackRequest)
},
),
govcr.WithTrackRecordingMutators(track.TrackRequestDeleteHeaderKeys(authHeader)),
govcr.WithTrackRecordingMutators(track.ResponseDeleteTLS()),
govcr.WithTrackReplayingMutators(track.TrackRequestDeleteHeaderKeys(authHeader)),
govcr.WithTrackReplayingMutators(track.ResponseDeleteTLS()),
}
if offline {
settings = append(settings, govcr.WithOfflineMode())
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified vcr/CollectionTestSuite/TestGetCollection.cassette.gz
Binary file not shown.
Binary file modified vcr/CollectionTestSuite/TestListAllCollections.cassette.gz
Binary file not shown.
Binary file not shown.
Binary file modified vcr/CollectionTestSuite/TestUpdateCollection.cassette.gz
Binary file not shown.
Binary file modified vcr/IntegrationTestSuite/TestCreateGCSIntegration.cassette.gz
Binary file not shown.
Binary file modified vcr/IntegrationTestSuite/TestCreateS3Integration.cassette.gz
Binary file not shown.
Binary file modified vcr/IntegrationTestSuite/TestGetIntegration.cassette.gz
Binary file not shown.
Binary file modified vcr/IntegrationTestSuite/TestListIntegrations.cassette.gz
Binary file not shown.
Binary file modified vcr/QueryIntegrationSuite/TestAsyncQuery.cassette.gz
Binary file not shown.
Binary file not shown.
Binary file modified vcr/QueryIntegrationSuite/TestCancelQuery.cassette.gz
Binary file not shown.
Binary file modified vcr/QueryIntegrationSuite/TestListQueries.cassette.gz
Binary file not shown.
Binary file modified vcr/QueryIntegrationSuite/TestQuery.cassette.gz
Binary file not shown.
Binary file modified vcr/QueryIntegrationSuite/TestQueryWithTimeout.cassette.gz
Binary file not shown.
Binary file modified vcr/QueryIntegrationSuite/TestValidateQuery.cassette.gz
Binary file not shown.
Binary file modified vcr/TestAliasIntegrationSuite.cassette.gz
Binary file not shown.
Binary file modified vcr/TestAzureIntegrations.cassette.gz
Binary file not shown.
Binary file modified vcr/TestCollectionIntegrationSuite.cassette.gz
Binary file not shown.
Binary file modified vcr/TestDocumentSuite.cassette.gz
Binary file not shown.
Binary file modified vcr/TestError_IsNotFoundError.cassette.gz
Binary file not shown.
Binary file modified vcr/TestListViews.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_CreateQueryLambda.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_GetOrganization.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_GetQueryLambdaVersion.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_GetQueryLambdaVersionByTag.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_ListQueryLambdaTags.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_ListQueryLambdaVersions.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_ListQueryLambdas.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_ListQueryLambdas_workspace.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_Ping.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRockClient_withAPIServerEnv.cassette.gz
Binary file not shown.
Binary file modified vcr/TestRoleIntegration.cassette.gz
Binary file not shown.
Binary file modified vcr/TestSuiteAPIKey.cassette.gz
Binary file not shown.
Binary file modified vcr/TestSuiteWorkspace.cassette.gz
Binary file not shown.
Binary file modified vcr/TestTemplate.cassette.gz
Binary file not shown.
Binary file modified vcr/TestUserIntegration.cassette.gz
Binary file not shown.
Binary file modified vcr/TestViewCRUD.cassette.gz
Binary file not shown.
Binary file modified vcr/TestVirtualInstance.cassette.gz
Binary file not shown.
Binary file modified vcr/TestVirtualInstanceIntegration.cassette.gz
Binary file not shown.
Binary file modified vcr/example_s3.cassette.gz
Binary file not shown.

0 comments on commit 338f6cd

Please sign in to comment.