summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sergey Mironov <grrwlf@gmail.com>2014-08-15 07:11:31 +0000
committerGravatar Sergey Mironov <grrwlf@gmail.com>2014-08-15 07:11:31 +0000
commit6c3c000ee821e37b0232afbb8c5733c573892ad2 (patch)
tree0d64a8971e731187b8a0743de34b4bc57f5c11e4
parente5e4cf1ae9eae228fea6ba0626f69f3539c83ed1 (diff)
Add tests/dbupload2.* files
tests/dbupload2.sh is a shell script which run the test scenario On my machine the executable segfaults after curl request
-rwxr-xr-xtests/dbupload2.sh17
-rw-r--r--tests/dbupload2.ur29
-rw-r--r--tests/dbupload2.urp7
-rw-r--r--tests/dbupload2.urs1
4 files changed, 54 insertions, 0 deletions
diff --git a/tests/dbupload2.sh b/tests/dbupload2.sh
new file mode 100755
index 00000000..cecf1960
--- /dev/null
+++ b/tests/dbupload2.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+set -e
+
+cd `dirname $0`
+
+urweb -dbms sqlite dbupload2
+
+rm -rf dbupload2.db || true
+sqlite3 dbupload2.db < dbupload2.sql
+
+./dbupload2.exe -p 8083 &
+sleep 1
+
+touch /tmp/empty
+curl --verbose -F"operation=upload" -F"filename=@/tmp/empty" http://localhost:8083/Blabla/bla
+
diff --git a/tests/dbupload2.ur b/tests/dbupload2.ur
new file mode 100644
index 00000000..428f2460
--- /dev/null
+++ b/tests/dbupload2.ur
@@ -0,0 +1,29 @@
+table t : { Id : int, Blob : blob, MimeType : string }
+sequence s
+
+fun getImage id : transaction page =
+ r <- oneRow1 (SELECT t.Blob, t.MimeType
+ FROM t
+ WHERE t.Id = {[id]});
+ returnBlob r.Blob (blessMime r.MimeType)
+
+fun handle (r : {File:file, Param:string}) =
+ id <- nextval s;
+ dml (INSERT INTO t (Id, Blob, MimeType)
+ VALUES ({[id]}, {[fileData r.File]}, {[fileMimeType r.File]}));
+ debug ("Text is " ^ r.Param);
+ main ()
+
+and main () : transaction page =
+ x <- queryX1 (SELECT t.Id FROM t)
+ (fn r => <xml><img src={url (getImage r.Id)}/>
+</xml>);
+ return <xml><body>
+ <form>
+ <upload{#File}/>
+ <textbox{#Param} value="text"/>
+ <submit action={handle}/>
+ </form>
+ <hr/>
+ {x}
+ </body></xml>
diff --git a/tests/dbupload2.urp b/tests/dbupload2.urp
new file mode 100644
index 00000000..bd550589
--- /dev/null
+++ b/tests/dbupload2.urp
@@ -0,0 +1,7 @@
+database dbname=dbupload2.db
+sql dbupload2.sql
+allow mime *
+rewrite all Dbupload2/*
+debug
+
+dbupload2
diff --git a/tests/dbupload2.urs b/tests/dbupload2.urs
new file mode 100644
index 00000000..80240dee
--- /dev/null
+++ b/tests/dbupload2.urs
@@ -0,0 +1 @@
+val main: {} -> transaction page