Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: aoiasd <[email protected]>
  • Loading branch information
aoiasd committed Feb 10, 2025
1 parent 46fdda1 commit 5219d36
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 0 additions & 1 deletion internal/proxy/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -6947,7 +6947,6 @@ func (node *Proxy) RunAnalyzer(ctx context.Context, req *milvuspb.RunAnalyzerReq
tokens := []string{}
for stream.Advance() {
token := stream.Token()
log.Info("Test--", zap.String("token", token))
tokens = append(tokens, token)
}
results[i] = &milvuspb.AnalyzerResult{
Expand Down
20 changes: 20 additions & 0 deletions internal/proxy/impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -2194,3 +2195,22 @@ func TestAlterCollectionReplicateProperty(t *testing.T) {
assert.NoError(t, err)
assert.True(t, merr.Ok(statusResp))
}

func TestRunAnalyzer(t *testing.T) {
p := &Proxy{}
// run analyzer with default params
resp, err := p.RunAnalyzer(context.Background(), &milvuspb.RunAnalyzerRequset{
Placeholder: [][]byte{[]byte("test doc")},
})
require.NoError(t, err)
require.NoError(t, merr.Error(resp.GetStatus()))
assert.Equal(t, len(resp.GetResults()[0].GetTokens()), 2)

// run analyzer with invalid params
resp, err = p.RunAnalyzer(context.Background(), &milvuspb.RunAnalyzerRequset{
Placeholder: [][]byte{[]byte("test doc")},
AnalyzerParams: "invalid json",
})
require.NoError(t, err)
require.Error(t, merr.Error(resp.GetStatus()))
}

0 comments on commit 5219d36

Please sign in to comment.