package tests

import "github.com/datastax/astra-db-go/v2/integration/legacy/tests"

Index

Functions

func AdminCreateDropDatabase

func AdminCreateDropDatabase(e *harness.TestEnv) error

func AdminFindAvailableRegionsFilterByOrg

func AdminFindAvailableRegionsFilterByOrg(e *harness.TestEnv) error

func AdminFindAvailableRegionsNoFilter

func AdminFindAvailableRegionsNoFilter(e *harness.TestEnv) error

func AdminGetDatabaseNotFound

func AdminGetDatabaseNotFound(e *harness.TestEnv) error

func AdminKeyspaceCreateListDrop

func AdminKeyspaceCreateListDrop(e *harness.TestEnv) error

func AdminListDatabases

func AdminListDatabases(e *harness.TestEnv) error

func AdminListDatabasesPaginated

func AdminListDatabasesPaginated(e *harness.TestEnv) error

func CollectionCount

func CollectionCount(e *harness.TestEnv) error

func CollectionCountUpperBound

func CollectionCountUpperBound(e *harness.TestEnv) error

func CollectionCreate

func CollectionCreate(e *harness.TestEnv) error

func CollectionCursorPagination

func CollectionCursorPagination(e *harness.TestEnv) error

CollectionCursorPagination tests server-side cursor pagination by inserting enough documents to span multiple pages and iterating through them all.

The Data API typically returns ~20 documents per page, so we insert 50+ documents to ensure we get multiple pages.

func CollectionDeleteOne

func CollectionDeleteOne(e *harness.TestEnv) error

func CollectionDrop

func CollectionDrop(e *harness.TestEnv) error

func CollectionEstimatedCount

func CollectionEstimatedCount(e *harness.TestEnv) error

func CollectionFind

func CollectionFind(e *harness.TestEnv) error

func CollectionFindCombined

func CollectionFindCombined(e *harness.TestEnv) error

CollectionFindCombined tests filter, sort, projection, and limit together Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#use-filter-sort-and-projection-together

func CollectionFindOne

func CollectionFindOne(e *harness.TestEnv) error

func CollectionFindOneAndDelete

func CollectionFindOneAndDelete(e *harness.TestEnv) error

func CollectionFindOneAndDeleteProjection

func CollectionFindOneAndDeleteProjection(e *harness.TestEnv) error

func CollectionFindOneAndReplace

func CollectionFindOneAndReplace(e *harness.TestEnv) error

func CollectionFindOneAndReplaceAfter

func CollectionFindOneAndReplaceAfter(e *harness.TestEnv) error

func CollectionFindOneAndReplaceProjection

func CollectionFindOneAndReplaceProjection(e *harness.TestEnv) error

func CollectionFindOneAndReplaceUpsert

func CollectionFindOneAndReplaceUpsert(e *harness.TestEnv) error

func CollectionFindOneAndUpdate

func CollectionFindOneAndUpdate(e *harness.TestEnv) error

func CollectionFindOneAndUpdateAfter

func CollectionFindOneAndUpdateAfter(e *harness.TestEnv) error

func CollectionFindOneAndUpdateProjection

func CollectionFindOneAndUpdateProjection(e *harness.TestEnv) error

func CollectionFindOneAndUpdateUpsert

func CollectionFindOneAndUpdateUpsert(e *harness.TestEnv) error

func CollectionFindWithLimit

func CollectionFindWithLimit(e *harness.TestEnv) error

CollectionFindWithLimit tests limiting results Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#example-limit

func CollectionFindWithProjection

func CollectionFindWithProjection(e *harness.TestEnv) error

CollectionFindWithProjection tests field projection Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#example-include

func CollectionFindWithSkip

func CollectionFindWithSkip(e *harness.TestEnv) error

CollectionFindWithSkip tests skipping documents Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#example-skip

func CollectionFindWithSort

func CollectionFindWithSort(e *harness.TestEnv) error

CollectionFindWithSort tests ascending/descending sort Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#example-sort

func CollectionInsertMany

func CollectionInsertMany(e *harness.TestEnv) error

func CollectionItemAlreadyExists

func CollectionItemAlreadyExists(e *harness.TestEnv) error

func CollectionListCollectionNames

func CollectionListCollectionNames(e *harness.TestEnv) error

