Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
haoxins committed Feb 15, 2024
1 parent 6516dba commit 815df31
Showing 1 changed file with 44 additions and 10 deletions.
54 changes: 44 additions & 10 deletions session_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,14 +522,14 @@ func TestSessionPoolApplyTag(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, 1, len(tags))
assert.Equal(t, "account", tags[0].Name, "tag name should be account")
assert.Equal(t, "account", tags[0].Name)
labels, err := sessionPool.DescTag("account")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 1, len(labels))
assert.Equal(t, "name", labels[0].Field, "field name should be name")
assert.Equal(t, "string", labels[0].Type, "field type should be string")
assert.Equal(t, "name", labels[0].Field)
assert.Equal(t, "string", labels[0].Type)

tagSchema = LabelSchema{
Name: "account",
Expand Down Expand Up @@ -560,18 +560,52 @@ func TestSessionPoolApplyTag(t *testing.T) {
t.Fatal(err)
}
assert.Equal(t, 1, len(tags))
assert.Equal(t, "account", tags[0].Name, "tag name should be account")
assert.Equal(t, "account", tags[0].Name)
labels, err = sessionPool.DescTag("account")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 3, len(labels))
assert.Equal(t, "name", labels[0].Field, "field name should be name")
assert.Equal(t, "string", labels[0].Type, "field type should be string")
assert.Equal(t, "email", labels[1].Field, "field name should be email")
assert.Equal(t, "string", labels[1].Type, "field type should be string")
assert.Equal(t, "phone", labels[2].Field, "field name should be phone")
assert.Equal(t, "int64", labels[2].Type, "field type should be int64")
assert.Equal(t, "name", labels[0].Field)
assert.Equal(t, "string", labels[0].Type)
assert.Equal(t, "email", labels[1].Field)
assert.Equal(t, "string", labels[1].Type)
assert.Equal(t, "phone", labels[2].Field)
assert.Equal(t, "int64", labels[2].Type)
tagSchema = LabelSchema{
Name: "account",
Fields: []LabelFieldSchema{
{
Field: "name",
Type: "string",
Nullable: false,
},
{
Field: "phone",
Type: "int64",
Nullable: true,
},
},
}
_, err = sessionPool.ApplyTag(tagSchema)
if err != nil {
t.Fatal(err)
}
tags, err = sessionPool.ShowTags()
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 1, len(tags))
assert.Equal(t, "account", tags[0].Name)
labels, err = sessionPool.DescTag("account")
if err != nil {
t.Fatal(err)
}
assert.Equal(t, 2, len(labels))
assert.Equal(t, "name", labels[0].Field)
assert.Equal(t, "string", labels[0].Type)
assert.Equal(t, "phone", labels[1].Field)
assert.Equal(t, "int64", labels[1].Type)
}

func TestIdleSessionCleaner(t *testing.T) {
Expand Down

0 comments on commit 815df31

Please sign in to comment.