Documentation ¶
Index ¶
- Constants
- Variables
- func AddServer(s *data.Server) error
- func AddServers(ss []data.Server) []string
- func Endpoint(section string) string
- func GenerateUUID() (string, error)
- func Get(section string) (*https.Response, error)
- func GetAuth(section, username, password string) (*https.Response, error)
- func GetID(h http.Header) (int, error)
- func GetIDFromRequest(r *http.Request) int
- func GetIDFromResponse(r *https.Response) int
- func InitDrive(d *data.Drive) (*data.Drive, error)
- func InitJob(j *data.Job) (*data.Job, error)
- func IsStarted() bool
- func Log(t *testing.T, jj []JournalEntry)
- func LogDetail(t *testing.T, j JournalEntry)
- func LogResponse(t *testing.T, r *https.Response)
- func LogURL(t *testing.T, j JournalEntry)
- func PutJournal(id int, name string, r *http.Request, rr *httptest.ResponseRecorder)
- func RemoveServer(uuid string) bool
- func Reset()
- func ResetDrives()
- func ResetServers()
- func SetID(h http.Header, id int)
- func SetServerStatus(uuid, status string)
- func Start()
- func Stop()
- type DriveLibrary
- func (d *DriveLibrary) Add(drv *data.Drive) error
- func (d *DriveLibrary) AddDrives(dd []data.Drive) []string
- func (d *DriveLibrary) Clone(uuid string, params map[string]interface{}) (string, error)
- func (d *DriveLibrary) Remove(uuid string) bool
- func (d *DriveLibrary) Reset()
- func (d *DriveLibrary) Resize(uuid string, size uint64) error
- func (d *DriveLibrary) SetStatus(uuid, status string)
- type JobLibrary
- type JournalEntry
Constants ¶
const ( // TestUser contains account name for log into mock server TestUser = "test@example.com" // TestPassword contains password for log into mock server TestPassword = "test" )
Variables ¶
var Drives = &DriveLibrary{ m: make(map[string]*data.Drive), p: "/api/2.0/drives", }
Drives defines user account drives
var ErrNotFound = errors.New("not found")
ErrNotFound - drive not found in library error
var Jobs = &JobLibrary{ m: make(map[string]*data.Job), p: "/api/2.0/jobs", }
Jobs defines library of all jobs in the mock
var LibDrives = &DriveLibrary{ m: make(map[string]*data.Drive), p: "/api/2.0/libdrives", }
LibDrives defines public drives
Functions ¶
func AddServers ¶
AddServers adds server instance records under the mock
func Endpoint ¶
Endpoint of mock server, represented as string in form 'https://host:port/api/{version}/{section}'. Panic if server is not started.
func GetIDFromRequest ¶
GetIDFromRequest returns journal ID from HTTP request
func GetIDFromResponse ¶
GetIDFromResponse returns journal ID from HTTP response
func LogDetail ¶
func LogDetail(t *testing.T, j JournalEntry)
LogDetail writes detailed information about journal entry to testing log
func LogResponse ¶
LogResponse log journal entries associated with response to testing log
func LogURL ¶
func LogURL(t *testing.T, j JournalEntry)
LogURL writes URL from journal entry to testing log
func PutJournal ¶
PutJournal adds record to specified journal
func RemoveServer ¶
RemoveServer removes server instance record from the mock
func ResetServers ¶
func ResetServers()
ResetServers removes all server instance records from the mock
func SetServerStatus ¶
func SetServerStatus(uuid, status string)
SetServerStatus changes status of server instance in the mock
Types ¶
type DriveLibrary ¶
type DriveLibrary struct {
// contains filtered or unexported fields
}
DriveLibrary defines type for mock drive library
func (*DriveLibrary) Add ¶
func (d *DriveLibrary) Add(drv *data.Drive) error
Add drive to the library
func (*DriveLibrary) AddDrives ¶
func (d *DriveLibrary) AddDrives(dd []data.Drive) []string
AddDrives adds drive collection to the library
func (*DriveLibrary) Clone ¶
func (d *DriveLibrary) Clone(uuid string, params map[string]interface{}) (string, error)
Clone drive in the library
func (*DriveLibrary) Remove ¶
func (d *DriveLibrary) Remove(uuid string) bool
Remove drive from the library
func (*DriveLibrary) Resize ¶
func (d *DriveLibrary) Resize(uuid string, size uint64) error
Resize drive in the library
func (*DriveLibrary) SetStatus ¶
func (d *DriveLibrary) SetStatus(uuid, status string)
SetStatus sets drive status in the library
type JobLibrary ¶
type JobLibrary struct {
// contains filtered or unexported fields
}
JobLibrary type to store all jobs in the mock
func (*JobLibrary) AddJobs ¶
func (j *JobLibrary) AddJobs(jj []data.Job) []string
AddJobs adds job collection to the libraryh
func (*JobLibrary) Remove ¶
func (j *JobLibrary) Remove(uuid string) bool
Remove job from the library
func (*JobLibrary) SetState ¶
func (j *JobLibrary) SetState(uuid, state string)
SetState for the job in the library
type JournalEntry ¶
type JournalEntry struct { Name string Request *http.Request Response *httptest.ResponseRecorder }
JournalEntry contains single journal record
func GetJournal ¶
func GetJournal(id int) []JournalEntry
GetJournal retrivies record from specified journal