Mercurial Hosting > luan
annotate examples/blog/src/lib/test.luan @ 1218:a50803fde972
http/tools cleanup
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 20 Mar 2018 16:24:59 -0600 |
| parents | 21d157b153fe |
| children | 4721c482c86b |
| rev | line source |
|---|---|
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
1 local Luan = require "luan:Luan.luan" |
| 598 | 2 local error = Luan.error |
| 3 local to_string = Luan.to_string or error() | |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
4 local Http = require "luan:http/Http.luan" |
|
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
5 local Http_test = require "luan:http/Http_test.luan" |
| 598 | 6 local init = Http_test.init or error() |
| 7 local get_page = Http_test.get_page or error() | |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
8 local Io = require "luan:Io.luan" |
| 598 | 9 local print = Io.print or error() |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
10 local String = require "luan:String.luan" |
|
629
35dde32c02ab
change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents:
598
diff
changeset
|
11 local matches = String.matches or error() |
| 598 | 12 |
| 13 Http.uncache_site() | |
| 14 | |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
15 local Db_mod = require "site:/lib/Db_mod.luan" |
| 598 | 16 |
| 17 Db_mod.lucene_dir = "site:/private/local/lucene_test" | |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
18 local Db = require "site:/lib/Db.luan" |
| 598 | 19 Db.delete_all() |
| 20 | |
|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
629
diff
changeset
|
21 local Post = require "site:/lib/Post.luan" |
| 598 | 22 local page |
| 23 | |
| 24 print 'go' | |
| 25 | |
| 26 init() | |
| 27 print '/' | |
| 28 get_page '/' | |
| 29 | |
| 30 init() | |
| 1218 | 31 print '/new.html' |
| 32 get_page '/new.html' | |
| 598 | 33 |
| 34 init() | |
|
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
35 Http.request.parameters.subject = 'test' |
|
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
36 Http.request.parameters.content = 'this is a test' |
|
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
37 Http.request.parameters.save = 'whatever' |
| 1218 | 38 print '/new.html submit' |
| 39 get_page '/new.html' | |
| 598 | 40 local posts = Post.get_all() |
| 41 #posts == 1 or error() | |
| 42 local post_id = to_string(posts[1].id) | |
| 43 | |
| 44 init() | |
|
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
45 Http.request.parameters.post = post_id |
| 1218 | 46 print '/edit.html' |
| 47 get_page '/edit.html' | |
| 598 | 48 |
| 49 init() | |
|
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
50 Http.request.parameters.post = post_id |
|
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
51 Http.request.parameters.subject = 'test' |
|
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
52 Http.request.parameters.content = 'this is an edit' |
|
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
53 Http.request.parameters.save = 'whatever' |
| 1218 | 54 print '/edit.html submit' |
| 55 get_page '/edit.html' | |
| 598 | 56 |
| 57 init() | |
| 58 print '/ again' | |
| 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 | 61 |
| 62 print 'done' |
