File: on_schema_init.test.lua

package info (click to toggle)
tarantool 2.6.0-1.4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 85,412 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,178; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (31 lines) | stat: -rwxr-xr-x 1,028 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env tarantool

--
-- gh-3159: test on_schema_init trigger
--
local tap = require('tap')
local test = tap.test('on_schema_init')
local str = ''
test:plan(7)

function testing_trig()
    test:istable(box.space._space, 'system spaces are accessible')
    test:is(type(box.space._space.before_replace), 'function', 'before_replace triggers')
    test:is(type(box.space._space.on_replace), 'function', 'on_replace triggers')
    test:is(type(box.space._space:on_replace(function() str = str.."_space:on_replace" end)),
            'function', 'set on_replace trigger')
    str = str..'on_schema_init'
end

trig = box.ctl.on_schema_init(testing_trig)
test:is(type(trig), 'function', 'on_schema_init trigger set')

box.cfg{log = 'tarantool.log'}
test:like(str, 'on_schema_init', 'on_schema_init trigger works')
str = ''
box.schema.space.create("test")
-- test that _space.on_replace trigger may be set in on_schema_init
test:like(str, '_space:on_replace', 'can set on_replace')
test:check()
box.space.test:drop()
os.exit(0)