dtestutils

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Overview

Package dtestutils contains test utilities for testing the dolt command line.

Index

Constants

View Source
const (
	IdTag uint64 = iota
	NameTag
	AgeTag
	IsMarriedTag
	TitleTag
	NextTag // leave last
)
View Source
const (
	TableName = "people"
	IndexName = "idx_name"
)
View Source
const (
	TestHomeDir = "/user/bheni"
	WorkingDir  = "/user/bheni/datasets/states"
)

Variables

View Source
var Ages = []uint64{32, 25, 21}
View Source
var FloatComparer = cmp.Comparer(func(x, y types.Float) bool {
	return math.Abs(float64(x)-float64(y)) < .001
})

Compares two noms Floats for approximate equality

View Source
var MaritalStatus = []bool{true, false, false}
View Source
var Names = []string{"Bill Billerson", "John Johnson", "Rob Robertson"}
View Source
var TimestampComparer = cmp.Comparer(func(x, y types.Timestamp) bool {
	return x.Equals(y)
})
View Source
var Titles = []string{"Senior Dufus", "Dufus", ""}
View Source
var TypedRows []row.Row
View Source
var TypedSchema = schema.MustSchemaFromCols(typedColColl)

modified by init()

View Source
var UUIDS = []uuid.UUID{
	uuid.Must(uuid.Parse("00000000-0000-0000-0000-000000000000")),
	uuid.Must(uuid.Parse("00000000-0000-0000-0000-000000000001")),
	uuid.Must(uuid.Parse("00000000-0000-0000-0000-000000000002"))}
View Source
var UntypedRows []row.Row
View Source
var UntypedSchema, _ = untyped.UntypeSchema(TypedSchema)

modified by init()

Functions

func AddColToRows

func AddColToRows(t *testing.T, rs []row.Row, tag uint64, val types.Value) []row.Row

AddColToRows adds a column to all the rows given and returns it. This method relies on the fact that noms_row.SetColVal doesn't need a full schema, just one that includes the column being set.

func AddColumnToSchema

func AddColumnToSchema(sch schema.Schema, col schema.Column) schema.Schema

AddColumnToSchema returns a new schema by adding the given column to the given schema. Will panic on an invalid schema, e.g. tag collision. Note the AddColumnToSchema relies on being called from the engine (GMS) to correctly update defaults. Directly calling this method in Dolt only adds a new column to schema but does not apply the default.

func ConvertToSchema

func ConvertToSchema(sch schema.Schema, rs ...row.Row) []row.Row

Coerces the rows given into the schema given. Only possible if the types are equivalent.

func CreateEnvWithSeedData

func CreateEnvWithSeedData(t *testing.T) *env.DoltEnv

func CreateSchema

func CreateSchema(columns ...schema.Column) schema.Schema

CreateSchema returns a schema from the columns given, panicking on any errors.

func CreateTestDataTable

func CreateTestDataTable(typed bool) (*table.InMemTable, schema.Schema)

func CreateTestEnv

func CreateTestEnv() *env.DoltEnv

func CreateTestTable

func CreateTestTable(t *testing.T, dEnv *env.DoltEnv, tableName string, sch schema.Schema, rs ...row.Row)

CreateTestTable creates a new test table with the name, schema, and rows given.

func MustMap

func MustMap(t *testing.T, vrw types.ValueReadWriter, kv ...types.Value) types.Map

MustMap contructs a types.Map for a slice of alternating key, value types.Value.

func MustRowData

func MustRowData(t *testing.T, ctx context.Context, vrw types.ValueReadWriter, sch schema.Schema, colVals []row.TaggedValues) *types.Map

MustRowData converts a slice of row.TaggedValues into a noms types.Map containing that data.

func MustSchema

func MustSchema(cols ...schema.Column) schema.Schema

MustSchema takes a variable number of columns and returns a schema.

func MustTuple

func MustTuple(vals ...types.Value) types.Tuple

MustMap contructs a types.Tuple for a slice of types.Values.

func NewRow

func NewRow(sch schema.Schema, values ...types.Value) row.Row

Creates a row with the schema given, having the values given. Starts at tag 0 and counts up.

func NewTypedRow

func NewTypedRow(id uuid.UUID, name string, age uint, isMarried bool, title *string) row.Row

func RemoveColumnFromSchema

func RemoveColumnFromSchema(sch schema.Schema, tagToRemove uint64) schema.Schema

RemoveColumnFromSchema returns a new schema with the given tag missing, but otherwise identical. At least one primary column must remain.

Types

This section is empty.

Directories

Path Synopsis
Package testcommands TODO: kill off this package, replace with the non-test commands directly
Package testcommands TODO: kill off this package, replace with the non-test commands directly

Jump to

Keyboard shortcuts

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