mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-28 22:45:26 +08:00
74 lines
2.0 KiB
Go
74 lines
2.0 KiB
Go
package reader
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestConstructorAndDestructor(t *testing.T) {
|
|
node := NewQueryNode(0, 0)
|
|
var collection = node.NewCollection("collection0", "fake schema")
|
|
var partition = collection.NewPartition("partition0")
|
|
var segment = partition.NewSegment(0)
|
|
|
|
partition.DeleteSegment(segment)
|
|
collection.DeletePartition(partition)
|
|
node.DeleteCollection(collection)
|
|
}
|
|
|
|
func TestSegmentInsert(t *testing.T) {
|
|
node := NewQueryNode(0, 0)
|
|
var collection = node.NewCollection("collection0", "fake schema")
|
|
var partition = collection.NewPartition("partition0")
|
|
var segment = partition.NewSegment(0)
|
|
|
|
ids :=[] uint64{1, 2, 3}
|
|
timestamps :=[] uint64 {0, 0, 0}
|
|
|
|
var _, err = SegmentInsert(segment, &ids, ×tamps, nil)
|
|
assert.NoError(t, err)
|
|
|
|
partition.DeleteSegment(segment)
|
|
collection.DeletePartition(partition)
|
|
node.DeleteCollection(collection)
|
|
}
|
|
|
|
func TestSegmentDelete(t *testing.T) {
|
|
node := NewQueryNode(0, 0)
|
|
var collection = node.NewCollection("collection0", "fake schema")
|
|
var partition = collection.NewPartition("partition0")
|
|
var segment = partition.NewSegment(0)
|
|
|
|
ids :=[] uint64{1, 2, 3}
|
|
timestamps :=[] uint64 {0, 0, 0}
|
|
|
|
var _, err = SegmentDelete(segment, &ids, ×tamps)
|
|
assert.NoError(t, err)
|
|
|
|
partition.DeleteSegment(segment)
|
|
collection.DeletePartition(partition)
|
|
node.DeleteCollection(collection)
|
|
}
|
|
|
|
func TestSegmentSearch(t *testing.T) {
|
|
node := NewQueryNode(0, 0)
|
|
var collection = node.NewCollection("collection0", "fake schema")
|
|
var partition = collection.NewPartition("partition0")
|
|
var segment = partition.NewSegment(0)
|
|
|
|
ids :=[] uint64{1, 2, 3}
|
|
timestamps :=[] uint64 {0, 0, 0}
|
|
|
|
var _, insertErr = SegmentInsert(segment, &ids, ×tamps, nil)
|
|
assert.NoError(t, insertErr)
|
|
|
|
var searchRes, searchErr = SegmentSearch(segment, "fake query string", ×tamps, nil)
|
|
assert.NoError(t, searchErr)
|
|
fmt.Println(searchRes)
|
|
|
|
partition.DeleteSegment(segment)
|
|
collection.DeletePartition(partition)
|
|
node.DeleteCollection(collection)
|
|
}
|