milvus/internal/queryservice/meta_replica_test.go
XuanYang-cn 7dd531d159 Fix release collection bug
Signed-off-by: XuanYang-cn <xuan.yang@zilliz.com>
2021-03-11 18:42:25 +08:00

41 lines
994 B
Go

package queryservice
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestReplica_Release(t *testing.T) {
replica := newMetaReplica()
err := replica.addCollection(0, 1, nil)
require.NoError(t, err)
colls, err := replica.getCollections(0)
assert.NoError(t, err)
assert.Equal(t, 1, len(colls))
err = replica.addPartition(0, 1, 100)
assert.NoError(t, err)
partitions, err := replica.getPartitions(0, 1)
assert.NoError(t, err)
assert.Equal(t, 1, len(partitions))
err = replica.releasePartition(0, 1, 100)
assert.NoError(t, err)
partitions, err = replica.getPartitions(0, 1)
assert.NoError(t, err)
assert.Equal(t, 0, len(partitions))
err = replica.releasePartition(0, 1, 100)
assert.Error(t, err)
err = replica.releaseCollection(0, 1)
assert.NoError(t, err)
colls, err = replica.getCollections(0)
assert.NoError(t, err)
assert.Equal(t, 0, len(colls))
err = replica.releaseCollection(0, 1)
assert.Error(t, err)
}