Mercurial Hosting > luan
comparison examples/blog/test.luan @ 1225:7d4b5afb636f
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 01 Apr 2018 19:04:43 -0600 |
parents | examples/blog/src/lib/test.luan@4416b9cbebf9 |
children |
comparison
equal
deleted
inserted
replaced
1224:4416b9cbebf9 | 1225:7d4b5afb636f |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local to_string = Luan.to_string or error() | |
4 local Http = require "luan:http/Http.luan" | |
5 local Http_test = require "luan:http/Http_test.luan" | |
6 local init = Http_test.init or error() | |
7 local get_page = Http_test.get_page or error() | |
8 local Io = require "luan:Io.luan" | |
9 local print = Io.print or error() | |
10 local String = require "luan:String.luan" | |
11 local matches = String.matches or error() | |
12 | |
13 local Db = require "site:/lib/Db.luan" | |
14 Db.db = Db.new("site:/private/local/lucene_test") | |
15 Db.db.delete_all() | |
16 | |
17 local Post = require "site:/lib/Post.luan" | |
18 local page | |
19 | |
20 print 'go' | |
21 | |
22 init() | |
23 print '/' | |
24 get_page '/' | |
25 | |
26 init() | |
27 print '/new.html' | |
28 get_page '/new.html' | |
29 | |
30 init() | |
31 Http.request.parameters.subject = 'test' | |
32 Http.request.parameters.content = 'this is a test' | |
33 Http.request.parameters.save = 'whatever' | |
34 print '/new.html submit' | |
35 get_page '/new.html' | |
36 local posts = Post.get_all() | |
37 #posts == 1 or error() | |
38 local post_id = to_string(posts[1].id) | |
39 | |
40 init() | |
41 Http.request.parameters.post = post_id | |
42 print '/edit.html' | |
43 get_page '/edit.html' | |
44 | |
45 init() | |
46 Http.request.parameters.post = post_id | |
47 Http.request.parameters.subject = 'test' | |
48 Http.request.parameters.content = 'this is an edit' | |
49 Http.request.parameters.save = 'whatever' | |
50 print '/edit.html submit' | |
51 get_page '/edit.html' | |
52 | |
53 init() | |
54 print '/ again' | |
55 page = get_page '/' | |
56 matches(page,'this is an edit') or error() | |
57 | |
58 print 'done' |