-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
279: Feature/Analytics r=alallema a=brunoocasali - Add `User-Agent` inside the pre-defined headers Add Go support as requested here meilisearch/integration-guides#150 I tried other options, but they do not fit so well: - https://pkg.go.dev/debug/buildinfo (does not work very well :/ has a lot of issues golang/go#29814, golang/go#33975 - https://github.com/ahmetb/govvv (I think it is not an option since it seems to be not maintained anymore). Co-authored-by: Bruno Casali <brunoocasali@gmail.com> Co-authored-by: Amélie <alallema@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package meilisearch | ||
|
||
import "fmt" | ||
|
||
const VERSION = "0.19.1" | ||
|
||
func GetQualifiedVersion() (qualifiedVersion string) { | ||
return getQualifiedVersion(VERSION) | ||
} | ||
|
||
func getQualifiedVersion(version string) (qualifiedVersion string) { | ||
return fmt.Sprintf("Meilisearch Go (v%s)", version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package meilisearch | ||
|
||
import ( | ||
"testing" | ||
"fmt" | ||
"regexp" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestVersion_GetQualifiedVersion(t *testing.T) { | ||
version := GetQualifiedVersion() | ||
|
||
require.NotNil(t, version) | ||
require.Equal(t, version, fmt.Sprintf("Meilisearch Go (v%s)", VERSION)) | ||
} | ||
|
||
func TestVersion_qualifiedVersionFormat(t *testing.T) { | ||
version := getQualifiedVersion("2.2.5") | ||
|
||
require.NotNil(t, version) | ||
require.Equal(t, version, "Meilisearch Go (v2.2.5)") | ||
} | ||
|
||
func TestVersion_constVERSIONFormat(t *testing.T) { | ||
match, _ := regexp.MatchString("[0-9]+.[0-9]+.[0-9]+", VERSION) | ||
|
||
assert.True(t, match) | ||
} |