mirror of
https://github.com/minio/minio.git
synced 2025-11-06 20:33:07 -05:00
Add support for helm package info in useragent (#4592)
This commit is contained in:
committed by
Harshavardhana
parent
ba6d997d18
commit
7bd1f44491
@@ -235,6 +235,48 @@ func TestIsKubernetes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Tests if the environment we are running is Helm chart.
|
||||
func TestGetHelmVersion(t *testing.T) {
|
||||
createTempFile := func(content string) string {
|
||||
tmpfile, err := ioutil.TempFile("", "helm-testfile-")
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create temporary file. %s", err)
|
||||
}
|
||||
if _, err = tmpfile.Write([]byte(content)); err != nil {
|
||||
t.Fatalf("Unable to create temporary file. %s", err)
|
||||
}
|
||||
if err = tmpfile.Close(); err != nil {
|
||||
t.Fatalf("Unable to create temporary file. %s", err)
|
||||
}
|
||||
return tmpfile.Name()
|
||||
}
|
||||
|
||||
filename := createTempFile(
|
||||
`app="virtuous-rat-minio"
|
||||
chart="minio-0.1.3"
|
||||
heritage="Tiller"
|
||||
pod-template-hash="818089471"`)
|
||||
|
||||
defer os.Remove(filename)
|
||||
|
||||
testCases := []struct {
|
||||
filename string
|
||||
expectedResult string
|
||||
}{
|
||||
{"", ""},
|
||||
{"/tmp/non-existing-file", ""},
|
||||
{filename, "minio-0.1.3"},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
result := getHelmVersion(testCase.filename)
|
||||
|
||||
if testCase.expectedResult != result {
|
||||
t.Fatalf("result: expected: %v, got: %v", testCase.expectedResult, result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Tests if the environment we are running is in docker.
|
||||
func TestIsDocker(t *testing.T) {
|
||||
createTempFile := func(content string) string {
|
||||
|
||||
Reference in New Issue
Block a user