diff examples/blog/src/lib/test.luan @ 779:c38f6619feb9

move blog into examples
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 28 Aug 2016 14:50:47 -0600
parents blog/src/lib/test.luan@ca169567ce07
children 21d157b153fe
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/blog/src/lib/test.luan	Sun Aug 28 14:50:47 2016 -0600
@@ -0,0 +1,62 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local to_string = Luan.to_string or error()
+local Http = require "luan:http/Http.luan"
+local Http_test = require "luan:http/Http_test.luan"
+local init = Http_test.init or error()
+local get_page = Http_test.get_page or error()
+local Io = require "luan:Io.luan"
+local print = Io.print or error()
+local String = require "luan:String.luan"
+local matches = String.matches or error()
+
+Http.uncache_site()
+
+local Db_mod = require "site:/lib/Db_mod.luan"
+
+Db_mod.lucene_dir = "site:/private/local/lucene_test"
+local Db = require "site:/lib/Db.luan"
+Db.delete_all()
+
+local Post = require "site:/lib/Post.luan"
+local page
+
+print 'go'
+
+init()
+print '/'
+get_page '/'
+
+init()
+print '/new'
+get_page '/new'
+
+init()
+Http.request.parameter.subject = 'test'
+Http.request.parameter.content = 'this is a test'
+Http.request.parameter.save = 'whatever'
+print '/new submit'
+get_page '/new'
+local posts = Post.get_all()
+#posts == 1 or error()
+local post_id = to_string(posts[1].id)
+
+init()
+Http.request.parameter.post = post_id
+print '/edit'
+get_page '/edit'
+
+init()
+Http.request.parameter.post = post_id
+Http.request.parameter.subject = 'test'
+Http.request.parameter.content = 'this is an edit'
+Http.request.parameter.save = 'whatever'
+print '/edit submit'
+get_page '/edit'
+
+init()
+print '/ again'
+page = get_page '/'
+matches(page,'this is an edit') or error()
+
+print 'done'