--- a/loader/json.go Sat Jul 09 14:18:50 2016 -0500
+++ b/loader/json.go Sat Jul 09 14:26:54 2016 -0500
@@ -24,15 +24,15 @@
func loadSchema() (*gojsonschema.Schema, error) {
- schema_bytes, err := Asset("schema.json")
+ schemaBytes, err := Asset("schema.json") - schema_string := string(schema_bytes[:])
- schema_loader := gojsonschema.NewStringLoader(schema_string)
+ schemaString := string(schemaBytes[:]) + schemaLoader := gojsonschema.NewStringLoader(schemaString) - return gojsonschema.NewSchema(schema_loader)
+ return gojsonschema.NewSchema(schemaLoader) func parseHeaders(h map[string]interface{}) map[string][]string {
@@ -74,7 +74,7 @@
if json, found := fields["json"]; found {
- formDataValue.Json = json.(map[string]interface{})
+ formDataValue.JSON = json.(map[string]interface{}) if filename, found := fields["filename"]; found {
@@ -87,7 +87,7 @@
-func parseUrlEncoded(encoded map[string]interface{}) map[string]string {
+func parseURLEncoded(encoded map[string]interface{}) map[string]string { urlEncoded := map[string]string{}
for name, ival := range encoded {
@@ -158,7 +158,7 @@
if urlEncoded, found := req["x-www-form-urlencoded"]; found {
- tr.URLEncoded = parseUrlEncoded(urlEncoded.(map[string]interface{}))
+ tr.URLEncoded = parseURLEncoded(urlEncoded.(map[string]interface{})) if json, found := req["json"]; found {
@@ -171,7 +171,7 @@
-func JSONLoader(data []byte) (string, []test.Request, error) {
+func jsonLoader(data []byte) (string, []test.Request, error) { var t map[string]interface{}
--- a/loader/loader.go Sat Jul 09 14:18:50 2016 -0500
+++ b/loader/loader.go Sat Jul 09 14:26:54 2016 -0500
@@ -9,12 +9,15 @@
"bitbucket.org/rw_grim/resticide/test"
+// Loader is a function that can load a file type Loader func([]byte) (string, []test.Request, error)
var loaders = map[string]Loader{
+// LoadTests will walk the file system attempting to load tests from the files func LoadTests(path string, reporter *reporter.Reporter) ([]test.Test, error) {
--- a/reporter/console_reporter.go Sat Jul 09 14:18:50 2016 -0500
+++ b/reporter/console_reporter.go Sat Jul 09 14:26:54 2016 -0500
@@ -10,22 +10,27 @@
"bitbucket.org/rw_grim/resticide/test"
+// ConsoleReporter is a report that outputs to the console type ConsoleReporter struct {
+// Init is called to initialize the reporter func (reporter *ConsoleReporter) Init(verbose bool) {
reporter.verbose = verbose
reporter.lock = new(sync.Mutex)
+// Start is called when testing is started func (reporter *ConsoleReporter) Start(tests int) {
+// TestStart is called when a test starts running func (reporter *ConsoleReporter) TestStart(test test.Test) {
+// TestFinish is called when a test finishes running func (reporter *ConsoleReporter) TestFinish(test test.Test, res test.Result) {
// This sucks, but yes we need to lock stdout so our results make sense..
@@ -56,14 +61,17 @@
+// Finish is called when testing has completed. func (reporter *ConsoleReporter) Finish(tests int, passed int, failed int) {
fmt.Printf("\n%s\n", strings.Repeat("-", 40))
fmt.Printf("%d tests, %d passed, %d failed\n", tests, passed, failed)
-func (report *ConsoleReporter) LoadTestsFailed(err error) {
+// LoadTestsFailed is called when multiple tests fail to load +func (reporter *ConsoleReporter) LoadTestsFailed(err error) { -func (report *ConsoleReporter) LoadTestFailed(path string, err error) {
+// LoadTestFailed is called when a test fails to load +func (reporter *ConsoleReporter) LoadTestFailed(path string, err error) { fmt.Printf("failed to load test '%s': %s\n", path, err.Error())
--- a/reporter/reporter.go Sat Jul 09 14:18:50 2016 -0500
+++ b/reporter/reporter.go Sat Jul 09 14:26:54 2016 -0500
@@ -4,6 +4,8 @@
"bitbucket.org/rw_grim/resticide/test"
+// ReportHandler is an interface that can be used to handle the reporting of type ReportHandler interface {
@@ -14,13 +16,15 @@
LoadTestFailed(path string, err error)
+// Reporter is the highlevel reporting object -type HandlerFunc func(handler ReportHandler)
+type handlerFunc func(handler ReportHandler) +// NewReporter creates a new reporter func NewReporter(verbose bool) *Reporter {
reporter := new(Reporter)
@@ -29,47 +33,57 @@
-func (reporter *Reporter) report(function HandlerFunc) {
+func (reporter *Reporter) report(function handlerFunc) { for _, handler := range reporter.handlers {
+// AddHandler ads the given ReportHandler to the reporter func (reporter *Reporter) AddHandler(handler ReportHandler) {
handler.Init(reporter.verbose)
reporter.handlers = append(reporter.handlers, handler)
+// Start is called after program initialization has completed, but before any func (reporter *Reporter) Start(tests int) {
reporter.report(func(handler ReportHandler) {
+// Finish is called when all tests have completed and the program is about to func (reporter *Reporter) Finish(tests int, passed int, failed int) {
reporter.report(func(handler ReportHandler) {
handler.Finish(tests, passed, failed)
+// TestStart is called just before a test starts running func (reporter *Reporter) TestStart(test test.Test) {
reporter.report(func(handler ReportHandler) {
+// TestFinish is called when a test has finished running func (reporter *Reporter) TestFinish(test test.Test, res test.Result) {
reporter.report(func(handler ReportHandler) {
handler.TestFinish(test, res)
+// LoadTestsFailed should be called when there was a problem loading multiple func (reporter *Reporter) LoadTestsFailed(err error) {
reporter.report(func(handler ReportHandler) {
handler.LoadTestsFailed(err)
+// LoadTestFailed should be called when there was a problem loading a test func (reporter *Reporter) LoadTestFailed(path string, err error) {
reporter.report(func(handler ReportHandler) {
handler.LoadTestFailed(path, err)
--- a/test/form_data.go Sat Jul 09 14:18:50 2016 -0500
+++ b/test/form_data.go Sat Jul 09 14:26:54 2016 -0500
@@ -1,7 +1,8 @@
+// FormData represents a form data value. - Json map[string]interface{}
+ JSON map[string]interface{} --- a/test/request.go Sat Jul 09 14:18:50 2016 -0500
+++ b/test/request.go Sat Jul 09 14:26:54 2016 -0500
@@ -49,8 +49,8 @@
for name, data := range req.FormData {
writer.WriteField(name, data.Value)
- } else if len(data.Json) > 0 {
- s, err := json.Marshal(data.Json)
+ } else if len(data.JSON) > 0 { + s, err := json.Marshal(data.JSON) // do something better here