Skip to content

Commit

Permalink
TEMP
Browse files Browse the repository at this point in the history
  • Loading branch information
brunoocasali committed Apr 2, 2022
1 parent 4f14edd commit 7aac214
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func (c *Client) sendRequest(req *internalRequest, internalError *Error, respons
request.Header.Set("Authorization", "Bearer "+c.config.APIKey)
}

request.Header.Set("User-Agent", GetQualifiedVersion())

// request is sent
if c.config.Timeout != 0 {
err = c.httpClient.DoTimeout(request, response, c.config.Timeout)
Expand Down
4 changes: 2 additions & 2 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ func TestClient_GenerateTenantToken(t *testing.T) {
args: args{
UID: "TestGenerateTenantTokenWithoutApiKey",
client: NewClient(ClientConfig{
Host: "http://localhost:7700",
Host: "http://meilisearch:7700",
APIKey: "",
}),
searchRules: map[string]interface{}{
Expand Down Expand Up @@ -1072,7 +1072,7 @@ func TestClient_GenerateTenantToken(t *testing.T) {
}

client := NewClient(ClientConfig{
Host: "http://localhost:7700",
Host: "http://meilisearch:7700",
APIKey: token,
})

Expand Down
15 changes: 15 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package meilisearch

import (
"fmt"
)

const VERSION = "0.19.0"

func GetQualifiedVersion() (qualifiedVersion string) {
return getQualifiedVersion(VERSION)
}

func getQualifiedVersion(version string) (qualifiedVersion string) {
return fmt.Sprintf("Meilisearch (v%s)", version)
}
17 changes: 17 additions & 0 deletions version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package meilisearch

import (
"testing"
"fmt"

"github.com/stretchr/testify/require"
)

func TestClient_PackageVersion(t *testing.T) {
t.Run("TestPackageVersion", func(t *testing.T) {
version := GetQualifiedVersion()

require.NotNil(t, version)
require.Equal(t, version, fmt.Sprintf("Meilisearch (v%s)", VERSION))
})
}

0 comments on commit 7aac214

Please sign in to comment.