2020-07-24 09:27:03 +00:00
|
|
|
package clients
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"github.com/qiniu/goc/pkg/qiniu"
|
2020-07-24 11:24:07 +00:00
|
|
|
"os"
|
2020-07-24 09:27:03 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
type MockQnClient struct {
|
2020-07-24 11:24:07 +00:00
|
|
|
QiniuObjectHandleRes qiniu.ObjectHandle
|
|
|
|
ReadObjectRes []byte
|
|
|
|
ReadObjectErr error
|
|
|
|
ListAllRes []string
|
|
|
|
ListAllErr error
|
|
|
|
GetAccessURLRes string
|
|
|
|
GetArtifactDetailsRes *qiniu.LogHistoryTemplate
|
|
|
|
GetArtifactDetailsErr error
|
|
|
|
ListSubDirsRes []string
|
|
|
|
ListSubDirsErr error
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockQnClient) QiniuObjectHandle(key string) qiniu.ObjectHandle {
|
2020-07-24 11:24:07 +00:00
|
|
|
return s.QiniuObjectHandleRes
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockQnClient) ReadObject(key string) ([]byte, error) {
|
2020-07-24 11:24:07 +00:00
|
|
|
return s.ReadObjectRes, s.ReadObjectErr
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockQnClient) ListAll(ctx context.Context, prefix string, delimiter string) ([]string, error) {
|
2020-07-24 11:24:07 +00:00
|
|
|
return s.ListAllRes, s.ListAllErr
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockQnClient) GetAccessURL(key string, timeout time.Duration) string {
|
2020-07-24 11:24:07 +00:00
|
|
|
return s.GetAccessURLRes
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockQnClient) GetArtifactDetails(key string) (*qiniu.LogHistoryTemplate, error) {
|
2020-07-24 11:24:07 +00:00
|
|
|
return s.GetArtifactDetailsRes, s.GetArtifactDetailsErr
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockQnClient) ListSubDirs(prefix string) ([]string, error) {
|
2020-07-24 11:24:07 +00:00
|
|
|
return s.ListSubDirsRes, s.ListSubDirsErr
|
|
|
|
}
|
|
|
|
|
|
|
|
type MockArtifacts struct {
|
|
|
|
ProfilePathRes string
|
|
|
|
CreateChangedProfileRes *os.File
|
|
|
|
GetChangedProfileNameRes string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *MockArtifacts) ProfilePath() string {
|
|
|
|
return s.ProfilePathRes
|
|
|
|
}
|
|
|
|
func (s *MockArtifacts) CreateChangedProfile() *os.File {
|
|
|
|
return s.CreateChangedProfileRes
|
|
|
|
}
|
|
|
|
func (s *MockArtifacts) GetChangedProfileName() string {
|
|
|
|
return s.GetChangedProfileNameRes
|
2020-07-24 09:27:03 +00:00
|
|
|
}
|