Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add test for IsNullable Field flag #302

Merged
merged 2 commits into from
Jun 13, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: add test for IsNullable Field flag
grafin committed Jun 9, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 25828698f947f70dd516df34185f08d942e1532d
3 changes: 2 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
@@ -16,14 +16,15 @@ box.once("init", function()
id = 616,
temporary = true,
if_not_exists = true,
field_count = 7,
field_count = 8,
format = {
{name = "name0", type = "unsigned"},
{name = "name1", type = "unsigned"},
{name = "name2", type = "string"},
{name = "name3", type = "unsigned"},
{name = "name4", type = "unsigned"},
{name = "name5", type = "string"},
{name = "nullable", is_nullable = true},
},
})
st:create_index('primary', {
39 changes: 36 additions & 3 deletions tarantool_test.go
Original file line number Diff line number Diff line change
@@ -1908,7 +1908,7 @@ func TestSchema(t *testing.T) {
if space.Engine != "memtx" {
t.Errorf("space 616 engine should be memtx")
}
if space.FieldsCount != 7 {
if space.FieldsCount != 8 {
t.Errorf("space 616 has incorrect fields count")
}

@@ -1918,10 +1918,10 @@ func TestSchema(t *testing.T) {
if space.Fields == nil {
t.Errorf("space.Fields is nill")
}
if len(space.FieldsById) != 6 {
if len(space.FieldsById) != 7 {
t.Errorf("space.FieldsById len is incorrect")
}
if len(space.Fields) != 6 {
if len(space.Fields) != 7 {
t.Errorf("space.Fields len is incorrect")
}

@@ -2045,6 +2045,39 @@ func TestSchema(t *testing.T) {
}
}

func TestSchema_IsNullable(t *testing.T) {
conn := test_helpers.ConnectWithValidation(t, server, opts)
defer conn.Close()

schema := conn.Schema
if schema.Spaces == nil {
t.Errorf("schema.Spaces is nil")
}

var space *Space
var ok bool
if space, ok = schema.SpacesById[616]; !ok {
t.Errorf("space with id = 616 was not found in schema.SpacesById")
}

var field, field_nullable *Field
for i := 0; i <= 5; i++ {
name := fmt.Sprintf("name%d", i)
if field, ok = space.Fields[name]; !ok {
t.Errorf("field name = %s was not found", name)
}
if field.IsNullable {
t.Errorf("field %s has incorrect IsNullable", name)
}
}
if field_nullable, ok = space.Fields["nullable"]; !ok {
t.Errorf("field name = nullable was not found")
}
if !field_nullable.IsNullable {
t.Errorf("field nullable has incorrect IsNullable")
}
}

func TestClientNamed(t *testing.T) {
var resp *Response
var err error