Skip to content

Commit 2582869

Browse files
committed
test: add test for IsNullable Field flag
1 parent 40fe0d3 commit 2582869

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

config.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ box.once("init", function()
1616
id = 616,
1717
temporary = true,
1818
if_not_exists = true,
19-
field_count = 7,
19+
field_count = 8,
2020
format = {
2121
{name = "name0", type = "unsigned"},
2222
{name = "name1", type = "unsigned"},
2323
{name = "name2", type = "string"},
2424
{name = "name3", type = "unsigned"},
2525
{name = "name4", type = "unsigned"},
2626
{name = "name5", type = "string"},
27+
{name = "nullable", is_nullable = true},
2728
},
2829
})
2930
st:create_index('primary', {

tarantool_test.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ func TestSchema(t *testing.T) {
19081908
if space.Engine != "memtx" {
19091909
t.Errorf("space 616 engine should be memtx")
19101910
}
1911-
if space.FieldsCount != 7 {
1911+
if space.FieldsCount != 8 {
19121912
t.Errorf("space 616 has incorrect fields count")
19131913
}
19141914

@@ -1918,10 +1918,10 @@ func TestSchema(t *testing.T) {
19181918
if space.Fields == nil {
19191919
t.Errorf("space.Fields is nill")
19201920
}
1921-
if len(space.FieldsById) != 6 {
1921+
if len(space.FieldsById) != 7 {
19221922
t.Errorf("space.FieldsById len is incorrect")
19231923
}
1924-
if len(space.Fields) != 6 {
1924+
if len(space.Fields) != 7 {
19251925
t.Errorf("space.Fields len is incorrect")
19261926
}
19271927

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

2048+
func TestSchema_IsNullable(t *testing.T) {
2049+
conn := test_helpers.ConnectWithValidation(t, server, opts)
2050+
defer conn.Close()
2051+
2052+
schema := conn.Schema
2053+
if schema.Spaces == nil {
2054+
t.Errorf("schema.Spaces is nil")
2055+
}
2056+
2057+
var space *Space
2058+
var ok bool
2059+
if space, ok = schema.SpacesById[616]; !ok {
2060+
t.Errorf("space with id = 616 was not found in schema.SpacesById")
2061+
}
2062+
2063+
var field, field_nullable *Field
2064+
for i := 0; i <= 5; i++ {
2065+
name := fmt.Sprintf("name%d", i)
2066+
if field, ok = space.Fields[name]; !ok {
2067+
t.Errorf("field name = %s was not found", name)
2068+
}
2069+
if field.IsNullable {
2070+
t.Errorf("field %s has incorrect IsNullable", name)
2071+
}
2072+
}
2073+
if field_nullable, ok = space.Fields["nullable"]; !ok {
2074+
t.Errorf("field name = nullable was not found")
2075+
}
2076+
if !field_nullable.IsNullable {
2077+
t.Errorf("field nullable has incorrect IsNullable")
2078+
}
2079+
}
2080+
20482081
func TestClientNamed(t *testing.T) {
20492082
var resp *Response
20502083
var err error

0 commit comments

Comments
 (0)