testdrive

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package testdrive is an internal httptest fixture for Drive, Docs, and Sheets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(t testing.TB, fx *FX, holder *vfs.TokenHolder) vfs.Open

Open builds Drive, Docs, and Sheets SDK clients against this fixture over httptest.

Types

type FX

type FX struct {
	Nodes   map[string]*Node
	Exports int

	DocsBatches []vfs.DocsBatch
	// contains filtered or unexported fields
}

FX is an in-memory Drive tree that speaks Drive v3, Docs, and Sheets HTTP.

func New

func New() *FX

New returns an empty fixture.

func Tree

func Tree() *FX

Tree is the shared Drive fixture used by mount tests.

func (*FX) Add

func (d *FX) Add(parent string, meta vfs.DriveMeta, body []byte)

Add inserts a node.

func (*FX) FailDocBatch

func (d *FX) FailDocBatch()

FailDocBatch makes documents.batchUpdate return HTTP 400 (ErrInvalidWrite).

func (*FX) FailMeta

func (d *FX) FailMeta(status int)

FailMeta makes every metadata GET return HTTP status.

func (*FX) FailNextDocWrites

func (d *FX) FailNextDocWrites(n int)

FailNextDocWrites makes the next n documents.batchUpdate calls return a revision conflict.

func (*FX) OnceMedia

func (d *FX) OnceMedia(id string, status int)

OnceMedia makes the next media GET for id return HTTP status.

func (*FX) SeedDoc

func (d *FX) SeedDoc(id, rev string, spans []vfs.DocsSpan, tabs []vfs.DocTab)

SeedDoc sets documents.get state for id.

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)

func (*FX) SetDocRev

func (d *FX) SetDocRev(id, rev string)

SetDocRev is an out-of-band revision bump (CAS tests).

func (*FX) SheetSnap

func (d *FX) SheetSnap(id string) vfs.SheetsSnapshot

SheetSnap is a copy of the seeded workbook (CAS / out-of-band mutation tests).

type Node

type Node struct {
	Meta   vfs.DriveMeta
	Parent string
	Body   []byte
	Export []byte
}

Node is one Drive file or folder in the fixture.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL