diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b21b5e2..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,73 +0,0 @@ -# Use the latest 2.1 version of CircleCI pipeline process engine. -# See: https://circleci.com/docs/2.0/configuration-reference -version: 2.1 - -# Define a job to be invoked later in a workflow. -# See: https://circleci.com/docs/2.0/configuration-reference/#jobs -jobs: - lint: - docker: - - image: golangci/golangci-lint:v1.33-alpine - environment: - GO111MODULE: 'on' - steps: - - checkout - - restore_cache: - keys: - - go-mod-v4-{{ checksum "go.sum" }} - - run: - name: Install Dependencies - command: go mod download - - save_cache: - key: go-mod-v4-{{ checksum "go.sum" }} - paths: - - '/go/pkg/mod' - - run: - name: golangci-lint - command: golangci-lint run -v - - run: - name: Install revive - command: cd / && go get -u github.com/mgechev/revive@v1.0.2 && cd - - - run: - name: revive - command: revive -config .revive.toml -formatter friendly ./... - test: - docker: - - image: cimg/go:1.17.5 - - name: db - image: typesense/typesense:26.0 - command: /opt/typesense-server --data-dir=/tmp --api-key=test_key - steps: - - checkout - - restore_cache: - keys: - - go-mod-v1-{{ checksum "go.sum" }} - - run: - name: Install Dependencies - command: go mod download - - save_cache: - key: go-mod-v1-{{ checksum "go.sum" }} - paths: - - '/home/circleci/go/pkg/mod' - - run: - name: Run tests - environment: - CGO_ENABLED: '0' - TYPESENSE_URL: 'http://db:8108' - TYPESENSE_API_KEY: 'test_key' - command: | - mkdir -p /tmp/test-reports - gotestsum --junitfile /tmp/test-reports/unit-tests.xml -- -tags=integration ./... - - run: - name: Build - command: go build ./... - - store_test_results: - path: /tmp/test-reports - -workflows: - test: - jobs: - - lint - - test: - requires: - - lint diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml new file mode 100644 index 0000000..9783f4d --- /dev/null +++ b/.github/workflows/golangci-lint.yml @@ -0,0 +1,33 @@ +name: golangci-lint + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +permissions: + # Required: allow read access to the content for analysis. + contents: read + # Optional: allow read access to pull request. Use with `only-new-issues` option. + pull-requests: read + # Optional: Allow write access to checks to allow the action to annotate code in the PR. + checks: write + +jobs: + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-go@v5 + with: + go-version: stable + + - name: golangci-lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.59 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..460f0e7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,46 @@ +name: Test + +on: + push: + paths-ignore: + - '**/*.md' + pull_request: + paths-ignore: + - '**/*.md' + +jobs: + test: + runs-on: ubuntu-latest + services: + typesense: + image: typesense/typesense:26.0 + ports: + - 8108:8108/tcp + volumes: + - /tmp/typesense-server-data:/data + env: + TYPESENSE_DATA_DIR: '/data' + TYPESENSE_API_KEY: 'test_key' + TYPESENSE_ENABLE_CORS: true + TYPESENSE_URL: 'http://localhost:8108' + + steps: + - uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: 'stable' + + - name: Install dependencies + run: go mod download + + - name: Build + run: go build -v ./... + + - name: Run tests + env: + TYPESENSE_URL: 'http://localhost:8108' + TYPESENSE_API_KEY: 'test_key' + CGO_ENABLED: 1 + run: go run gotest.tools/gotestsum@latest --format github-actions -- -tags=integration ./... -race -shuffle=on diff --git a/.golangci.yml b/.golangci.yml index 8f16ae6..fce0858 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -9,16 +9,26 @@ linters: - gocyclo - gofmt - goimports - - golint - gosec - - maligned - misspell - nestif - prealloc - - unconvert + # - unconvert - unparam - disable: - - structcheck + - revive + +linters-settings: + # govet: + # enable: + # - fieldalignment + revive: + rules: + # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#var-naming + - name: var-naming + severity: warning + exclude: [""] + arguments: + - ["ID"] # AllowList run: timeout: 3m @@ -31,3 +41,7 @@ issues: - linters: - funlen path: _test\.go + - linters: + - errcheck + path: _test\.go + diff --git a/README.md b/README.md index 49337d8..9d80aac 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # typesense-go [![Build Status](https://cloud.drone.io/api/badges/typesense/typesense-go/status.svg)](https://cloud.drone.io/typesense/typesense-go) -[![GoReportCard Status](https://goreportcard.com/badge/github.com/typesense/typesense-go)](https://goreportcard.com/report/github.com/typesense/typesense-go) -[![Go Reference](https://pkg.go.dev/badge/github.com/typesense/typesense-go.svg)](https://pkg.go.dev/github.com/typesense/typesense-go) +[![GoReportCard Status](https://goreportcard.com/badge/github.com/typesense/typesense-go/v2)](https://goreportcard.com/report/github.com/typesense/typesense-go/v2) +[![Go Reference](https://pkg.go.dev/badge/github.com/typesense/typesense-go/v2.svg)](https://pkg.go.dev/github.com/typesense/typesense-go/v2) [![GitHub release](https://img.shields.io/github/v/release/typesense/typesense-go)](https://github.com/typesense/typesense-go/releases/latest) [![Gitter](https://badges.gitter.im/typesense-go/community.svg)](https://gitter.im/typesense-go/community) @@ -11,7 +11,7 @@ Go client for the Typesense API: https://github.com/typesense/typesense ## Installation ``` -go get github.com/typesense/typesense-go +go get github.com/typesense/typesense-go/v2 ``` ## Usage @@ -19,7 +19,7 @@ go get github.com/typesense/typesense-go Import the the package into your code : ```go -import "github.com/typesense/typesense-go/typesense" +import "github.com/typesense/typesense-go/v2/typesense" ``` Create new client: diff --git a/go.mod b/go.mod index 6d341cf..259741a 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/typesense/typesense-go +module github.com/typesense/typesense-go/v2 go 1.18 diff --git a/typesense/alias.go b/typesense/alias.go index 7462d46..92dd25f 100644 --- a/typesense/alias.go +++ b/typesense/alias.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // AliasInterface is a type for Alias API operations diff --git a/typesense/alias_test.go b/typesense/alias_test.go index 58720bf..5c5c54e 100644 --- a/typesense/alias_test.go +++ b/typesense/alias_test.go @@ -6,10 +6,10 @@ import ( "net/http" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func TestCollectionAliasRetrieve(t *testing.T) { diff --git a/typesense/aliases.go b/typesense/aliases.go index 539b1b9..cd8b33a 100644 --- a/typesense/aliases.go +++ b/typesense/aliases.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // AliasesInterface is a type for Aliases API operations diff --git a/typesense/aliases_test.go b/typesense/aliases_test.go index e682b31..2925efa 100644 --- a/typesense/aliases_test.go +++ b/typesense/aliases_test.go @@ -6,13 +6,13 @@ import ( "net/http" "testing" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" - "go.uber.org/mock/gomock" "github.com/jinzhu/copier" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func createNewCollectionAlias(collectionName string, name string) *api.CollectionAlias { diff --git a/typesense/api/circuit/gobreaker_test.go b/typesense/api/circuit/gobreaker_test.go index 67cc297..6e58e9f 100644 --- a/typesense/api/circuit/gobreaker_test.go +++ b/typesense/api/circuit/gobreaker_test.go @@ -34,7 +34,7 @@ func TestGoBreakerSettingsOptions(t *testing.T) { return counts.Requests > 10 && (float64(counts.TotalFailures)/float64(counts.Requests)) > 0.4 } - onStateChange := func(name string, from gobreaker.State, to gobreaker.State) {} + onStateChange := func(_ string, _ gobreaker.State, _ gobreaker.State) {} tests := []struct { name string options []GoBreakerOption diff --git a/typesense/api/circuit/http_client.go b/typesense/api/circuit/http_client.go index 3cc91ec..c393422 100644 --- a/typesense/api/circuit/http_client.go +++ b/typesense/api/circuit/http_client.go @@ -5,7 +5,7 @@ package circuit import ( "net/http" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type HTTPRequestDoer interface { diff --git a/typesense/api/circuit/http_client_test.go b/typesense/api/circuit/http_client_test.go index 758d494..c6ecc2b 100644 --- a/typesense/api/circuit/http_client_test.go +++ b/typesense/api/circuit/http_client_test.go @@ -5,9 +5,9 @@ import ( "net/http" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api/circuit/mocks" + "github.com/typesense/typesense-go/v2/typesense/api/circuit/mocks" + "go.uber.org/mock/gomock" ) func newHTTPRequest(t *testing.T) *http.Request { diff --git a/typesense/api/client.go b/typesense/api/client.go index 0ce296f..ce03473 100644 --- a/typesense/api/client.go +++ b/typesense/api/client.go @@ -5,11 +5,11 @@ import ( "net/http" ) -const APIKeyHeader = "X-TYPESENSE-API-KEY" +const APIKeyHeader = "X-TYPESENSE-API-KEY" // #nosec G101 func WithAPIKey(apiKey string) ClientOption { return func(c *Client) error { - c.RequestEditors = []RequestEditorFn{func(ctx context.Context, req *http.Request) error { + c.RequestEditors = []RequestEditorFn{func(_ context.Context, req *http.Request) error { req.Header.Add(APIKeyHeader, apiKey) return nil }} diff --git a/typesense/api/generator/main.go b/typesense/api/generator/main.go index 4f66b9c..d932b09 100644 --- a/typesense/api/generator/main.go +++ b/typesense/api/generator/main.go @@ -25,7 +25,7 @@ type MapKV struct { } func sortedSlice(params map[string]interface{}) []MapKV { - var kvs []MapKV + kvs := []MapKV{} for k, v := range params { kvs = append(kvs, MapKV{k, v}) diff --git a/typesense/api_call.go b/typesense/api_call.go index 6908bf1..54ac719 100644 --- a/typesense/api_call.go +++ b/typesense/api_call.go @@ -5,10 +5,10 @@ import ( "net/url" "time" - "github.com/typesense/typesense-go/typesense/api/circuit" + "github.com/typesense/typesense-go/v2/typesense/api/circuit" ) -type ApiCall struct { +type APICall struct { client circuit.HTTPRequestDoer nearestNode *Node nodes []Node @@ -32,10 +32,10 @@ const ( UNHEALTHY = false ) -type ApiCallOption func(*ApiCall) +type APICallOption func(*APICall) -func NewApiCall(client circuit.HTTPRequestDoer, config *ClientConfig) *ApiCall { - apiCall := &ApiCall{ +func NewAPICall(client circuit.HTTPRequestDoer, config *ClientConfig) *APICall { + apiCall := &APICall{ currentNodeIndex: -1, healthcheckInterval: config.HealthcheckInterval, client: client, @@ -56,7 +56,7 @@ func NewApiCall(client circuit.HTTPRequestDoer, config *ClientConfig) *ApiCall { return apiCall } -func (a *ApiCall) Do(req *http.Request) (*http.Response, error) { +func (a *APICall) Do(req *http.Request) (*http.Response, error) { // Default is to not load balance for backward compatibility if len(a.nodes) == 0 { res, err := a.client.Do(req) @@ -73,7 +73,7 @@ func (a *ApiCall) Do(req *http.Request) (*http.Response, error) { response, err := a.client.Do(req) - // If conection timeouts or status 5xx, retry + // If connection timeouts or status 5xx, retry with the next node if err != nil || response.StatusCode >= 500 { lastResponse = response lastError = err @@ -92,7 +92,7 @@ func (a *ApiCall) Do(req *http.Request) (*http.Response, error) { return lastResponse, lastError } -func (a *ApiCall) getNextNode() *Node { +func (a *APICall) getNextNode() *Node { if a.nearestNode != nil && (a.nearestNode.isHealthy || a.nodeDueForHealthcheck(a.nearestNode)) { return a.nearestNode } @@ -110,7 +110,7 @@ func (a *ApiCall) getNextNode() *Node { return candidateNode } -func (a *ApiCall) initializeNodesMetadata(config *ClientConfig) { +func (a *APICall) initializeNodesMetadata(config *ClientConfig) { if config.NearestNode != "" { a.nearestNode = &Node{index: "nearestNode", url: config.NearestNode} setNodeHealthCheck(a.nearestNode, HEALTHY) @@ -121,8 +121,8 @@ func (a *ApiCall) initializeNodesMetadata(config *ClientConfig) { } } -func replaceRequestHostname(req *http.Request, URL string) { - newURL, _ := url.Parse(URL) +func replaceRequestHostname(req *http.Request, urlToReplace string) { + newURL, _ := url.Parse(urlToReplace) req.URL.Scheme = newURL.Scheme req.URL.Host = newURL.Host @@ -134,6 +134,6 @@ func setNodeHealthCheck(node *Node, isHealthy bool) { node.lastAccessTimestamp = apiCallTimeNow().UnixMilli() } -func (a *ApiCall) nodeDueForHealthcheck(node *Node) bool { +func (a *APICall) nodeDueForHealthcheck(node *Node) bool { return apiCallTimeNow().UnixMilli()-node.lastAccessTimestamp > a.healthcheckInterval.Milliseconds() } diff --git a/typesense/api_call_test.go b/typesense/api_call_test.go index 344e131..0704d8d 100644 --- a/typesense/api_call_test.go +++ b/typesense/api_call_test.go @@ -22,8 +22,8 @@ func newHTTPRequest(t *testing.T, urls ...string) *http.Request { return req } -func newApiCall(apiConfig *ClientConfig) *ApiCall { - return NewApiCall( +func newAPICall(apiConfig *ClientConfig) *APICall { + return NewAPICall( &http.Client{ Timeout: apiConfig.ConnectionTimeout, }, @@ -51,15 +51,15 @@ func freezeUnixMilli(msec int64) { // * When NearestNode is not specified func TestApiCallDoesNotRetryWhenStatusCodeIs3xxOr4xx(t *testing.T) { - requestUrlHistory := make([]string, 0, 2) + requestURLHistory := make([]string, 0, 2) servers, serverURLs := instantiateServers([]serverHandler{ func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(301) }, func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(409) }, }) @@ -67,7 +67,7 @@ func TestApiCallDoesNotRetryWhenStatusCodeIs3xxOr4xx(t *testing.T) { defer server.Close() } - apiCall := newApiCall( + apiCall := newAPICall( &ClientConfig{ Nodes: serverURLs, ConnectionTimeout: 5 * time.Second, @@ -83,7 +83,7 @@ func TestApiCallDoesNotRetryWhenStatusCodeIs3xxOr4xx(t *testing.T) { assert.NoError(t, err2) assert.Equal(t, 409, res2.StatusCode) - assert.Equal(t, serverURLs, requestUrlHistory) + assert.Equal(t, serverURLs, requestURLHistory) } type timeoutError struct { @@ -109,24 +109,24 @@ func (m *mockClient) Do(req *http.Request) (*http.Response, error) { } } func TestApiCallSelectNextNodeWhenTimeOut(t *testing.T) { - requestUrlHistory := make([]string, 0, 3) + requestURLHistory := make([]string, 0, 3) servers, serverURLs := instantiateServers([]serverHandler{ - func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + func(_ http.ResponseWriter, r *http.Request) { + requestURLHistory = append(requestURLHistory, "http://"+r.Host) }, - func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + func(_ http.ResponseWriter, r *http.Request) { + requestURLHistory = append(requestURLHistory, "http://"+r.Host) }, - func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + func(_ http.ResponseWriter, r *http.Request) { + requestURLHistory = append(requestURLHistory, "http://"+r.Host) }, }) for _, server := range servers { defer server.Close() } - apiCall := NewApiCall( + apiCall := NewAPICall( &mockClient{}, &ClientConfig{ Nodes: serverURLs, @@ -139,17 +139,17 @@ func TestApiCallSelectNextNodeWhenTimeOut(t *testing.T) { assert.Error(t, err) assert.Nil(t, res) - assert.Equal(t, serverURLs, requestUrlHistory) + assert.Equal(t, serverURLs, requestURLHistory) } func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { - requestUrlHistory := make([]string, 0, 8) + requestURLHistory := make([]string, 0, 8) var count int servers, serverURLs := instantiateServers([]serverHandler{ func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) if count > 1 { - // will response sucessful after 2 failed request + // will response successful code after 2 failed request w.WriteHeader(201) } else { count++ @@ -157,11 +157,11 @@ func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { } }, func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(501) }, func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(202) }, }) @@ -172,7 +172,7 @@ func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { apiCallTimeNow = time.Now }() - apiCall := newApiCall( + apiCall := newAPICall( &ClientConfig{ Nodes: serverURLs, HealthcheckInterval: 20 * time.Millisecond, @@ -187,7 +187,7 @@ func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 202, res.StatusCode) - assert.Equal(t, serverURLs, requestUrlHistory[:3]) + assert.Equal(t, serverURLs, requestURLHistory[:3]) freezeUnixMilli(10) @@ -195,7 +195,7 @@ func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 202, res2.StatusCode) - assert.Equal(t, serverURLs[2], requestUrlHistory[3]) + assert.Equal(t, serverURLs[2], requestURLHistory[3]) freezeUnixMilli(25) @@ -203,7 +203,7 @@ func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 202, res3.StatusCode) - assert.Equal(t, serverURLs, requestUrlHistory[4:7]) + assert.Equal(t, serverURLs, requestURLHistory[4:7]) freezeUnixMilli(50) @@ -211,19 +211,19 @@ func TestApiCallRemoveAndAddUnhealthyNodeIntoRotation(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 201, res4.StatusCode) - assert.Equal(t, serverURLs[0], requestUrlHistory[len(requestUrlHistory)-1]) + assert.Equal(t, serverURLs[0], requestURLHistory[len(requestURLHistory)-1]) } // * When NearestNode is specified func TestApiCallWithNearestNode(t *testing.T) { - requestUrlHistory := make([]string, 0, 10) + requestURLHistory := make([]string, 0, 10) var count int servers, serverURLs := instantiateServers([]serverHandler{ func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) if count > 1 { - // will response sucessful after 2 failed request + // will response successful code after 2 failed request w.WriteHeader(201) } else { count++ @@ -231,15 +231,15 @@ func TestApiCallWithNearestNode(t *testing.T) { } }, func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(502) }, func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(503) }, func(w http.ResponseWriter, r *http.Request) { - requestUrlHistory = append(requestUrlHistory, "http://"+r.Host) + requestURLHistory = append(requestURLHistory, "http://"+r.Host) w.WriteHeader(202) }, }) @@ -250,7 +250,7 @@ func TestApiCallWithNearestNode(t *testing.T) { apiCallTimeNow = time.Now }() - apiCall := newApiCall( + apiCall := newAPICall( &ClientConfig{ NearestNode: serverURLs[0], Nodes: serverURLs[1:], @@ -267,7 +267,7 @@ func TestApiCallWithNearestNode(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 202, res.StatusCode) - assert.Equal(t, serverURLs, requestUrlHistory[:4]) + assert.Equal(t, serverURLs, requestURLHistory[:4]) freezeUnixMilli(10) @@ -275,7 +275,7 @@ func TestApiCallWithNearestNode(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 202, res2.StatusCode) - assert.Equal(t, serverURLs[3], requestUrlHistory[4]) + assert.Equal(t, serverURLs[3], requestURLHistory[4]) freezeUnixMilli(25) @@ -283,7 +283,7 @@ func TestApiCallWithNearestNode(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 202, res3.StatusCode) - assert.Equal(t, serverURLs, requestUrlHistory[5:9]) + assert.Equal(t, serverURLs, requestURLHistory[5:9]) freezeUnixMilli(50) @@ -291,12 +291,12 @@ func TestApiCallWithNearestNode(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 201, res4.StatusCode) - assert.Equal(t, serverURLs[0], requestUrlHistory[9]) + assert.Equal(t, serverURLs[0], requestURLHistory[9]) res5, err := apiCall.Do(req) // request should still be made to nearest node assert.NoError(t, err) assert.Equal(t, 201, res5.StatusCode) - assert.Equal(t, serverURLs[0], requestUrlHistory[len(requestUrlHistory)-1]) + assert.Equal(t, serverURLs[0], requestURLHistory[len(requestURLHistory)-1]) } func TestApiCallCompatibleWithServerURL(t *testing.T) { @@ -310,7 +310,7 @@ func TestApiCallCompatibleWithServerURL(t *testing.T) { }) defer servers[0].Close() - apiCall := newApiCall( + apiCall := newAPICall( &ClientConfig{ ServerURL: serverURLs[0], ConnectionTimeout: 5 * time.Second, @@ -328,13 +328,13 @@ func TestApiCallCanReplaceRequestHostName(t *testing.T) { var lastRequestURL string servers, serverURLs := instantiateServers([]serverHandler{ - func(w http.ResponseWriter, r *http.Request) { + func(_ http.ResponseWriter, r *http.Request) { lastRequestURL = "http://" + r.Host + r.RequestURI }, }) defer servers[0].Close() - apiCall := newApiCall( + apiCall := newAPICall( &ClientConfig{ Nodes: serverURLs, ConnectionTimeout: 5 * time.Second, diff --git a/typesense/client.go b/typesense/client.go index 67a9897..3f7199f 100644 --- a/typesense/client.go +++ b/typesense/client.go @@ -7,8 +7,8 @@ import ( "net/http" "time" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/circuit" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/circuit" ) type APIClientInterface interface { @@ -114,16 +114,16 @@ func WithServer(serverURL string) ClientOption { } // WithNearestNode sets the Load Balanced endpoint. -func WithNearestNode(URL string) ClientOption { +func WithNearestNode(nodeURL string) ClientOption { return func(c *Client) { - c.apiConfig.NearestNode = URL + c.apiConfig.NearestNode = nodeURL } } // WithNodes sets multiple hostnames to load balance reads & writes across all nodes. -func WithNodes(URLs []string) ClientOption { +func WithNodes(nodeURLs []string) ClientOption { return func(c *Client) { - c.apiConfig.Nodes = URLs + c.apiConfig.Nodes = nodeURLs } } @@ -270,7 +270,7 @@ func NewClient(opts ...ClientOption) *Client { ) httpClient := circuit.NewHTTPClient( circuit.WithHTTPRequestDoer( - NewApiCall( + NewAPICall( &http.Client{ Timeout: c.apiConfig.ConnectionTimeout, }, diff --git a/typesense/client_test.go b/typesense/client_test.go index 45c1c58..6fc634a 100644 --- a/typesense/client_test.go +++ b/typesense/client_test.go @@ -7,8 +7,8 @@ import ( "github.com/sony/gobreaker" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/circuit" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/circuit" ) func TestHttpError(t *testing.T) { @@ -31,7 +31,7 @@ func TestClientConfigOptions(t *testing.T) { return counts.Requests > 10 && (float64(counts.TotalFailures)/float64(counts.Requests)) > 0.4 } - onStateChange := func(name string, from gobreaker.State, to gobreaker.State) {} + onStateChange := func(_ string, _ gobreaker.State, _ gobreaker.State) {} tests := []struct { name string options []ClientOption diff --git a/typesense/collection.go b/typesense/collection.go index 0e5b2f9..68ef5cc 100644 --- a/typesense/collection.go +++ b/typesense/collection.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // CollectionInterface is a type for Collection API operations diff --git a/typesense/collection_test.go b/typesense/collection_test.go index 0df44d2..e19e96a 100644 --- a/typesense/collection_test.go +++ b/typesense/collection_test.go @@ -6,11 +6,11 @@ import ( "net/http" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func updateExistingSchema() *api.CollectionUpdateSchema { diff --git a/typesense/collections.go b/typesense/collections.go index 9566798..3b0227a 100644 --- a/typesense/collections.go +++ b/typesense/collections.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // CollectionsInterface is a type for Collections API operations diff --git a/typesense/collections_test.go b/typesense/collections_test.go index e0a57df..a4bd469 100644 --- a/typesense/collections_test.go +++ b/typesense/collections_test.go @@ -6,12 +6,12 @@ import ( "net/http" "testing" - "go.uber.org/mock/gomock" "github.com/jinzhu/copier" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func createNewSchema(collectionName string) *api.CollectionSchema { diff --git a/typesense/document_test.go b/typesense/document_test.go index 4221cba..6ee38bf 100644 --- a/typesense/document_test.go +++ b/typesense/document_test.go @@ -5,9 +5,9 @@ import ( "errors" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func TestDocumentRetrieve(t *testing.T) { diff --git a/typesense/documents.go b/typesense/documents.go index 72ec7c9..9d8134e 100644 --- a/typesense/documents.go +++ b/typesense/documents.go @@ -8,7 +8,7 @@ import ( "io" "net/http" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) var upsertAction api.IndexDocumentParamsAction = "upsert" diff --git a/typesense/documents_test.go b/typesense/documents_test.go index b4192f1..b8e09c0 100644 --- a/typesense/documents_test.go +++ b/typesense/documents_test.go @@ -9,11 +9,11 @@ import ( "strings" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func createNewDocument(docIDs ...string) interface{} { diff --git a/typesense/health_test.go b/typesense/health_test.go index 02440c3..25f6caf 100644 --- a/typesense/health_test.go +++ b/typesense/health_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func TestHealthStatus(t *testing.T) { diff --git a/typesense/import_test.go b/typesense/import_test.go index 2eaaa58..0aaf30a 100644 --- a/typesense/import_test.go +++ b/typesense/import_test.go @@ -11,11 +11,11 @@ import ( "strings" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) type eqReaderMatcher struct { diff --git a/typesense/key.go b/typesense/key.go index 09df17b..f1037db 100644 --- a/typesense/key.go +++ b/typesense/key.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type KeyInterface interface { diff --git a/typesense/key_test.go b/typesense/key_test.go index c494764..8d369ec 100644 --- a/typesense/key_test.go +++ b/typesense/key_test.go @@ -6,12 +6,12 @@ import ( "net/http" "testing" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func TestKeyRetrieve(t *testing.T) { diff --git a/typesense/keys.go b/typesense/keys.go index 5695300..f5cfb4b 100644 --- a/typesense/keys.go +++ b/typesense/keys.go @@ -8,7 +8,7 @@ import ( "encoding/json" "fmt" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type KeysInterface interface { diff --git a/typesense/keys_test.go b/typesense/keys_test.go index 0494bee..5e3585d 100644 --- a/typesense/keys_test.go +++ b/typesense/keys_test.go @@ -7,12 +7,12 @@ import ( "testing" "time" - "go.uber.org/mock/gomock" "github.com/jinzhu/copier" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func createNewKeySchema() *api.ApiKeySchema { diff --git a/typesense/mocks/mock_client.go b/typesense/mocks/mock_client.go index 7168f2c..b0a403c 100644 --- a/typesense/mocks/mock_client.go +++ b/typesense/mocks/mock_client.go @@ -15,7 +15,7 @@ import ( http "net/http" reflect "reflect" - api "github.com/typesense/typesense-go/typesense/api" + api "github.com/typesense/typesense-go/v2/typesense/api" gomock "go.uber.org/mock/gomock" ) diff --git a/typesense/multi_search.go b/typesense/multi_search.go index 3ddd450..580afcd 100644 --- a/typesense/multi_search.go +++ b/typesense/multi_search.go @@ -6,7 +6,7 @@ import ( "encoding/json" "io" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type MultiSearchInterface interface { diff --git a/typesense/multi_search_test.go b/typesense/multi_search_test.go index 6558d96..da019e6 100644 --- a/typesense/multi_search_test.go +++ b/typesense/multi_search_test.go @@ -9,11 +9,11 @@ import ( "bytes" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func newMultiSearchParams() *api.MultiSearchParams { diff --git a/typesense/operations.go b/typesense/operations.go index fbafd98..810c276 100644 --- a/typesense/operations.go +++ b/typesense/operations.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type OperationsInterface interface { diff --git a/typesense/operations_test.go b/typesense/operations_test.go index ef17c16..f5ed504 100644 --- a/typesense/operations_test.go +++ b/typesense/operations_test.go @@ -6,10 +6,10 @@ import ( "net/http" "testing" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) const snapshotPath = "/tmp/typesense-data-snapshot" diff --git a/typesense/override.go b/typesense/override.go index 7d84f65..a44d8d6 100644 --- a/typesense/override.go +++ b/typesense/override.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // OverrideInterface is a type for Search Override API operations diff --git a/typesense/override_test.go b/typesense/override_test.go index 7c2d185..fc3b7c0 100644 --- a/typesense/override_test.go +++ b/typesense/override_test.go @@ -6,12 +6,12 @@ import ( "net/http" "testing" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func TestSearchOverrideRetrieve(t *testing.T) { diff --git a/typesense/overrides.go b/typesense/overrides.go index d6c509c..2eadddb 100644 --- a/typesense/overrides.go +++ b/typesense/overrides.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // OverridesInterface is a type for Search Overrides API operations diff --git a/typesense/overrides_test.go b/typesense/overrides_test.go index f486339..3278fb1 100644 --- a/typesense/overrides_test.go +++ b/typesense/overrides_test.go @@ -6,13 +6,13 @@ import ( "net/http" "testing" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" - "go.uber.org/mock/gomock" "github.com/jinzhu/copier" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func createNewSearchOverrideSchema() *api.SearchOverrideSchema { diff --git a/typesense/preset.go b/typesense/preset.go index 4072a23..ecc519e 100644 --- a/typesense/preset.go +++ b/typesense/preset.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type PresetInterface interface { diff --git a/typesense/preset_test.go b/typesense/preset_test.go index 7137045..7eb3757 100644 --- a/typesense/preset_test.go +++ b/typesense/preset_test.go @@ -6,7 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func TestPresetRetrieveAsSearchParameters(t *testing.T) { diff --git a/typesense/presets.go b/typesense/presets.go index 0691f38..b2d1074 100644 --- a/typesense/presets.go +++ b/typesense/presets.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) type PresetsInterface interface { diff --git a/typesense/presets_test.go b/typesense/presets_test.go index 12c1a69..6bc8352 100644 --- a/typesense/presets_test.go +++ b/typesense/presets_test.go @@ -7,7 +7,7 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func TestPresetsRetrieveAsSearchParameters(t *testing.T) { diff --git a/typesense/search_test.go b/typesense/search_test.go index 7529062..de9ea65 100644 --- a/typesense/search_test.go +++ b/typesense/search_test.go @@ -8,9 +8,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/mocks" "go.uber.org/mock/gomock" ) diff --git a/typesense/synonym.go b/typesense/synonym.go index 9e9eeb5..9c5287a 100644 --- a/typesense/synonym.go +++ b/typesense/synonym.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // SynonymInterface is a type for Search Synonym API operations diff --git a/typesense/synonym_test.go b/typesense/synonym_test.go index 933aca3..1b6db43 100644 --- a/typesense/synonym_test.go +++ b/typesense/synonym_test.go @@ -6,12 +6,12 @@ import ( "net/http" "testing" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" - "go.uber.org/mock/gomock" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func TestSearchSynonymRetrieve(t *testing.T) { diff --git a/typesense/synonyms.go b/typesense/synonyms.go index 90ea22d..1e2bc8d 100644 --- a/typesense/synonyms.go +++ b/typesense/synonyms.go @@ -3,7 +3,7 @@ package typesense import ( "context" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) // SynonymsInterface is a type for Search Synonyms API operations diff --git a/typesense/synonyms_test.go b/typesense/synonyms_test.go index c25f48f..7e98613 100644 --- a/typesense/synonyms_test.go +++ b/typesense/synonyms_test.go @@ -6,13 +6,13 @@ import ( "net/http" "testing" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" - "go.uber.org/mock/gomock" "github.com/jinzhu/copier" "github.com/stretchr/testify/assert" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/mocks" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/mocks" + "go.uber.org/mock/gomock" ) func createNewSearchSynonymSchema() *api.SearchSynonymSchema { diff --git a/typesense/test/alias_test.go b/typesense/test/alias_test.go index cd13638..6d4775e 100644 --- a/typesense/test/alias_test.go +++ b/typesense/test/alias_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func TestCollectionAliasRetrieve(t *testing.T) { diff --git a/typesense/test/aliases_test.go b/typesense/test/aliases_test.go index 75ace0a..bb25106 100644 --- a/typesense/test/aliases_test.go +++ b/typesense/test/aliases_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func TestCollectionAliasUpsertNewAlias(t *testing.T) { diff --git a/typesense/test/collection_test.go b/typesense/test/collection_test.go index 01f5c9b..1e8f043 100644 --- a/typesense/test/collection_test.go +++ b/typesense/test/collection_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestCollectionRetrieve(t *testing.T) { diff --git a/typesense/test/collections_test.go b/typesense/test/collections_test.go index 284b60d..cbc664e 100644 --- a/typesense/test/collections_test.go +++ b/typesense/test/collections_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestCollectionCreate(t *testing.T) { diff --git a/typesense/test/dbhelpers_test.go b/typesense/test/dbhelpers_test.go index 10e5820..8fea813 100644 --- a/typesense/test/dbhelpers_test.go +++ b/typesense/test/dbhelpers_test.go @@ -11,8 +11,8 @@ import ( "github.com/google/uuid" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func newUUIDName(namePrefix string) string { diff --git a/typesense/test/doc.go b/typesense/test/doc.go index adf83bc..87b454a 100644 --- a/typesense/test/doc.go +++ b/typesense/test/doc.go @@ -1,3 +1,3 @@ // Package test contains integration tests for the -// github.com/typesense/typesense-go/typesense package. +// github.com/typesense/typesense-go/v2/typesense package. package test diff --git a/typesense/test/document_test.go b/typesense/test/document_test.go index 2faaeba..ce21af1 100644 --- a/typesense/test/document_test.go +++ b/typesense/test/document_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense" + "github.com/typesense/typesense-go/v2/typesense" ) func TestDocumentRetrieveGeneric(t *testing.T) { diff --git a/typesense/test/documents_test.go b/typesense/test/documents_test.go index 1a458f5..f13769a 100644 --- a/typesense/test/documents_test.go +++ b/typesense/test/documents_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestDocumentCreate(t *testing.T) { diff --git a/typesense/test/import_test.go b/typesense/test/import_test.go index ba7e0e7..6ba8fe5 100644 --- a/typesense/test/import_test.go +++ b/typesense/test/import_test.go @@ -10,8 +10,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestDocumentsImport(t *testing.T) { diff --git a/typesense/test/keys_test.go b/typesense/test/keys_test.go index 268b307..0d12ba7 100644 --- a/typesense/test/keys_test.go +++ b/typesense/test/keys_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func TestKeyCreate(t *testing.T) { diff --git a/typesense/test/main_test.go b/typesense/test/main_test.go index 8b82bf3..b7dedd8 100644 --- a/typesense/test/main_test.go +++ b/typesense/test/main_test.go @@ -1,3 +1,4 @@ +//go:build integration // +build integration package test @@ -7,7 +8,7 @@ import ( "os" "testing" - "github.com/typesense/typesense-go/typesense" + "github.com/typesense/typesense-go/v2/typesense" ) var typesenseClient *typesense.Client diff --git a/typesense/test/multi_search_test.go b/typesense/test/multi_search_test.go index f68b68a..2e70c1b 100644 --- a/typesense/test/multi_search_test.go +++ b/typesense/test/multi_search_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestMultiSearch(t *testing.T) { diff --git a/typesense/test/overrides_test.go b/typesense/test/overrides_test.go index 3c7694c..14e6abf 100644 --- a/typesense/test/overrides_test.go +++ b/typesense/test/overrides_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func TestSearchOverrideUpsertNewOverride(t *testing.T) { diff --git a/typesense/test/presets_test.go b/typesense/test/presets_test.go index b61b344..ac999bb 100644 --- a/typesense/test/presets_test.go +++ b/typesense/test/presets_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api" ) func presetsCleanUp() { diff --git a/typesense/test/search_test.go b/typesense/test/search_test.go index e83f52f..e8945af 100644 --- a/typesense/test/search_test.go +++ b/typesense/test/search_test.go @@ -8,8 +8,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestCollectionSearch(t *testing.T) { diff --git a/typesense/test/setupdb_docker_test.go b/typesense/test/setupdb_docker_test.go index 5e22c48..fd4118f 100644 --- a/typesense/test/setupdb_docker_test.go +++ b/typesense/test/setupdb_docker_test.go @@ -1,3 +1,4 @@ +//go:build integration && docker // +build integration,docker package test @@ -12,8 +13,8 @@ import ( "github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go/wait" - "github.com/typesense/typesense-go/typesense" - "github.com/typesense/typesense-go/typesense/api" + "github.com/typesense/typesense-go/v2/typesense" + "github.com/typesense/typesense-go/v2/typesense/api" ) var typesenseC testcontainers.Container diff --git a/typesense/test/setupdb_test.go b/typesense/test/setupdb_test.go index 833624d..bb32089 100644 --- a/typesense/test/setupdb_test.go +++ b/typesense/test/setupdb_test.go @@ -9,7 +9,7 @@ import ( "os" "time" - "github.com/typesense/typesense-go/typesense" + "github.com/typesense/typesense-go/v2/typesense" ) func waitHealthyStatus(client *typesense.Client, timeout time.Duration) error { diff --git a/typesense/test/synonym_test.go b/typesense/test/synonym_test.go index 3766298..f03acc3 100644 --- a/typesense/test/synonym_test.go +++ b/typesense/test/synonym_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestSearchSynonymRetrieve(t *testing.T) { diff --git a/typesense/test/synonyms_test.go b/typesense/test/synonyms_test.go index 550d375..7e3a2e1 100644 --- a/typesense/test/synonyms_test.go +++ b/typesense/test/synonyms_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/typesense/typesense-go/typesense/api" - "github.com/typesense/typesense-go/typesense/api/pointer" + "github.com/typesense/typesense-go/v2/typesense/api" + "github.com/typesense/typesense-go/v2/typesense/api/pointer" ) func TestSearchSynonymUpsertNewSynonym(t *testing.T) {