func CollectionListCollections

func CollectionListCollections(e *harness.TestEnv) error

func CollectionNestedCreate

func CollectionNestedCreate(e *harness.TestEnv) error

CollectionNestedCreate creates a collection for nested document tests.

func CollectionNestedDrop

func CollectionNestedDrop(e *harness.TestEnv) error

CollectionNestedDrop cleans up the nested test collection.

func CollectionNestedFindByNestedField

func CollectionNestedFindByNestedField(e *harness.TestEnv) error

CollectionNestedFindByNestedField queries restaurants using a dot-notation filter on a nested field.

func CollectionNestedFindOne

func CollectionNestedFindOne(e *harness.TestEnv) error

CollectionNestedFindOne retrieves a Restaurant by ID and verifies all nested data round-trips correctly.

func CollectionNestedInsertMany

func CollectionNestedInsertMany(e *harness.TestEnv) error

CollectionNestedInsertMany inserts multiple Restaurants with nested data.

func CollectionNestedInsertOne

func CollectionNestedInsertOne(e *harness.TestEnv) error

CollectionNestedInsertOne inserts a single Restaurant and verifies the insert succeeded.

func CollectionOptions

func CollectionOptions(e *harness.TestEnv) error

func CollectionReplaceOne

func CollectionReplaceOne(e *harness.TestEnv) error

func CollectionReplaceOneNoMatch

func CollectionReplaceOneNoMatch(e *harness.TestEnv) error

func CollectionReplaceOneUpsert

func CollectionReplaceOneUpsert(e *harness.TestEnv) error

func CollectionUpdateMany

func CollectionUpdateMany(e *harness.TestEnv) error

func CollectionUpdateManyNoMatch

func CollectionUpdateManyNoMatch(e *harness.TestEnv) error

func CollectionUpdateManyUpsert

func CollectionUpdateManyUpsert(e *harness.TestEnv) error

func CollectionUpdateOne

func CollectionUpdateOne(e *harness.TestEnv) error

func CollectionUpdateOneNoMatch

func CollectionUpdateOneNoMatch(e *harness.TestEnv) error

func CollectionUpdateOneUpsert

func CollectionUpdateOneUpsert(e *harness.TestEnv) error

func CollectionVectorCollectionDrop

func CollectionVectorCollectionDrop(e *harness.TestEnv) error

CollectionVectorCollectionDrop cleans up the vector test collection

func CollectionVectorCreate

func CollectionVectorCreate(e *harness.TestEnv) error

CollectionVectorCreate creates a vector-enabled collection for testing

func CollectionVectorInsert

func CollectionVectorInsert(e *harness.TestEnv) error

CollectionVectorInsert inserts test documents with vector embeddings

func CollectionVectorSearch

func CollectionVectorSearch(e *harness.TestEnv) error

CollectionVectorSearch tests basic vector similarity search Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#example-vector

func CollectionVectorSearchWithSimilarity

func CollectionVectorSearchWithSimilarity(e *harness.TestEnv) error

CollectionVectorSearchWithSimilarity tests vector search with similarity scores Based on: https://docs.datastax.com/en/astra-db-serverless/api-reference/document-methods/find-many.html#example-similarity

func DbFindEmbeddingProvidersDefault

func DbFindEmbeddingProvidersDefault(e *harness.TestEnv) error

DbFindEmbeddingProvidersDefault calls FindEmbeddingProviders with no options and validates the response structure: at least one provider, each with a non-empty DisplayName/URL, at least one model with a non-empty name.

func DbFindEmbeddingProvidersFilterAll

func DbFindEmbeddingProvidersFilterAll(e *harness.TestEnv) error

DbFindEmbeddingProvidersFilterAll calls FindEmbeddingProviders with ModelLifecycleStatusAll, which should include models of every lifecycle status. The result must be structurally valid and contain at least as many total models as the default (SUPPORTED-only) call.

func DbFindEmbeddingProvidersFilterDeprecated

func DbFindEmbeddingProvidersFilterDeprecated(e *harness.TestEnv) error

DbFindEmbeddingProvidersFilterDeprecated calls FindEmbeddingProviders filtering for DEPRECATED models. The call must succeed; any returned models must carry DEPRECATED status.

