Skip to content

Commit 2f6d7a7

Browse files
committed
add type decl test
1 parent 8bcacd0 commit 2f6d7a7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_type.nim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import std/unittest
2+
3+
import easy_sqlite3
4+
5+
type
6+
User = tuple[id: int, username: string, email: string]
7+
8+
proc createUsersTable() {.importdb: "create table users(id INTEGER PRIMARY KEY, username TEXT NOT NULL, email TEXT NOT NULL)".}
9+
proc insertUser(username, email: string) {.importdb: "insert into users(username, email) values ($username, $email)".}
10+
proc selectUserById(id: int): User {.importdb: "select * from users where id = $id".}
11+
12+
test "type decl":
13+
var db = initDatabase(":memory:")
14+
db.createUsersTable()
15+
db.insertUser("user", "[email protected]")
16+
check db.selectUserById(1) == (id: 1, username: "user", email: "[email protected]")

0 commit comments

Comments
 (0)