Skip to content

Commit

Permalink
reviw comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tulsishah committed Apr 29, 2024
1 parent 133346e commit c065fb7
Showing 1 changed file with 40 additions and 16 deletions.
56 changes: 40 additions & 16 deletions internal/storage/storage_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,6 @@ func (suite *StorageHandleTest) TearDownSuite() {
suite.fakeStorage.ShutDown()
}

func (suite *StorageHandleTest) invokeAndVerifyStorageHandle(sc storageutil.StorageClientConfig) {
handleCreated, err := NewStorageHandle(context.Background(), sc)
suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestBucketHandleWhenBucketExistsWithEmptyBillingProject() {
storageHandle := suite.fakeStorage.CreateStorageHandle()
bucketHandle := storageHandle.BucketHandle(TestBucketName, "")
Expand Down Expand Up @@ -88,28 +82,40 @@ func (suite *StorageHandleTest) TestBucketHandleWhenBucketDoesNotExistWithNonEmp
func (suite *StorageHandleTest) TestNewStorageHandleHttp2Disabled() {
sc := storageutil.GetDefaultStorageClientConfig() // by default http1 enabled

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleHttp2Enabled() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.ClientProtocol = mountpkg.HTTP2

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWithZeroMaxConnsPerHost() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.MaxConnsPerHost = 0

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWhenUserAgentIsSet() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.UserAgent = "gcsfuse/unknown (Go version go1.20-pre3 cl/474093167 +a813be86df) appName (GPN:Gcsfuse-DLC)"

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWithCustomEndpoint() {
Expand All @@ -118,7 +124,10 @@ func (suite *StorageHandleTest) TestNewStorageHandleWithCustomEndpoint() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.CustomEndpoint = url

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

// This will fail while fetching the token-source, since key-file doesn't exist.
Expand All @@ -137,28 +146,40 @@ func (suite *StorageHandleTest) TestNewStorageHandleWhenKeyFileIsEmpty() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.KeyFile = ""

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWhenReuseTokenUrlFalse() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.ReuseTokenFromUrl = false

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWhenTokenUrlIsSet() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.TokenUrl = storageutil.CustomTokenUrl

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWhenJsonReadEnabled() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.ExperimentalEnableJsonRead = true

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestNewStorageHandleWithInvalidClientProtocol() {
Expand Down Expand Up @@ -196,7 +217,10 @@ func (suite *StorageHandleTest) TestNewStorageHandleWithGRPCClientProtocol() {
sc := storageutil.GetDefaultStorageClientConfig()
sc.ClientProtocol = mountpkg.GRPC

suite.invokeAndVerifyStorageHandle(sc)
handleCreated, err := NewStorageHandle(context.Background(), sc)

suite.Nil(err)
suite.NotNil(handleCreated)
}

func (suite *StorageHandleTest) TestCreateGRPCClientHandle_WithHTTPClientProtocol() {
Expand Down

0 comments on commit c065fb7

Please sign in to comment.