func DbFindEmbeddingProvidersFilterSupported

func DbFindEmbeddingProvidersFilterSupported(e *harness.TestEnv) error

DbFindEmbeddingProvidersFilterSupported explicitly passes ModelLifecycleStatusSupported and verifies every returned model carries that status.

func DbFindEmbeddingProvidersHuggingFaceDedicated

func DbFindEmbeddingProvidersHuggingFaceDedicated(e *harness.TestEnv) error

DbFindEmbeddingProvidersHuggingFaceDedicated verifies the huggingfaceDedicated examples from the doc comments:

func DbFindEmbeddingProvidersNvidia

func DbFindEmbeddingProvidersNvidia(e *harness.TestEnv) error

DbFindEmbeddingProvidersNvidia verifies the concrete nvidia examples from the doc comments:

func DbFindEmbeddingProvidersOpenAI

func DbFindEmbeddingProvidersOpenAI(e *harness.TestEnv) error

DbFindEmbeddingProvidersOpenAI verifies the concrete openai examples from the doc comments:

func TableAlter

func TableAlter(e *harness.TestEnv) error

TableAlter exercises alterTable end-to-end against a freshly-created throwaway table.

func TableCreate

func TableCreate(e *harness.TestEnv) error

func TableDrop

func TableDrop(e *harness.TestEnv) error

func TableDuration

func TableDuration(e *harness.TestEnv) (err error)

TableDuration is self-contained: creates a table, exercises insert/find with Duration values, then drops the table.

func TableFind

func TableFind(e *harness.TestEnv) error

func TableFindOne

func TableFindOne(e *harness.TestEnv) error

func TableFindWithCursor

func TableFindWithCursor(e *harness.TestEnv) error

TableFindWithCursor demonstrates iterating with Next/Decode pattern

func TableFindWithProjection

func TableFindWithProjection(e *harness.TestEnv) error

func TableFindWithSort

func TableFindWithSort(e *harness.TestEnv) error

func TableInsertMany

func TableInsertMany(e *harness.TestEnv) error

func TableInsertOne

func TableInsertOne(e *harness.TestEnv) error

func TableListIndexes

func TableListIndexes(e *harness.TestEnv) error

func TableListTables

func TableListTables(e *harness.TestEnv) error

TableListTables tests listing tables with both names-only and full metadata (explain=true). This should be run after TableCreate and before TableDrop. One of the things I have thought about is improving how `IntegrationTest` registers tests to allow running single tests that have dependencies. Something like:

type IntegrationTest struct {
	Name string
	Run  func(e *TestEnv) error
	DependsOn []string // Ensure these have run before this test
	CleanUp   []string // Ensure these tests run after this test
}

That would allow us to set `TEST_PREFIX=TableListTables` and just run this test with dependencies. Right now, to test ListTables you need to run all the table tests (`TEST_PREFIX=Table`).

func TableVectorIndex

func TableVectorIndex(e *harness.TestEnv) error

Types

type Address

type Address struct {
	Building    string    `json:"building"`
	Coordinates []float64 `json:"coordinates"`
	Street      string    `json:"street"`
	ZipCode     string    `json:"zipCode"`
}

type Book

type Book struct {
	ID                *string `json:"_id,omitempty"`
	Title             *string `json:"title,omitempty"`
	Author            *string `json:"author,omitempty"`
	NumberOfPages     *int    `json:"number_of_pages,omitempty"`
	IsCheckedOut      *bool   `json:"isCheckedOut,omitempty"`
	StringToVectorize *string `json:"$vectorize,omitempty"`
}

type BrokenCompositePrimaryKey

type BrokenCompositePrimaryKey struct {
	KeyTwo string `json:"keyTwo" astra:"pk,3"`
	KeyOne string `json:"keyOne" astra:"pk,1"`
}

type BrokenCompoundPrimaryKey

type BrokenCompoundPrimaryKey struct {
	KeyTwo            string `json:"keyTwo" astra:"pk,2"`
	KeyOne            string `json:"keyOne" astra:"pk,1"`
	SortTwoDescending string `json:"sortTwoDescending" astra:"ck,2,desc"`
	SortOneAscending  string `json:"sortOneAscending" astra:"ck,0,asc"`
}

type CompositePrimaryKey

