Documentation
¶
Overview ¶
Package testdrive is an internal httptest fixture for Drive, Docs, and Sheets.
Index ¶
- func Open(t testing.TB, fx *FX, holder *vfs.TokenHolder) vfs.Open
- type FX
- func (d *FX) Add(parent string, meta vfs.DriveMeta, body []byte)
- func (d *FX) Fail(f Fault)
- func (d *FX) FailDocBatch()
- func (d *FX) FailNextDocWrites(n int)
- func (d *FX) SeedDoc(id, rev string, spans []vfs.DocsSpan, tabs []vfs.DocTab)
- func (d *FX) SeedSheet(id string, snap vfs.SheetsSnapshot)
- func (d *FX) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (d *FX) SetDocRev(id, rev string)
- func (d *FX) SheetSnap(id string) vfs.SheetsSnapshot
- type Fault
- type Node
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FX ¶
FX is an in-memory Drive tree that speaks Drive v3, Docs, and Sheets HTTP.
func (*FX) Fail ¶ added in v0.5.0
Fail plans f. The faults that match one call occur in the order they were planned.
func (*FX) FailDocBatch ¶
func (d *FX) FailDocBatch()
FailDocBatch makes the next documents.batchUpdate call return HTTP 400 (ErrInvalidWrite).
func (*FX) FailNextDocWrites ¶
FailNextDocWrites makes the next n documents.batchUpdate calls return a revision conflict.
func (*FX) SeedSheet ¶
func (d *FX) SeedSheet(id string, snap vfs.SheetsSnapshot)
SeedSheet sets spreadsheets.get state for id.
func (*FX) ServeHTTP ¶
func (d *FX) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP answers the Drive v3, Docs v1 and Sheets v4 calls of the vfs clients. A request with no bearer token gets 401.
type Fault ¶ added in v0.5.0
type Fault struct {
// Call is the API method that fails: files.get, files.media,
// files.list, files.export, files.create, files.update, documents.get,
// documents.batchUpdate, spreadsheets.get, spreadsheets.batchUpdate or
// spreadsheets.values.batchUpdate.
Call string
// ID is the file, document or spreadsheet the call names (the folder
// for files.list). An empty ID matches every call.
ID string
// Skip is the number of matching calls that pass before the fault.
Skip int
// Status is the HTTP status of the Google error reply.
Status int
// Message is the message of the Google error reply.
Message string
// Cut answers 200 and then drops the connection in the body. It is
// for drops: a request that gets no reply at all is sent again by
// net/http, so the call does not fail.
Cut bool
// Then runs when the fault occurs, before the reply.
Then func()
}
Fault is one planned failure of a call to the fixture.
Click to show internal directories.
Click to hide internal directories.