Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TemplateOp ¶
type TemplateOp string
type TemplateRuntime ¶
type TemplateRuntime struct {
// contains filtered or unexported fields
}
func (*TemplateRuntime) Close ¶
func (rt *TemplateRuntime) Close()
func (*TemplateRuntime) RunStep ¶
func (rt *TemplateRuntime) RunStep(ctx context.Context, s *TemplateStep) (*TemplateStepResult, error)
RunStep executes the database command on a user DB.
type TemplateStep ¶
type TemplateStep struct { // Op holds the test action, which is one of the templateOps defined above. Op TemplateOp Database string Transaction string Snapshot string Iterator string Key string Value string Next bool Begin string End string Error string // contains filtered or unexported fields }
TemplateStep represents a sinlge database command for a transaction or snapshot or an iterator. It is defined as a string in the following format:
db:%s new-transaction => error:nil, tx:%s tx:%s get key:%s => error:ErrNotExist tx:%s set key:%s value:%s tx:%s get key:%s => value:%s tx:%s delete key:%s tx:%s get key:%s => error:ErrNotExist tx:%s commit => tx:%s rollback => error:non-nil
db:%s new-snapshot => snap:%s snap:%s get key:%s => error:ErrNotExist value:%s snap:%s discard
tx:%s ascend begin:%s end:%s => nil it:%s
it:%s fetch next:true => key:%s value:%s error:%s
Database commands above are parsed and validated into an object which can be used to run the command on a user database.
func ParseTemplateStep ¶
func ParseTemplateStep(s string) (*TemplateStep, error)
ParseTemplateStep parses input string into a database command.
func (*TemplateStep) String ¶
func (s *TemplateStep) String() string
type TemplateStepResult ¶
type TemplateStepResult struct { Step *TemplateStep Status error Key string Value io.Reader Iterator kv.Iterator Snapshot kv.Snapshot Transaction kv.Transaction }
TemplateStepResult holds the result of a TemplateStep execution.
func RunTemplateTest ¶
func RunTemplateTest(ctx context.Context, text string, dbs ...kv.Database) ([]*TemplateStepResult, error)
RunTemplateTest runs all database operations in the input template serially one-after-another in the order defined in the template.
type TemplateTest ¶
type TemplateTest struct {
Steps []*TemplateStep
}
func ParseTemplateTest ¶
func ParseTemplateTest(r io.Reader) (*TemplateTest, error)
func (*TemplateTest) WithKeyPrefix ¶
func (t *TemplateTest) WithKeyPrefix(prefix string) (*TemplateTest, error)
WithKeyPrefix returns a new test with the given prefix added to all keys. Templates with `scan` operator or empty values for `begin` and `end` are not supported.