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
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.

- Type() method to the Request interface (#158)
- Enumeration types for RLimitAction/iterators (#158)
- IsNullable flag for Field (#302)

### Changed

Expand Down
3 changes: 2 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
39 changes: 36 additions & 3 deletions tarantool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand All @@ -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")
}

Expand Down Expand Up @@ -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
Expand Down