Fix: filename and code typo (#260)

* Rename handller.go to handler.go

* Rename handller.go to handler.go

* Rename handller_test.go to handler_test.go

* Rename handller.go to handler.go

* Rename handller.go to handler.go

* Rename handller.go to handler.go

* Rename handller.go to handler.go

* Fix typo
pull/265/head
yeungc 5 years ago committed by GitHub
parent f594d0ab83
commit 6285e45e34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -60,10 +60,10 @@ func TestFileSystem_Upload(t *testing.T) {
asserts := assert.New(t) asserts := assert.New(t)
// 正常 // 正常
testHandller := new(FileHeaderMock) testHandler := new(FileHeaderMock)
testHandller.On("Put", testMock.Anything, testMock.Anything, testMock.Anything).Return(nil) testHandler.On("Put", testMock.Anything, testMock.Anything, testMock.Anything).Return(nil)
fs := &FileSystem{ fs := &FileSystem{
Handler: testHandller, Handler: testHandler,
User: &model.User{ User: &model.User{
Model: gorm.Model{ Model: gorm.Model{
ID: 1, ID: 1,
@ -88,10 +88,10 @@ func TestFileSystem_Upload(t *testing.T) {
asserts.NoError(err) asserts.NoError(err)
// 正常,上下文已指定源文件 // 正常,上下文已指定源文件
testHandller = new(FileHeaderMock) testHandler = new(FileHeaderMock)
testHandller.On("Put", testMock.Anything, testMock.Anything, "123/123.txt").Return(nil) testHandler.On("Put", testMock.Anything, testMock.Anything, "123/123.txt").Return(nil)
fs = &FileSystem{ fs = &FileSystem{
Handler: testHandller, Handler: testHandler,
User: &model.User{ User: &model.User{
Model: gorm.Model{ Model: gorm.Model{
ID: 1, ID: 1,
@ -124,20 +124,20 @@ func TestFileSystem_Upload(t *testing.T) {
err = fs.Upload(ctx, file) err = fs.Upload(ctx, file)
asserts.Error(err) asserts.Error(err)
fs.Hooks["BeforeUpload"] = nil fs.Hooks["BeforeUpload"] = nil
testHandller.AssertExpectations(t) testHandler.AssertExpectations(t)
// 上传文件失败 // 上传文件失败
testHandller2 := new(FileHeaderMock) testHandler2 := new(FileHeaderMock)
testHandller2.On("Put", testMock.Anything, testMock.Anything, testMock.Anything).Return(errors.New("error")) testHandler2.On("Put", testMock.Anything, testMock.Anything, testMock.Anything).Return(errors.New("error"))
fs.Handler = testHandller2 fs.Handler = testHandler2
err = fs.Upload(ctx, file) err = fs.Upload(ctx, file)
asserts.Error(err) asserts.Error(err)
testHandller2.AssertExpectations(t) testHandler2.AssertExpectations(t)
// AfterUpload失败 // AfterUpload失败
testHandller3 := new(FileHeaderMock) testHandler3 := new(FileHeaderMock)
testHandller3.On("Put", testMock.Anything, testMock.Anything, testMock.Anything).Return(nil) testHandler3.On("Put", testMock.Anything, testMock.Anything, testMock.Anything).Return(nil)
fs.Handler = testHandller3 fs.Handler = testHandler3
fs.Use("AfterUpload", func(ctx context.Context, fs *FileSystem) error { fs.Use("AfterUpload", func(ctx context.Context, fs *FileSystem) error {
return errors.New("error") return errors.New("error")
}) })
@ -146,7 +146,7 @@ func TestFileSystem_Upload(t *testing.T) {
}) })
err = fs.Upload(ctx, file) err = fs.Upload(ctx, file)
asserts.Error(err) asserts.Error(err)
testHandller2.AssertExpectations(t) testHandler2.AssertExpectations(t)
} }
@ -180,11 +180,11 @@ func TestFileSystem_GetUploadToken(t *testing.T) {
"upload_credential_timeout": "10", "upload_credential_timeout": "10",
"upload_session_timeout": "10", "upload_session_timeout": "10",
}, "setting_") }, "setting_")
testHandller := new(FileHeaderMock) testHandler := new(FileHeaderMock)
testHandller.On("Token", testMock.Anything, int64(10), testMock.Anything).Return(serializer.UploadCredential{Token: "test"}, nil) testHandler.On("Token", testMock.Anything, int64(10), testMock.Anything).Return(serializer.UploadCredential{Token: "test"}, nil)
fs.Handler = testHandller fs.Handler = testHandler
res, err := fs.GetUploadToken(ctx, "/", 10, "123") res, err := fs.GetUploadToken(ctx, "/", 10, "123")
testHandller.AssertExpectations(t) testHandler.AssertExpectations(t)
asserts.NoError(err) asserts.NoError(err)
asserts.Equal("test", res.Token) asserts.Equal("test", res.Token)
} }
@ -195,11 +195,11 @@ func TestFileSystem_GetUploadToken(t *testing.T) {
"upload_credential_timeout": "10", "upload_credential_timeout": "10",
"upload_session_timeout": "10", "upload_session_timeout": "10",
}, "setting_") }, "setting_")
testHandller := new(FileHeaderMock) testHandler := new(FileHeaderMock)
testHandller.On("Token", testMock.Anything, int64(10), testMock.Anything).Return(serializer.UploadCredential{}, errors.New("error")) testHandler.On("Token", testMock.Anything, int64(10), testMock.Anything).Return(serializer.UploadCredential{}, errors.New("error"))
fs.Handler = testHandller fs.Handler = testHandler
_, err := fs.GetUploadToken(ctx, "/", 10, "123") _, err := fs.GetUploadToken(ctx, "/", 10, "123")
testHandller.AssertExpectations(t) testHandler.AssertExpectations(t)
asserts.Error(err) asserts.Error(err)
} }
} }

Loading…
Cancel
Save