local schema = require "schema" local sqlite = require "lsqlite3" local describe, it, expect = lester.describe, lester.it, lester.expect describe("schema", function() local db lester.before(function() db = sqlite.open_memory() db:exec("PRAGMA foreign_keys") schema.setup(db) end) lester.after(function() db:close() db = nil end) describe("new_node_type", function() it("creates new node types", function() local node_type_names = {"a", "b", "c", "d"} for _, name in ipairs(node_type_names) do schema.new_node_type(db, name) end local results = {} for name in schema.get_node_types(db) do table.insert(results, name) end expect.equal(node_type_names, results) end) it("fails when creating a duplicate node type", function() local function create() schema.new_node_type(db, "a") end create() expect.fail(create) end) end) describe("quote name", function() it("quotes names and escapes double quotes", function() local original = [[My "name" is "Frankie".]] local expected = [["My ""name"" is ""Frankie""."]] local actual = schema.quote_name(original) expect.equal(expected, actual) end) end) end)