Skip to content

Commit 5e2e18a

Browse files
add unit test checking error message for non existing schema
1 parent 6926def commit 5e2e18a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Rezoom.SQL.Test/Environment.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ let userModel1() = userModelByName "user-model-1"
1919

2020
let userModel2() = userModelByName "user-model-2"
2121

22-
let expectError (msg : string) (sql : string) =
22+
let expectErrorWithModel (mkMsg : Model -> string) (sql : string) =
2323
let userModel = userModel1()
2424
try
2525
ignore <| CommandEffect.OfSQL(userModel.Model, "anonymous", sql)
2626
failwith "Should've thrown an exception!"
2727
with
2828
| :? SourceException as exn ->
2929
printfn "\"%s\"" exn.Message
30-
Assert.AreEqual(msg, exn.Reason.Trim())
30+
Assert.AreEqual(mkMsg userModel.Model, exn.Reason.Trim())
31+
32+
let expectError (msg : string) (sql : string) = expectErrorWithModel (fun _ -> msg) sql
3133

3234
let dispenserParameterIndexer() =
3335
let dict = Dictionary()

src/Rezoom.SQL.Test/TestModelErrors.fs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,9 @@ let ``no such column to index on creation`` () =
4545
[<Test>]
4646
let ``can't drop table referenced by others`` () =
4747
expectError (Error.tableIsReferencedByFKs "main.Users" ["main.UserGroupMaps"])
48-
"drop table Users"
48+
"drop table Users"
49+
50+
[<Test>]
51+
let ``non existing schema name`` () =
52+
expectErrorWithModel (fun model -> Error.noSuchSchema model.Schemas "a")
53+
"select * from a.b"

0 commit comments

Comments
 (0)