grim/resticide

940c4cf5c4fb
Parents eac0cf79de6d
Children 30401bc3140f
Lots of other goodies trying to get schema validation going
  • +15 -2
    Godeps/Godeps.json
  • +12 -7
    Makefile
  • +22 -1
    test.go
  • --- a/Godeps/Godeps.json Thu Nov 05 20:53:51 2015 -0600
    +++ b/Godeps/Godeps.json Thu Nov 05 20:54:09 2015 -0600
    @@ -1,5 +1,18 @@
    {
    "ImportPath": "bitbucket.org/rw_grim/resticide",
    - "GoVersion": "go1.4.2",
    - "Deps": []
    + "GoVersion": "go1.5.1",
    + "Deps": [
    + {
    + "ImportPath": "github.com/xeipuuv/gojsonpointer",
    + "Rev": "e0fe6f68307607d540ed8eac07a342c33fa1b54a"
    + },
    + {
    + "ImportPath": "github.com/xeipuuv/gojsonreference",
    + "Rev": "e02fc20de94c78484cd5ffb007f8af96be030a45"
    + },
    + {
    + "ImportPath": "github.com/xeipuuv/gojsonschema",
    + "Rev": "ac452913faa25c08bb78810d3e6f88b8a39f8f25"
    + }
    + ]
    }
    --- a/Makefile Thu Nov 05 20:53:51 2015 -0600
    +++ b/Makefile Thu Nov 05 20:54:09 2015 -0600
    @@ -2,21 +2,26 @@
    TARGET = resticide
    -GOPATH ?= ~/go
    +GOPATH ?= $(shell pwd)/go
    PATH := $(GOPATH)/bin:$(PATH)
    -.PHONY: all deps clean check
    +.PHONY: all deps clean check godep
    all: $(TARGET)
    -deps: Godeps
    +deps: Godeps/Godeps.json
    + touch $*
    +
    +godep:
    + GOPATH=$(GOPATH) go get github.com/tools/godep
    +
    +Godeps/Godeps.json: godep
    godep restore
    -Godeps:
    - mkdir $@
    - touch $@
    +gobindata: godep
    + GOPATH=$(GOPATH) go get github.com/jteeuwen/go-bindata/...
    -assets.go: assets
    +assets.go: assets Godeps/Godeps.json gobindata
    go-bindata -o $@ assets/
    $(TARGET): *.go assets.go
    --- a/test.go Thu Nov 05 20:53:51 2015 -0600
    +++ b/test.go Thu Nov 05 20:54:09 2015 -0600
    @@ -3,11 +3,14 @@
    import (
    "bytes"
    "encoding/json"
    + "fmt"
    "io/ioutil"
    "net/http"
    "os"
    "path/filepath"
    "time"
    +
    + "github.com/xeipuuv/gojsonschema"
    )
    type TestResult struct {
    @@ -45,10 +48,28 @@
    Duration time.Duration
    }
    +func load_schema() (*gojsonschema.Schema, error) {
    + schema_bytes, err := Asset("assets/schema.json")
    + if err != nil {
    + return nil, err
    + }
    +
    + schema_string := string(schema_bytes[:])
    + schema_loader = gojsonschema.NewStringLoader(schema_string)
    + schema = gojsonschema.NewSchema(schema_loader)
    +
    + return schema, nil
    +}
    +
    func find_tests(path string) ([]Test, error) {
    + schema, err := load_schema()
    + if err != nil {
    + return nil, err
    + }
    +
    tests := []Test{}
    - err := filepath.Walk(path, func(path string, _ os.FileInfo, _ error) error {
    + err = filepath.Walk(path, func(path string, _ os.FileInfo, _ error) error {
    stat, err := os.Stat(path)
    if os.IsNotExist(err) {
    return nil