type CompositePrimaryKey struct {
	KeyTwo string `json:"keyTwo" astra:"pk,2"`
	KeyOne string `json:"keyOne" astra:"pk,1"`
}

type CompoundPrimaryKey

type CompoundPrimaryKey struct {
	KeyTwo            string `json:"keyTwo" astra:"pk,2"`
	KeyOne            string `json:"keyOne" astra:"pk,1"`
	SortTwoDescending string `json:"sortTwoDescending" astra:"ck,2,desc"`
	SortOneAscending  string `json:"sortOneAscending" astra:"ck,1,asc"`
}

type DifferentIdsObject

type DifferentIdsObject struct {
	TheID any    `json:"_id"` // Matches 'object' in C#
	Name  string `json:"name"`
}

type DurationRow

type DurationRow struct {
	ID       string             `json:"id"`
	Label    string             `json:"label"`
	Duration datatypes.Duration `json:"duration"`
}

type GradeEntry

type GradeEntry struct {
	Date  time.Time `json:"date"`
	Grade string    `json:"grade"`
	Score *float32  `json:"score,omitempty"`
}

type Metadata

type Metadata struct {
	Language string `json:"language"`
	Genre    string `json:"genre"`
}

type Properties

type Properties struct {
	PropertyOne         string    `json:"propertyOne"`
	PropertyTwo         string    `json:"propertyTwo"`
	IntProperty         int       `json:"intProperty"`
	StringArrayProperty []string  `json:"stringArrayProperty"`
	BoolProperty        bool      `json:"boolProperty"`
	TimeProperty        time.Time `json:"timeProperty"`
	UTCTime             time.Time `json:"utcTime"`
	SkipWhenNull        *string   `json:"skipWhenNull,omitempty"`
}

type Restaurant

type Restaurant struct {
	ID           string       `json:"id"` // Guid
	Name         string       `json:"name"`
	RestaurantID string       `json:"restaurantId"`
	Cuisine      string       `json:"cuisine"`
	Address      Address      `json:"address"`
	Borough      string       `json:"borough"`
	Grades       []GradeEntry `json:"grades"`
}

type RowBook

type RowBook struct {
	Title         string     `json:"title" astra:"pk,1"`
	Author        any        `json:"author" astra:"vectorize,provider=nvidia,model=NV-Embed-QA"`
	NumberOfPages int        `json:"numberOfPages" astra:"pk,2"`
	DueDate       *time.Time `json:"dueDate"`
	Genres        []string   `json:"genres"` // HashSet mapped to Slice for JSON compatibility
	Rating        float32    `json:"rating"`
}
func (RowBook) TableName
func (RowBook) TableName() string

TableName implements the interface to define the custom table name

type RowBookSinglePrimaryKey

type RowBookSinglePrimaryKey struct {
	Title         string    `json:"title" astra:"pk,1"`
	Author        string    `json:"author"`
	NumberOfPages int       `json:"numberOfPages"`
	DueDate       time.Time `json:"dueDate"`
	Genres        []string  `json:"genres"`
	Rating        float32   `json:"rating"`
}
func (RowBookSinglePrimaryKey) TableName
func (RowBookSinglePrimaryKey) TableName() string

type RowBookWithSimilarity

type RowBookWithSimilarity struct {
	RowBook            // Embedding
	Similarity float64 `json:"$similarity"`
}

type RowEventByDay

type RowEventByDay struct {
	EventDate time.Time `json:"event_date" astra:"pk,1"`
	ID        string    `json:"id" astra:"pk,2"` // Guid
	Title     string    `json:"title"`
	Location  string    `json:"location"`
	Category  string    `json:"category"`
}

type RowTestObject

