annotate blog/src/lib/test.luan @ 654:ea7dbd2dfa65

compile TemplateStmt
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 05 Apr 2016 14:16:14 -0600
parents 35dde32c02ab
children ca169567ce07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local to_string = Luan.to_string or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Http_test = require "luan:http/Http_test"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local init = Http_test.init or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local get_page = Http_test.get_page or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Io = require "luan:Io"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local print = Io.print or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local String = require "luan:String"
629
35dde32c02ab change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents: 598
diff changeset
11 local matches = String.matches or error()
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 Http.uncache_site()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 local Db_mod = require "site:/lib/Db_mod"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 Db_mod.lucene_dir = "site:/private/local/lucene_test"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 local Db = require "site:/lib/Db"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 Db.delete_all()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 local Post = require "site:/lib/Post"
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 local page
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 print 'go'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 print '/'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 get_page '/'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 print '/new'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 get_page '/new'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 Http.request.parameter.subject = 'test'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 Http.request.parameter.content = 'this is a test'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 Http.request.parameter.save = 'whatever'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 print '/new submit'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 get_page '/new'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 local posts = Post.get_all()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 #posts == 1 or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 local post_id = to_string(posts[1].id)
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 Http.request.parameter.post = post_id
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 print '/edit'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 get_page '/edit'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 Http.request.parameter.post = post_id
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 Http.request.parameter.subject = 'test'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 Http.request.parameter.content = 'this is an edit'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 Http.request.parameter.save = 'whatever'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 print '/edit submit'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 get_page '/edit'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 print '/ again'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59 page = get_page '/'
629
35dde32c02ab change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents: 598
diff changeset
60 matches(page,'this is an edit') or error()
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
62 print 'done'