forked from GoogleCloudPlatform/gcsfuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain_test.go
74 lines (55 loc) · 2.06 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package main
import (
"fmt"
"os"
"strings"
"testing"
mountpkg "github.com/googlecloudplatform/gcsfuse/internal/mount"
. "github.com/jacobsa/ogletest"
)
func Test_Main(t *testing.T) { RunTests(t) }
////////////////////////////////////////////////////////////////////////
// Boilerplate
////////////////////////////////////////////////////////////////////////
type MainTest struct {
}
func init() { RegisterTestSuite(&MainTest{}) }
func (t *MainTest) TestCreateStorageHandle() {
flags := &flagStorage{
ClientProtocol: mountpkg.HTTP1,
MaxConnsPerHost: 5,
MaxIdleConnsPerHost: 100,
HttpClientTimeout: 5,
MaxRetryDuration: 7,
RetryMultiplier: 2,
AppName: "app",
KeyFile: "testdata/test_creds.json",
}
storageHandle, err := createStorageHandle(flags)
AssertEq(nil, err)
AssertNe(nil, storageHandle)
}
func (t *MainTest) TestGetUserAgentWhenMetadataImageTypeEnvVarIsSet() {
os.Setenv("GCSFUSE_METADATA_IMAGE_TYPE", "DLVM")
defer os.Unsetenv("GCSFUSE_METADATA_IMAGE_TYPE")
userAgent := getUserAgent("AppName")
expectedUserAgent := strings.TrimSpace(fmt.Sprintf("gcsfuse/%s AppName (GPN:gcsfuse-DLVM)", getVersion()))
ExpectEq(expectedUserAgent, userAgent)
}
func (t *MainTest) TestGetUserAgentWhenMetadataImageTypeEnvVarIsNotSet() {
userAgent := getUserAgent("AppName")
expectedUserAgent := strings.TrimSpace(fmt.Sprintf("gcsfuse/%s (GPN:gcsfuse-AppName)", getVersion()))
ExpectEq(expectedUserAgent, userAgent)
}
func (t *MainTest) TestGetUserAgentWhenMetadataImageTypeEnvVarAndAppNameAreNotSet() {
userAgent := getUserAgent("")
expectedUserAgent := strings.TrimSpace(fmt.Sprintf("gcsfuse/%s (GPN:gcsfuse)", getVersion()))
ExpectEq(expectedUserAgent, userAgent)
}
func (t *MainTest) TestGetUserAgentWhenMetadataImageTypeEnvVarSetAndAppNameNotSet() {
os.Setenv("GCSFUSE_METADATA_IMAGE_TYPE", "DLVM")
defer os.Unsetenv("GCSFUSE_METADATA_IMAGE_TYPE")
userAgent := getUserAgent("")
expectedUserAgent := strings.TrimSpace(fmt.Sprintf("gcsfuse/%s (GPN:gcsfuse-DLVM)", getVersion()))
ExpectEq(expectedUserAgent, userAgent)
}