changeset 598:e930f92d0f61

add blog test
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 16 Sep 2015 14:32:52 -0600
parents cb6c628de583
children 50540f0813e2
files blog/src/lib/test.luan blog/src/private/tools/test.luan blog/test.sh
diffstat 3 files changed, 86 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/blog/src/lib/test.luan	Wed Sep 16 14:32:52 2015 -0600
@@ -0,0 +1,62 @@
+local Luan = require "luan:Luan"
+local error = Luan.error
+local to_string = Luan.to_string or error()
+local Http = require "luan:http/Http"
+local Http_test = require "luan:http/Http_test"
+local init = Http_test.init or error()
+local get_page = Http_test.get_page or error()
+local Io = require "luan:Io"
+local print = Io.print or error()
+local String = require "luan:String"
+local match = String.match or error()
+
+Http.uncache_site()
+
+local Db_mod = require "site:/lib/Db_mod"
+
+Db_mod.lucene_dir = "site:/private/local/lucene_test"
+local Db = require "site:/lib/Db"
+Db.delete_all()
+
+local Post = require "site:/lib/Post"
+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 '/'
+match(page,'this is an edit') or error()
+
+print 'done'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/blog/src/private/tools/test.luan	Wed Sep 16 14:32:52 2015 -0600
@@ -0,0 +1,23 @@
+local Luan = require "luan:Luan"
+local do_file = Luan.do_file
+local try = Luan.try
+local Io = require "luan:Io"
+local print = Io.print
+local Http = require "luan:http/Http"
+
+
+return function()
+	Io.stdout = Http.response.text_writer()
+	Http.response.content_type = "text/plain"
+	try {
+		function()
+			do_file "site:/lib/test.luan"
+		end;
+		catch = function(e)
+			print()
+			print("error:",e)
+		end;
+	}
+	local Db = require "site:/lib/Db"
+	Db.close()
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/blog/test.sh	Wed Sep 16 14:32:52 2015 -0600
@@ -0,0 +1,1 @@
+luan luan:http/test file:src site:/lib/test 2>&1 | tee err