Skip to content

Commit

Permalink
feat(db) support unique constraint on foreign fields (#4698)
Browse files Browse the repository at this point in the history
  • Loading branch information
bungle authored and locao committed Nov 5, 2019
1 parent 1aa9bc7 commit 0b12f39
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/01-unit/01-db/02-db-errors_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,31 @@ describe("DB Errors", function()
end)


describe("INVALID_FOREIGN_KEY", function()
local pk = {
id = "missing",
id2 = "missing2",
}

local err_t = e:invalid_foreign_key(pk)

it("creates", function()
assert.same({
code = Errors.codes.INVALID_FOREIGN_KEY,
name = "invalid foreign key",
strategy = "some_strategy",
message = [[invalid foreign key: '{id2="missing2",id="missing"}']],
fields = pk,
}, err_t)
end)

it("__tostring", function()
local s = fmt("[%s] %s", err_t.strategy, err_t.message)
assert.equals(s, tostring(err_t))
end)
end)


describe("SCHEMA_VIOLATION", function()
local schema_errors = {
foo = "expected an integer",
Expand Down

0 comments on commit 0b12f39

Please sign in to comment.