mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package proxy
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/mock"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
|
"github.com/milvus-io/milvus/internal/mocks"
|
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
|
"github.com/milvus-io/milvus/pkg/v2/util/merr"
|
|
)
|
|
|
|
func TestNewInterceptor(t *testing.T) {
|
|
rootCoord := mocks.NewMockRootCoordClient(t)
|
|
node := &Proxy{
|
|
rootCoord: rootCoord,
|
|
session: &sessionutil.Session{SessionRaw: sessionutil.SessionRaw{ServerID: 1}},
|
|
}
|
|
node.UpdateStateCode(commonpb.StateCode_Healthy)
|
|
rootCoord.On("DescribeCollection", mock.Anything, mock.Anything).Return(nil, merr.ErrCollectionNotFound).Maybe()
|
|
var err error
|
|
globalMetaCache, err = NewMetaCache(rootCoord, nil, nil)
|
|
assert.NoError(t, err)
|
|
interceptor, err := NewInterceptor[*milvuspb.DescribeCollectionRequest, *milvuspb.DescribeCollectionResponse](node, "DescribeCollection")
|
|
assert.NoError(t, err)
|
|
resp, err := interceptor.Call(context.Background(), &milvuspb.DescribeCollectionRequest{
|
|
DbName: "test",
|
|
CollectionName: "test",
|
|
})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "can't find collection[database=test][collection=test]", resp.Status.Reason)
|
|
}
|