congqixia cb7f2fa6fd
enhance: Use v2 package name for pkg module (#39990)
Related to #39095

https://go.dev/doc/modules/version-numbers

Update pkg version according to golang dep version convention

---------

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
2025-02-22 23:15:58 +08:00

44 lines
1.2 KiB
Go

package attributes
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/milvus-io/milvus/internal/util/sessionutil"
"github.com/milvus-io/milvus/pkg/v2/streaming/util/types"
)
func TestAttributes(t *testing.T) {
attr := new(Attributes)
serverID := GetServerID(attr)
assert.Nil(t, serverID)
assert.Nil(t, GetChannelAssignmentInfoFromAttributes(attr))
assert.Nil(t, GetSessionFromAttributes(attr))
attr = new(Attributes)
attr = WithChannelAssignmentInfo(attr, &types.StreamingNodeAssignment{
NodeInfo: types.StreamingNodeInfo{
ServerID: 1,
Address: "localhost:8080",
},
})
assert.NotNil(t, GetServerID(attr))
assert.Equal(t, int64(1), *GetServerID(attr))
assert.NotNil(t, GetChannelAssignmentInfoFromAttributes(attr))
assert.Equal(t, "localhost:8080", GetChannelAssignmentInfoFromAttributes(attr).NodeInfo.Address)
attr = new(Attributes)
attr = WithSession(attr, &sessionutil.SessionRaw{
ServerID: 1,
})
assert.NotNil(t, GetServerID(attr))
assert.Equal(t, int64(1), *GetServerID(attr))
assert.NotNil(t, GetSessionFromAttributes(attr))
assert.Equal(t, int64(1), GetSessionFromAttributes(attr).ServerID)
attr = new(Attributes)
attr = WithServerID(attr, 1)
assert.Equal(t, int64(1), *GetServerID(attr))
}