grim/resticide

A bunch of stuff
develop
2015-11-04, Gary Kramlich
6ca22ce9fc92
Parents 7f6b1b84337a
Children eac0cf79de6d
A bunch of stuff
--- a/.hgignore Sun Nov 01 17:53:57 2015 -0600
+++ b/.hgignore Wed Nov 04 22:12:45 2015 -0600
@@ -2,5 +2,7 @@
*.sublime-workspace
syntax: regexp
+Godeps/_workspace
resticide
+assets\.go
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Godeps/Godeps.json Wed Nov 04 22:12:45 2015 -0600
@@ -0,0 +1,5 @@
+{
+ "ImportPath": "bitbucket.org/rw_grim/resticide",
+ "GoVersion": "go1.4.2",
+ "Deps": []
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Godeps/Readme Wed Nov 04 22:12:45 2015 -0600
@@ -0,0 +1,5 @@
+This directory tree is generated automatically by godep.
+
+Please do not edit.
+
+See https://github.com/tools/godep for more information.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Wed Nov 04 22:12:45 2015 -0600
@@ -0,0 +1,30 @@
+#!/usr/bin/make -f
+
+TARGET = resticide
+
+GOPATH ?= ~/go
+PATH := $(GOPATH)/bin:$(PATH)
+
+.PHONY: all deps clean check
+
+all: $(TARGET)
+
+deps: Godeps
+ godep restore
+
+Godeps:
+ mkdir $@
+ touch $@
+
+assets.go: assets
+ go-bindata -o $@ assets/
+
+$(TARGET): *.go assets.go
+ go build -o $@
+
+clean:
+ rm -f $(TARGET)
+ rm -f assets.go
+
+check: $(TARGET)
+ ./$(TARGET) -path tests
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/assets/schema.json Wed Nov 04 22:12:45 2015 -0600
@@ -0,0 +1,40 @@
+{
+ "$schema": "http://json-schema.org/draft-04/schema#",
+ "definitions": {
+ "response": {
+ "type": "object",
+ "properties": {
+ "statuscode": {"type": "number"}
+ },
+ "required": ["statuscode"],
+ "additionalProperties": false
+ },
+ "request": {
+ "type": "object",
+ "properties": {
+ "path": {"type": "string"},
+ "method": {"type": "string"},
+ "response": {"$ref": "#/response"},
+ "headers": {
+ "type": "object"
+ }
+ },
+ "required": ["path", "method", "response"],
+ "additionalProperties": false
+ },
+ "requests": {
+ "type": "array",
+ "items": {"$ref": "#/request"}
+ }
+ },
+ "type": "object",
+ "properties": {
+ "name": {"type": "string"},
+ "$ref": {"type": "string"}
+ },
+ "oneOf": [{
+ "required": ["request", "name"]
+ }, {
+ "required": ["requests", "name"]
+ }]
+}
--- a/console_reporter.go Sun Nov 01 17:53:57 2015 -0600
+++ b/console_reporter.go Wed Nov 04 22:12:45 2015 -0600
@@ -25,9 +25,6 @@
fmt.Printf("%s %s\n", status, test.Duration.String())
if reporter.verbose || res.Passed == false {
- fmt.Printf(" url: %s\n", test.Request.Path)
- fmt.Printf(" status code: %d\n", res.HttpResponse.StatusCode)
- fmt.Printf(" headers:\n")
for name, value := range res.HttpResponse.Header {
fmt.Printf(" %s: %s\n", name, value)
}
--- a/test.go Sun Nov 01 17:53:57 2015 -0600
+++ b/test.go Wed Nov 04 22:12:45 2015 -0600
@@ -30,11 +30,16 @@
Response TestResponse
}
+type TestData struct {
+ Name string
+ Request TestRequest
+ Requests []TestRequest
+}
+
type Test struct {
Filename string
Name string
- Request TestRequest
- Result TestResult
+ Requests []TestRequest
Start time.Time
End time.Time
Duration time.Duration
@@ -121,13 +126,13 @@
}
func (test *Test) Run() TestResult {
- request, _ := test.Request.buildRequest()
+ request, _ := test.Requests[0].buildRequest()
client := &http.Client{}
resp, _ := client.Do(request)
defer resp.Body.Close()
- return test.Request.compareResponse(resp)
+ return test.Requests[0].compareResponse(resp)
}
func run_tests(tests []Test, reporters []Reporter) error {