hlfw.ca

webbing

Download patch

ref: 74303acf0bc6eb6c58771657fdc87001dd435c6e
parent: 577eada94e73351cb47ef146ce7ae5e37e98ad2d
author: halfwit <michaelmisch1985@gmail.com>
date: Mon Mar 30 09:27:09 PDT 2020

Start designing tests for pages

--- a/doctor/application.go
+++ b/doctor/application.go
@@ -23,9 +23,10 @@
 
 func application(r *http.Request, p *message.Printer) []string {
 	var errors []string
+
 	data, err := forms.Parse(r)
 	if err != nil {
-		errors = append(errors, "Internal server error")
+		errors = append(errors, fmt.Sprintf("Internal server error %v", err))
 		return errors
 	}
 	val := data.Validator()
--- /dev/null
+++ b/doctor/application_test.go
@@ -1,0 +1,125 @@
+package forms
+
+import (
+	"bufio"
+	"net/http"
+	"strings"
+	"testing"
+)
+
+// This isn't quite right yet, we'll get a working test soon.
+var req = `POST /doctor/application.html HTTP/1.1
+Host: localhost
+User-Agent: Mozilla/5.0
+Accept: */*
+Connection: keep-alive
+Cache-Control: no-cache
+Content-Length: 2028
+Content-Type: multipart/form-data; boundary=--------------------
+
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="Specialty"
+
+bariatric
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="country"
+
+Albania
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="email"
+
+mee%40foo.ca
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="gender"
+
+male
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="name"
+
+mememe
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="pagetitle"
+
+Application+for+doctor
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q1"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q10"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q11"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q2"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q3"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q4"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q5"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q6"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q7"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q8"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="q9"
+
+No
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="sendto"
+
+olmaxmedical%40gmail.com
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="cv"
+
+resume.pdf
+--------------------------4ee5f9ad0b2d7899
+Content-Disposition: form-data; name="form"
+
+resume.pdf
+--------------------------4ee5f9ad0b2d7899`
+
+func TestApplication(t *testing.T) {
+	// Build a POST request with a map of entries
+	rd := bufio.NewReader(strings.NewReader(req))
+
+	request, err := http.ReadRequest(rd)
+	if err != nil {
+		t.Errorf("test design error: bad request: %v", err)
+		return
+	}
+
+	if e := request.ParseMultipartForm(request.ContentLength); e != nil {
+		t.Error(e)
+	}
+	/*
+		printer := message.NewPrinter(message.MatchLanguage("en"))
+
+		resp := application(request, printer)
+		if len(resp) > 0 {
+			for _, err := range resp {
+				t.Errorf("%s", err)
+			}
+		}
+	*/
+}
--- a/go.mod
+++ b/go.mod
@@ -4,12 +4,7 @@
 
 require (
 	github.com/albrow/forms v0.3.3
-	github.com/olmaxmedical/database v0.0.1 // indirect
-	github.com/olmaxmedical/email v0.0.1 // indirect
 	github.com/olmaxmedical/plugins v0.0.1
 	github.com/olmaxmedical/router v0.0.1
-	github.com/pariz/gountries v0.0.0-20191029140926-233bc78cf5b5 // indirect
-	github.com/stretchr/testify v1.5.1 // indirect
 	golang.org/x/text v0.3.2
-	gopkg.in/yaml.v2 v2.2.8 // indirect
 )
--- a/go.sum
+++ b/go.sum
@@ -9,10 +9,10 @@
 github.com/olmaxmedical/database v0.0.1/go.mod h1:/5Tl6/p0jpvLpj4GaoFki3wRG/3b+ipNNhM5Dyi6Zf8=
 github.com/olmaxmedical/email v0.0.1 h1:bhOERmPiUmFJqC133s+FFXucSI3dNnfDKsboDYFEbkc=
 github.com/olmaxmedical/email v0.0.1/go.mod h1:bz6en9uc6h9fyu3MW2jTwYW19ZclQ22JkcIxsl3/epc=
-github.com/olmaxmedical/plugins v0.0.1 h1:KT6yy6faKLlDkGDx/RokGm+rsAxzKAzsFtb2zjaWUd8=
-github.com/olmaxmedical/plugins v0.0.1/go.mod h1:XIPHYhbFmjgxwo5ySRHXDK3Ar3Y3vcBW1k//nwMNncA=
-github.com/olmaxmedical/router v0.0.1 h1:0oDsfSoW+lP8g3yzql5QLAQgV4cTy4s+gZH7aJNJex8=
-github.com/olmaxmedical/router v0.0.1/go.mod h1:AM2lewexrBtUWFURwB9exKGvdHRGbKMEb1GL3iHX4js=
+github.com/olmaxmedical/plugins v0.0.1 h1:fON9AAfH635gLKNbytrUdRoRCjhI0ZPP7VFzCVZDVWA=
+github.com/olmaxmedical/plugins v0.0.1/go.mod h1:bHkYv5oh6bk5y1jCZDO9Bk5IyYMPWgZDjMrEifxVgbU=
+github.com/olmaxmedical/router v0.0.1 h1:x3fZ9u00xwKxLvPj8Au0QhIxpmxRv+q2lVMdBmyRQjM=
+github.com/olmaxmedical/router v0.0.1/go.mod h1:28e377pByZCQMBAdERDBhX4wYeTsJgc6U4yOEiz7MsA=
 github.com/olmaxmedical/session v0.0.1 h1:2xdSjpEg89+ClRFLPp/gR3lNxl4JjPAUd2Hsds++FFs=
 github.com/olmaxmedical/session v0.0.1/go.mod h1:XOVyHL+cKa5t2fLDIJtFxwEzJOa3r1hUkwlL4aybdqA=
 github.com/pariz/gountries v0.0.0-20191029140926-233bc78cf5b5 h1:842t0ixg/A4my8/Q3oDNdHIsKYIx02NDlWVEhaiBToo=