type RowTestObject struct {
	Name              string             `json:"renamed" astra:"pk,1"`
	Vector            []float32          `json:"vector" astra:"pk,2,vector,dim=4"`
	StringToVectorize any                `json:"stringToVectorize" astra:"pk,3,vectorize,provider=nvidia,model=NV-Embed-QA"`
	Text              string             `json:"text" astra:"pk,4"`
	Inet              net.IP             `json:"inet"`
	Int               int                `json:"int" astra:"pk,5"`
	TinyInt           uint8              `json:"tinyInt" astra:"pk,6"`
	SmallInt          int16              `json:"smallInt" astra:"pk,7"`
	BigInt            int64              `json:"bigInt" astra:"pk,8"`
	Decimal           float64            `json:"decimal" astra:"pk,9"` // Go uses float64 for generic decimal, or math/big
	Double            float64            `json:"double" astra:"pk,10"`
	Float             float32            `json:"float" astra:"pk,11"`
	IntDictionary     map[string]int     `json:"intDictionary"`
	DecimalDictionary map[string]float64 `json:"decimalDictionary"`
	StringSet         []string           `json:"stringSet"` // Set -> Slice for JSON
	IntSet            []int              `json:"intSet"`    // Set -> Slice for JSON
	StringList        []string           `json:"stringList"`
	ObjectList        []Properties       `json:"objectList" astra:"jsonString"`
	Boolean           bool               `json:"boolean" astra:"pk,12"`
	Date              time.Time          `json:"date" astra:"pk,13"`
	UUID              string             `json:"uuid" astra:"pk,14"`
	Blob              []byte             `json:"blob"`
	Duration          time.Duration      `json:"duration"`
}
func (RowTestObject) TableName
func (RowTestObject) TableName() string

type SerializationTest

type SerializationTest struct {
	TestID           int        `json:"_id"`
	NestedProperties Properties `json:"nestedProperties"`
}

type SimpleObject

type SimpleObject struct {
	ID         any        `json:"_id,omitempty"`
	Name       string     `json:"name"`
	Properties Properties `json:"properties"`
}

type SimpleObjectSkipNulls

type SimpleObjectSkipNulls struct {
	ID          int     `json:"_id"`
	Name        string  `json:"name"`
	PropertyOne *string `json:"propertyOne,omitempty"`
	PropertyTwo *string `json:"propertyTwo,omitempty"`
}

type SimpleObjectWithGuidId

type SimpleObjectWithGuidId struct {
	ID   *string `json:"_id,omitempty"` // Go uses strings for UUIDs in JSON
	Name string  `json:"name"`
}

type SimpleObjectWithObjectId

type SimpleObjectWithObjectId struct {
	// standard "any" allows string (hex) or specific ObjectId types
	ID   any    `json:"_id,omitempty"`
	Name string `json:"name"`
}

type SimpleObjectWithVector

type SimpleObjectWithVector struct {
	ID               *int      `json:"_id,omitempty"`
	Name             string    `json:"name"`
	VectorEmbeddings []float32 `json:"$vector,omitempty"` // Vectors are usually float32
}

type SimpleObjectWithVectorize

type SimpleObjectWithVectorize struct {
	ID   *int   `json:"_id,omitempty"`
	Name string `json:"name"`
	// Go doesn't support computed properties in structs for JSON.
	// You must populate this field manually before marshaling.
	StringToVectorize string `json:"$vectorize,omitempty"`
}

type SimpleObjectWithVectorizeResult

type SimpleObjectWithVectorizeResult struct {
	SimpleObjectWithVectorize          // Embedding (Inheritance)
	Similarity                *float64 `json:"$similarity,omitempty"`
}

type SimpleRowObject

type SimpleRowObject struct {
	Name string `json:"name" astra:"pk"`
}

type TestBook

type TestBook struct {
	Title         string   `json:"title"`
	Author        string   `json:"author"`
	NumberOfPages int      `json:"number_of_pages"`
	Rating        float32  `json:"rating"`
	IsCheckedOut  bool     `json:"is_checked_out"`
	Genres        []string `json:"genres"`
}

TestBook represents a book for table tests

type TestDocument

type TestDocument struct {
	ID        string    `json:"id"`
	Content   string    `json:"content"`
	Embedding []float32 `json:"embedding"`
}

TestDocument represents a document with vector embeddings for vector index tests

type VectorDocument

type VectorDocument struct {
	ID            string    `json:"_id,omitempty"`
	Title         string    `json:"title"`
	Rating        int       `json:"rating"`
	IsCheckedOut  bool      `json:"is_checked_out"`
	NumberOfPages int       `json:"number_of_pages"`
	Vector        []float32 `json:"$vector,omitempty"`
	Metadata      Metadata  `json:"metadata"`
}

VectorDocument represents a document with vector embeddings