├── .gitignore ├── .godir ├── .travis.yml ├── Godeps ├── Godeps.json └── Readme ├── LICENSE ├── Makefile ├── Procfile ├── README.md ├── cmd └── hello │ └── main.go ├── contrib └── docker │ ├── .dockerignore │ └── Dockerfile ├── hello.go ├── hello_test.go └── vendor └── github.com ├── Sirupsen └── logrus │ ├── .gitignore │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── entry.go │ ├── examples │ ├── basic │ │ └── basic.go │ └── hook │ │ └── hook.go │ ├── exported.go │ ├── formatter.go │ ├── formatters │ └── logstash │ │ └── logstash.go │ ├── hooks.go │ ├── hooks │ ├── airbrake │ │ └── airbrake.go │ ├── bugsnag │ │ └── bugsnag.go │ ├── papertrail │ │ ├── README.md │ │ └── papertrail.go │ ├── sentry │ │ ├── README.md │ │ └── sentry.go │ └── syslog │ │ ├── README.md │ │ └── syslog.go │ ├── json_formatter.go │ ├── logger.go │ ├── logrus.go │ ├── terminal_bsd.go │ ├── terminal_linux.go │ ├── terminal_notwindows.go │ ├── terminal_windows.go │ ├── text_formatter.go │ └── writer.go ├── jtolds └── gls │ ├── LICENSE │ ├── README.md │ ├── context.go │ ├── gen_sym.go │ ├── id_pool.go │ └── stack_tags.go └── smartystreets ├── assertions ├── .gitignore ├── .travis.yml ├── LICENSE.md ├── README.md ├── assertions.goconvey ├── collections.go ├── doc.go ├── equality.go ├── filter.go ├── internal │ ├── Makefile │ ├── oglematchers │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── all_of.go │ │ ├── any.go │ │ ├── any_of.go │ │ ├── contains.go │ │ ├── deep_equals.go │ │ ├── elements_are.go │ │ ├── equals.go │ │ ├── error.go │ │ ├── greater_or_equal.go │ │ ├── greater_than.go │ │ ├── has_same_type_as.go │ │ ├── has_substr.go │ │ ├── identical_to.go │ │ ├── less_or_equal.go │ │ ├── less_than.go │ │ ├── matcher.go │ │ ├── matches_regexp.go │ │ ├── new_matcher.go │ │ ├── not.go │ │ ├── panics.go │ │ ├── pointee.go │ │ └── transform_description.go │ ├── oglemock │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── action.go │ │ ├── controller.go │ │ ├── createmock │ │ │ ├── createmock.go │ │ │ └── test_cases │ │ │ │ ├── golden.no_interfaces │ │ │ │ ├── golden.no_package │ │ │ │ ├── golden.unknown_interface │ │ │ │ └── golden.unknown_package │ │ ├── do_all.go │ │ ├── error_reporter.go │ │ ├── expectation.go │ │ ├── generate │ │ │ ├── generate.go │ │ │ └── test_cases │ │ │ │ ├── complicated_pkg │ │ │ │ └── complicated_pkg.go │ │ │ │ ├── golden.complicated_pkg.go │ │ │ │ ├── golden.image.go │ │ │ │ ├── golden.io_reader_writer.go │ │ │ │ ├── golden.renamed_pkg.go │ │ │ │ └── renamed_pkg │ │ │ │ └── renamed_pkg.go │ │ ├── internal_expectation.go │ │ ├── invoke.go │ │ ├── mock_object.go │ │ ├── return.go │ │ ├── sample │ │ │ ├── README.markdown │ │ │ └── mock_io │ │ │ │ └── mock_io.go │ │ └── save_arg.go │ ├── ogletest │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── assert_aliases.go │ │ ├── assert_that.go │ │ ├── doc.go │ │ ├── expect_aliases.go │ │ ├── expect_call.go │ │ ├── expect_that.go │ │ ├── failure.go │ │ ├── register.go │ │ ├── register_test_suite.go │ │ ├── run_tests.go │ │ ├── srcutil │ │ │ ├── docs.go │ │ │ └── methods.go │ │ ├── test_cases │ │ │ ├── failing.test.go │ │ │ ├── filtered.test.go │ │ │ ├── golden.failing_test │ │ │ ├── golden.filtered_test │ │ │ ├── golden.mock_test │ │ │ ├── golden.no_cases_test │ │ │ ├── golden.panicking_test │ │ │ ├── golden.passing_test │ │ │ ├── golden.run_twice_test │ │ │ ├── golden.stop_test │ │ │ ├── golden.unexported_test │ │ │ ├── mock.test.go │ │ │ ├── mock_image │ │ │ │ └── mock_image.go │ │ │ ├── no_cases.test.go │ │ │ ├── panicking.test.go │ │ │ ├── passing.test.go │ │ │ ├── run_twice.test.go │ │ │ ├── stop.test.go │ │ │ └── unexported.test.go │ │ └── test_info.go │ └── reqtrace │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── reqtrace.go │ │ └── trace_state.go ├── messages.go ├── panic.go ├── quantity.go ├── serializer.go ├── should │ └── should.go ├── strings.go ├── time.go └── type.go └── goconvey ├── LICENSE.md ├── convey ├── assertions.go ├── context.go ├── convey.goconvey ├── discovery.go ├── doc.go ├── gotest │ └── utils.go ├── init.go ├── nilReporter.go └── reporting │ ├── console.go │ ├── doc.go │ ├── dot.go │ ├── gotest.go │ ├── init.go │ ├── json.go │ ├── printer.go │ ├── problems.go │ ├── reporter.go │ ├── reporting.goconvey │ ├── reports.go │ ├── statistics.go │ └── story.go └── web └── client └── resources └── fonts └── Open_Sans └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Binary 2 | hello 3 | 4 | # Profile output 5 | profile.out 6 | 7 | # dist 8 | /dist 9 | /contrib/docker/entrypoint 10 | /contrib/docker/linux_386 11 | 12 | # Junk files 13 | *~ 14 | *# 15 | .#* 16 | 17 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 18 | *.o 19 | *.a 20 | *.so 21 | 22 | # Folders 23 | _obj 24 | _test 25 | 26 | # Architecture specific extensions/prefixes 27 | *.[568vq] 28 | [568vq].out 29 | 30 | *.cgo1.go 31 | *.cgo2.c 32 | _cgo_defun.c 33 | _cgo_gotypes.go 34 | _cgo_export.* 35 | 36 | _testmain.go 37 | 38 | *.exe 39 | *.test 40 | *.prof 41 | -------------------------------------------------------------------------------- /.godir: -------------------------------------------------------------------------------- 1 | github.com/moul/golang-boilerplate/cmd/hello -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | #- 1.1 5 | #- 1.2 6 | #- 1.3 7 | #- 1.4 8 | - 1.5 9 | - tip 10 | 11 | env: 12 | - GO15VENDOREXPERIMENT=1 13 | 14 | matrix: 15 | allow_failures: 16 | - go: tip 17 | 18 | before_install: 19 | - go get -u github.com/axw/gocov/gocov 20 | - go get -u github.com/mattn/goveralls 21 | - go get golang.org/x/tools/cmd/cover 22 | 23 | script: 24 | - make build 25 | - make test 26 | - make cover 27 | - goveralls -service=travis-ci -v -covermode=count -coverprofile=profile.out 28 | -------------------------------------------------------------------------------- /Godeps/Godeps.json: -------------------------------------------------------------------------------- 1 | { 2 | "ImportPath": "github.com/moul/golang-boilerplate", 3 | "GoVersion": "go1.5.1", 4 | "Packages": [ 5 | "github.com/moul/golang-boilerplate", 6 | "github.com/moul/golang-boilerplate/cmd/hello" 7 | ], 8 | "Deps": [ 9 | { 10 | "ImportPath": "github.com/Sirupsen/logrus", 11 | "Comment": "v0.8.6-13-g84b968c", 12 | "Rev": "84b968cb9f82d727044973f8255489bbe15e9948" 13 | }, 14 | { 15 | "ImportPath": "github.com/jtolds/gls", 16 | "Rev": "9a4a02dbe491bef4bab3c24fd9f3087d6c4c6690" 17 | }, 18 | { 19 | "ImportPath": "github.com/smartystreets/assertions", 20 | "Comment": "1.5.0-405-g01fedaa", 21 | "Rev": "01fedaa993c0a9f9aa55111501cd7c81a49e812e" 22 | }, 23 | { 24 | "ImportPath": "github.com/smartystreets/goconvey/convey", 25 | "Comment": "1.5.0-453-g5bb9e11", 26 | "Rev": "5bb9e117a1a4f1a1555a4d41cd233c79b1a5209f" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /Godeps/Readme: -------------------------------------------------------------------------------- 1 | This directory tree is generated automatically by godep. 2 | 3 | Please do not edit. 4 | 5 | See https://github.com/tools/godep for more information. 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Manfred Touron 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Project-specific variables 2 | BINARIES ?= hello 3 | CONVEY_PORT ?= 9042 4 | 5 | 6 | # Common variables 7 | SOURCES := $(shell find . -type f -name "*.go") 8 | COMMANDS := $(shell go list ./... | grep -v /vendor/ | grep /cmd/) 9 | PACKAGES := $(shell go list ./... | grep -v /vendor/ | grep -v /cmd/) 10 | GOENV ?= GO15VENDOREXPERIMENT=1 11 | GO ?= $(GOENV) go 12 | GODEP ?= $(GOENV) godep 13 | USER ?= $(shell whoami) 14 | 15 | 16 | all: build 17 | 18 | 19 | .PHONY: build 20 | build: $(BINARIES) 21 | 22 | 23 | $(BINARIES): $(SOURCES) 24 | $(GO) build -o $@ ./cmd/$@ 25 | 26 | 27 | .PHONY: test 28 | test: 29 | $(GO) get -t . 30 | $(GO) test -v . 31 | 32 | 33 | .PHONY: godep-save 34 | godep-save: 35 | $(GODEP) save $(PACKAGES) $(COMMANDS) 36 | 37 | 38 | .PHONY: clean 39 | clean: 40 | rm -f $(BINARIES) 41 | 42 | 43 | .PHONY: re 44 | re: clean all 45 | 46 | 47 | .PHONY: convey 48 | convey: 49 | $(GO) get github.com/smartystreets/goconvey 50 | goconvey -cover -port=$(CONVEY_PORT) -workDir="$(realpath .)" -depth=1 51 | 52 | 53 | .PHONY: cover 54 | cover: profile.out 55 | 56 | 57 | profile.out: $(SOURCES) 58 | rm -f $@ 59 | $(GO) test -covermode=count -coverpkg=. -coverprofile=$@ . 60 | 61 | 62 | .PHONY: docker-build 63 | docker-build: 64 | go get github.com/laher/goxc 65 | rm -rf contrib/docker/linux_386 66 | for binary in $(BINARIES); do \ 67 | goxc -bc="linux,386" -d . -pv contrib/docker -n $$binary xc; \ 68 | mv contrib/docker/linux_386/$$binary contrib/docker/entrypoint; \ 69 | docker build -t $(USER)/$$binary contrib/docker; \ 70 | docker run -it --rm $(USER)/$$binary || true; \ 71 | docker inspect --type=image --format="{{ .Id }}" moul/$$binary || true; \ 72 | echo "Now you can run 'docker push $(USER)/$$binary'"; \ 73 | done 74 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: hello server 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hello 2 | :wrench: hello world in Golang. 3 | 4 | [![GoDoc](https://godoc.org/github.com/moul/golang-boilerplate?status.svg)](https://godoc.org/github.com/moul/golang-boilerplate) 5 | [![Build Status](https://travis-ci.org/moul/golang-boilerplate.svg?branch=master)](https://travis-ci.org/moul/golang-boilerplate) 6 | [![Coverage Status](https://coveralls.io/repos/moul/golang-boilerplate/badge.svg?branch=master&service=github)](https://coveralls.io/github/moul/golang-boilerplate?branch=master) 7 | [![](https://badge.imagelayers.io/moul/golang-boilerplate:latest.svg)](https://imagelayers.io/?images=moul/golang-boilerplate:latest) 8 | 9 | ## Usage 10 | 11 | ```console 12 | $ hello 13 | Hello world ! 14 | ``` 15 | 16 | ## Install 17 | 18 | ```console 19 | $ go get github.com/moul/golang-boilerplate/cmd/... 20 | ``` 21 | 22 | ## Run with docker 23 | 24 | ```console 25 | $ docker run moul/golang-boilerplate 26 | Hello world ! 27 | ``` 28 | 29 | ## License 30 | 31 | MIT 32 | -------------------------------------------------------------------------------- /cmd/hello/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/Sirupsen/logrus" 7 | "github.com/moul/golang-boilerplate" 8 | ) 9 | 10 | func main() { 11 | instance := hello.NewHello("world") 12 | greetings, err := instance.Hey() 13 | if err != nil { 14 | logrus.Fatalf("Failed to get greetings: %v", err) 15 | } 16 | fmt.Println(greetings) 17 | } 18 | -------------------------------------------------------------------------------- /contrib/docker/.dockerignore: -------------------------------------------------------------------------------- 1 | linux_386 2 | -------------------------------------------------------------------------------- /contrib/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM scratch 2 | MAINTAINER Manfred Touron (@moul) 3 | ADD ./entrypoint /usr/bin/entrypoint 4 | ENTRYPOINT ["/usr/bin/entrypoint"] 5 | -------------------------------------------------------------------------------- /hello.go: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import "fmt" 4 | 5 | type Hello struct { 6 | Message string 7 | } 8 | 9 | func NewHello(msg string) Hello { 10 | return Hello{ 11 | Message: msg, 12 | } 13 | } 14 | 15 | func (h *Hello) Hey() (string, error) { 16 | return fmt.Sprintf("Hello %s !", h.Message), nil 17 | } 18 | -------------------------------------------------------------------------------- /hello_test.go: -------------------------------------------------------------------------------- 1 | package hello 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | . "github.com/smartystreets/goconvey/convey" 8 | ) 9 | 10 | func ExampleHello_Hey() { 11 | instance := NewHello("world") 12 | greetings, _ := instance.Hey() 13 | fmt.Println(greetings) 14 | // Output: Hello world ! 15 | } 16 | 17 | func TestNewHello(t *testing.T) { 18 | Convey("Testing NewHello()", t, func() { 19 | instance := NewHello("world") 20 | So(instance.Message, ShouldEqual, "world") 21 | greetings, err := instance.Hey() 22 | So(err, ShouldBeNil) 23 | So(greetings, ShouldEqual, "Hello world !") 24 | }) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/.gitignore: -------------------------------------------------------------------------------- 1 | logrus 2 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | go: 3 | - 1.2 4 | - 1.3 5 | - 1.4 6 | - tip 7 | install: 8 | - go get -t ./... 9 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 0.8.6 2 | 3 | * hooks/raven: allow passing an initialized client 4 | 5 | # 0.8.5 6 | 7 | * logrus/core: revert #208 8 | 9 | # 0.8.4 10 | 11 | * formatter/text: fix data race (#218) 12 | 13 | # 0.8.3 14 | 15 | * logrus/core: fix entry log level (#208) 16 | * logrus/core: improve performance of text formatter by 40% 17 | * logrus/core: expose `LevelHooks` type 18 | * logrus/core: add support for DragonflyBSD and NetBSD 19 | * formatter/text: print structs more verbosely 20 | 21 | # 0.8.2 22 | 23 | * logrus: fix more Fatal family functions 24 | 25 | # 0.8.1 26 | 27 | * logrus: fix not exiting on `Fatalf` and `Fatalln` 28 | 29 | # 0.8.0 30 | 31 | * logrus: defaults to stderr instead of stdout 32 | * hooks/sentry: add special field for `*http.Request` 33 | * formatter/text: ignore Windows for colors 34 | 35 | # 0.7.3 36 | 37 | * formatter/\*: allow configuration of timestamp layout 38 | 39 | # 0.7.2 40 | 41 | * formatter/text: Add configuration option for time format (#158) 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Simon Eskildsen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/basic/basic.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | ) 6 | 7 | var log = logrus.New() 8 | 9 | func init() { 10 | log.Formatter = new(logrus.JSONFormatter) 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Level = logrus.DebugLevel 13 | } 14 | 15 | func main() { 16 | defer func() { 17 | err := recover() 18 | if err != nil { 19 | log.WithFields(logrus.Fields{ 20 | "omg": true, 21 | "err": err, 22 | "number": 100, 23 | }).Fatal("The ice breaks!") 24 | } 25 | }() 26 | 27 | log.WithFields(logrus.Fields{ 28 | "animal": "walrus", 29 | "number": 8, 30 | }).Debug("Started observing beach") 31 | 32 | log.WithFields(logrus.Fields{ 33 | "animal": "walrus", 34 | "size": 10, 35 | }).Info("A group of walrus emerges from the ocean") 36 | 37 | log.WithFields(logrus.Fields{ 38 | "omg": true, 39 | "number": 122, 40 | }).Warn("The group's number increased tremendously!") 41 | 42 | log.WithFields(logrus.Fields{ 43 | "temperature": -4, 44 | }).Debug("Temperature changes") 45 | 46 | log.WithFields(logrus.Fields{ 47 | "animal": "orca", 48 | "size": 9009, 49 | }).Panic("It's over 9000!") 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/examples/hook/hook.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "github.com/Sirupsen/logrus" 5 | "github.com/Sirupsen/logrus/hooks/airbrake" 6 | ) 7 | 8 | var log = logrus.New() 9 | 10 | func init() { 11 | log.Formatter = new(logrus.TextFormatter) // default 12 | log.Hooks.Add(airbrake.NewHook("https://example.com", "xyz", "development")) 13 | } 14 | 15 | func main() { 16 | log.WithFields(logrus.Fields{ 17 | "animal": "walrus", 18 | "size": 10, 19 | }).Info("A group of walrus emerges from the ocean") 20 | 21 | log.WithFields(logrus.Fields{ 22 | "omg": true, 23 | "number": 122, 24 | }).Warn("The group's number increased tremendously!") 25 | 26 | log.WithFields(logrus.Fields{ 27 | "omg": true, 28 | "number": 100, 29 | }).Fatal("The ice breaks!") 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import "time" 4 | 5 | const DefaultTimestampFormat = time.RFC3339 6 | 7 | // The Formatter interface is used to implement a custom Formatter. It takes an 8 | // `Entry`. It exposes all the fields, including the default ones: 9 | // 10 | // * `entry.Data["msg"]`. The message passed from Info, Warn, Error .. 11 | // * `entry.Data["time"]`. The timestamp. 12 | // * `entry.Data["level"]. The level the entry was logged at. 13 | // 14 | // Any additional fields added with `WithField` or `WithFields` are also in 15 | // `entry.Data`. Format is expected to return an array of bytes which are then 16 | // logged to `logger.Out`. 17 | type Formatter interface { 18 | Format(*Entry) ([]byte, error) 19 | } 20 | 21 | // This is to not silently overwrite `time`, `msg` and `level` fields when 22 | // dumping it. If this code wasn't there doing: 23 | // 24 | // logrus.WithField("level", 1).Info("hello") 25 | // 26 | // Would just silently drop the user provided level. Instead with this code 27 | // it'll logged as: 28 | // 29 | // {"level": "info", "fields.level": 1, "msg": "hello", "time": "..."} 30 | // 31 | // It's not exported because it's still using Data in an opinionated way. It's to 32 | // avoid code duplication between the two default formatters. 33 | func prefixFieldClashes(data Fields) { 34 | _, ok := data["time"] 35 | if ok { 36 | data["fields.time"] = data["time"] 37 | } 38 | 39 | _, ok = data["msg"] 40 | if ok { 41 | data["fields.msg"] = data["msg"] 42 | } 43 | 44 | _, ok = data["level"] 45 | if ok { 46 | data["fields.level"] = data["level"] 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/formatters/logstash/logstash.go: -------------------------------------------------------------------------------- 1 | package logstash 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/Sirupsen/logrus" 8 | ) 9 | 10 | // Formatter generates json in logstash format. 11 | // Logstash site: http://logstash.net/ 12 | type LogstashFormatter struct { 13 | Type string // if not empty use for logstash type field. 14 | 15 | // TimestampFormat sets the format used for timestamps. 16 | TimestampFormat string 17 | } 18 | 19 | func (f *LogstashFormatter) Format(entry *logrus.Entry) ([]byte, error) { 20 | entry.Data["@version"] = 1 21 | 22 | if f.TimestampFormat == "" { 23 | f.TimestampFormat = logrus.DefaultTimestampFormat 24 | } 25 | 26 | entry.Data["@timestamp"] = entry.Time.Format(f.TimestampFormat) 27 | 28 | // set message field 29 | v, ok := entry.Data["message"] 30 | if ok { 31 | entry.Data["fields.message"] = v 32 | } 33 | entry.Data["message"] = entry.Message 34 | 35 | // set level field 36 | v, ok = entry.Data["level"] 37 | if ok { 38 | entry.Data["fields.level"] = v 39 | } 40 | entry.Data["level"] = entry.Level.String() 41 | 42 | // set type field 43 | if f.Type != "" { 44 | v, ok = entry.Data["type"] 45 | if ok { 46 | entry.Data["fields.type"] = v 47 | } 48 | entry.Data["type"] = f.Type 49 | } 50 | 51 | serialized, err := json.Marshal(entry.Data) 52 | if err != nil { 53 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 54 | } 55 | return append(serialized, '\n'), nil 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | // A hook to be fired when logging on the logging levels returned from 4 | // `Levels()` on your implementation of the interface. Note that this is not 5 | // fired in a goroutine or a channel with workers, you should handle such 6 | // functionality yourself if your call is non-blocking and you don't wish for 7 | // the logging calls for levels returned from `Levels()` to block. 8 | type Hook interface { 9 | Levels() []Level 10 | Fire(*Entry) error 11 | } 12 | 13 | // Internal type for storing the hooks on a logger instance. 14 | type LevelHooks map[Level][]Hook 15 | 16 | // Add a hook to an instance of logger. This is called with 17 | // `log.Hooks.Add(new(MyHook))` where `MyHook` implements the `Hook` interface. 18 | func (hooks LevelHooks) Add(hook Hook) { 19 | for _, level := range hook.Levels() { 20 | hooks[level] = append(hooks[level], hook) 21 | } 22 | } 23 | 24 | // Fire all the hooks for the passed level. Used by `entry.log` to fire 25 | // appropriate hooks for a log entry. 26 | func (hooks LevelHooks) Fire(level Level, entry *Entry) error { 27 | for _, hook := range hooks[level] { 28 | if err := hook.Fire(entry); err != nil { 29 | return err 30 | } 31 | } 32 | 33 | return nil 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/airbrake/airbrake.go: -------------------------------------------------------------------------------- 1 | package airbrake 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | 7 | "github.com/Sirupsen/logrus" 8 | "github.com/tobi/airbrake-go" 9 | ) 10 | 11 | // AirbrakeHook to send exceptions to an exception-tracking service compatible 12 | // with the Airbrake API. 13 | type airbrakeHook struct { 14 | APIKey string 15 | Endpoint string 16 | Environment string 17 | } 18 | 19 | func NewHook(endpoint, apiKey, env string) *airbrakeHook { 20 | return &airbrakeHook{ 21 | APIKey: apiKey, 22 | Endpoint: endpoint, 23 | Environment: env, 24 | } 25 | } 26 | 27 | func (hook *airbrakeHook) Fire(entry *logrus.Entry) error { 28 | airbrake.ApiKey = hook.APIKey 29 | airbrake.Endpoint = hook.Endpoint 30 | airbrake.Environment = hook.Environment 31 | 32 | var notifyErr error 33 | err, ok := entry.Data["error"].(error) 34 | if ok { 35 | notifyErr = err 36 | } else { 37 | notifyErr = errors.New(entry.Message) 38 | } 39 | 40 | airErr := airbrake.Notify(notifyErr) 41 | if airErr != nil { 42 | return fmt.Errorf("Failed to send error to Airbrake: %s", airErr) 43 | } 44 | 45 | return nil 46 | } 47 | 48 | func (hook *airbrakeHook) Levels() []logrus.Level { 49 | return []logrus.Level{ 50 | logrus.ErrorLevel, 51 | logrus.FatalLevel, 52 | logrus.PanicLevel, 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/bugsnag/bugsnag.go: -------------------------------------------------------------------------------- 1 | package logrus_bugsnag 2 | 3 | import ( 4 | "errors" 5 | 6 | "github.com/Sirupsen/logrus" 7 | "github.com/bugsnag/bugsnag-go" 8 | ) 9 | 10 | type bugsnagHook struct{} 11 | 12 | // ErrBugsnagUnconfigured is returned if NewBugsnagHook is called before 13 | // bugsnag.Configure. Bugsnag must be configured before the hook. 14 | var ErrBugsnagUnconfigured = errors.New("bugsnag must be configured before installing this logrus hook") 15 | 16 | // ErrBugsnagSendFailed indicates that the hook failed to submit an error to 17 | // bugsnag. The error was successfully generated, but `bugsnag.Notify()` 18 | // failed. 19 | type ErrBugsnagSendFailed struct { 20 | err error 21 | } 22 | 23 | func (e ErrBugsnagSendFailed) Error() string { 24 | return "failed to send error to Bugsnag: " + e.err.Error() 25 | } 26 | 27 | // NewBugsnagHook initializes a logrus hook which sends exceptions to an 28 | // exception-tracking service compatible with the Bugsnag API. Before using 29 | // this hook, you must call bugsnag.Configure(). The returned object should be 30 | // registered with a log via `AddHook()` 31 | // 32 | // Entries that trigger an Error, Fatal or Panic should now include an "error" 33 | // field to send to Bugsnag. 34 | func NewBugsnagHook() (*bugsnagHook, error) { 35 | if bugsnag.Config.APIKey == "" { 36 | return nil, ErrBugsnagUnconfigured 37 | } 38 | return &bugsnagHook{}, nil 39 | } 40 | 41 | // Fire forwards an error to Bugsnag. Given a logrus.Entry, it extracts the 42 | // "error" field (or the Message if the error isn't present) and sends it off. 43 | func (hook *bugsnagHook) Fire(entry *logrus.Entry) error { 44 | var notifyErr error 45 | err, ok := entry.Data["error"].(error) 46 | if ok { 47 | notifyErr = err 48 | } else { 49 | notifyErr = errors.New(entry.Message) 50 | } 51 | 52 | bugsnagErr := bugsnag.Notify(notifyErr) 53 | if bugsnagErr != nil { 54 | return ErrBugsnagSendFailed{bugsnagErr} 55 | } 56 | 57 | return nil 58 | } 59 | 60 | // Levels enumerates the log levels on which the error should be forwarded to 61 | // bugsnag: everything at or above the "Error" level. 62 | func (hook *bugsnagHook) Levels() []logrus.Level { 63 | return []logrus.Level{ 64 | logrus.ErrorLevel, 65 | logrus.FatalLevel, 66 | logrus.PanicLevel, 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/papertrail/README.md: -------------------------------------------------------------------------------- 1 | # Papertrail Hook for Logrus :walrus: 2 | 3 | [Papertrail](https://papertrailapp.com) provides hosted log management. Once stored in Papertrail, you can [group](http://help.papertrailapp.com/kb/how-it-works/groups/) your logs on various dimensions, [search](http://help.papertrailapp.com/kb/how-it-works/search-syntax) them, and trigger [alerts](http://help.papertrailapp.com/kb/how-it-works/alerts). 4 | 5 | In most deployments, you'll want to send logs to Papertrail via their [remote_syslog](http://help.papertrailapp.com/kb/configuration/configuring-centralized-logging-from-text-log-files-in-unix/) daemon, which requires no application-specific configuration. This hook is intended for relatively low-volume logging, likely in managed cloud hosting deployments where installing `remote_syslog` is not possible. 6 | 7 | ## Usage 8 | 9 | You can find your Papertrail UDP port on your [Papertrail account page](https://papertrailapp.com/account/destinations). Substitute it below for `YOUR_PAPERTRAIL_UDP_PORT`. 10 | 11 | For `YOUR_APP_NAME`, substitute a short string that will readily identify your application or service in the logs. 12 | 13 | ```go 14 | import ( 15 | "log/syslog" 16 | "github.com/Sirupsen/logrus" 17 | "github.com/Sirupsen/logrus/hooks/papertrail" 18 | ) 19 | 20 | func main() { 21 | log := logrus.New() 22 | hook, err := logrus_papertrail.NewPapertrailHook("logs.papertrailapp.com", YOUR_PAPERTRAIL_UDP_PORT, YOUR_APP_NAME) 23 | 24 | if err == nil { 25 | log.Hooks.Add(hook) 26 | } 27 | } 28 | ``` 29 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/papertrail/papertrail.go: -------------------------------------------------------------------------------- 1 | package logrus_papertrail 2 | 3 | import ( 4 | "fmt" 5 | "net" 6 | "os" 7 | "time" 8 | 9 | "github.com/Sirupsen/logrus" 10 | ) 11 | 12 | const ( 13 | format = "Jan 2 15:04:05" 14 | ) 15 | 16 | // PapertrailHook to send logs to a logging service compatible with the Papertrail API. 17 | type PapertrailHook struct { 18 | Host string 19 | Port int 20 | AppName string 21 | UDPConn net.Conn 22 | } 23 | 24 | // NewPapertrailHook creates a hook to be added to an instance of logger. 25 | func NewPapertrailHook(host string, port int, appName string) (*PapertrailHook, error) { 26 | conn, err := net.Dial("udp", fmt.Sprintf("%s:%d", host, port)) 27 | return &PapertrailHook{host, port, appName, conn}, err 28 | } 29 | 30 | // Fire is called when a log event is fired. 31 | func (hook *PapertrailHook) Fire(entry *logrus.Entry) error { 32 | date := time.Now().Format(format) 33 | msg, _ := entry.String() 34 | payload := fmt.Sprintf("<22> %s %s: %s", date, hook.AppName, msg) 35 | 36 | bytesWritten, err := hook.UDPConn.Write([]byte(payload)) 37 | if err != nil { 38 | fmt.Fprintf(os.Stderr, "Unable to send log line to Papertrail via UDP. Wrote %d bytes before error: %v", bytesWritten, err) 39 | return err 40 | } 41 | 42 | return nil 43 | } 44 | 45 | // Levels returns the available logging levels. 46 | func (hook *PapertrailHook) Levels() []logrus.Level { 47 | return []logrus.Level{ 48 | logrus.PanicLevel, 49 | logrus.FatalLevel, 50 | logrus.ErrorLevel, 51 | logrus.WarnLevel, 52 | logrus.InfoLevel, 53 | logrus.DebugLevel, 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/sentry/README.md: -------------------------------------------------------------------------------- 1 | # Sentry Hook for Logrus :walrus: 2 | 3 | [Sentry](https://getsentry.com) provides both self-hosted and hosted 4 | solutions for exception tracking. 5 | Both client and server are 6 | [open source](https://github.com/getsentry/sentry). 7 | 8 | ## Usage 9 | 10 | Every sentry application defined on the server gets a different 11 | [DSN](https://www.getsentry.com/docs/). In the example below replace 12 | `YOUR_DSN` with the one created for your application. 13 | 14 | ```go 15 | import ( 16 | "github.com/Sirupsen/logrus" 17 | "github.com/Sirupsen/logrus/hooks/sentry" 18 | ) 19 | 20 | func main() { 21 | log := logrus.New() 22 | hook, err := logrus_sentry.NewSentryHook(YOUR_DSN, []logrus.Level{ 23 | logrus.PanicLevel, 24 | logrus.FatalLevel, 25 | logrus.ErrorLevel, 26 | }) 27 | 28 | if err == nil { 29 | log.Hooks.Add(hook) 30 | } 31 | } 32 | ``` 33 | 34 | If you wish to initialize a SentryHook with tags, you can use the `NewWithTagsSentryHook` constructor to provide default tags: 35 | 36 | ```go 37 | tags := map[string]string{ 38 | "site": "example.com", 39 | } 40 | levels := []logrus.Level{ 41 | logrus.PanicLevel, 42 | logrus.FatalLevel, 43 | logrus.ErrorLevel, 44 | } 45 | hook, err := logrus_sentry.NewWithTagsSentryHook(YOUR_DSN, tags, levels) 46 | 47 | ``` 48 | 49 | If you wish to initialize a SentryHook with an already initialized raven client, you can use 50 | the `NewWithClientSentryHook` constructor: 51 | 52 | ```go 53 | import ( 54 | "github.com/Sirupsen/logrus" 55 | "github.com/Sirupsen/logrus/hooks/sentry" 56 | "github.com/getsentry/raven-go" 57 | ) 58 | 59 | func main() { 60 | log := logrus.New() 61 | 62 | client, err := raven.New(YOUR_DSN) 63 | if err != nil { 64 | log.Fatal(err) 65 | } 66 | 67 | hook, err := logrus_sentry.NewWithClientSentryHook(client, []logrus.Level{ 68 | logrus.PanicLevel, 69 | logrus.FatalLevel, 70 | logrus.ErrorLevel, 71 | }) 72 | 73 | if err == nil { 74 | log.Hooks.Add(hook) 75 | } 76 | } 77 | 78 | hook, err := NewWithClientSentryHook(client, []logrus.Level{ 79 | logrus.ErrorLevel, 80 | }) 81 | ``` 82 | 83 | ## Special fields 84 | 85 | Some logrus fields have a special meaning in this hook, 86 | these are `server_name`, `logger` and `http_request`. 87 | When logs are sent to sentry these fields are treated differently. 88 | - `server_name` (also known as hostname) is the name of the server which 89 | is logging the event (hostname.example.com) 90 | - `logger` is the part of the application which is logging the event. 91 | In go this usually means setting it to the name of the package. 92 | - `http_request` is the in-coming request(*http.Request). The detailed request data are sent to Sentry. 93 | 94 | ## Timeout 95 | 96 | `Timeout` is the time the sentry hook will wait for a response 97 | from the sentry server. 98 | 99 | If this time elapses with no response from 100 | the server an error will be returned. 101 | 102 | If `Timeout` is set to 0 the SentryHook will not wait for a reply 103 | and will assume a correct delivery. 104 | 105 | The SentryHook has a default timeout of `100 milliseconds` when created 106 | with a call to `NewSentryHook`. This can be changed by assigning a value to the `Timeout` field: 107 | 108 | ```go 109 | hook, _ := logrus_sentry.NewSentryHook(...) 110 | hook.Timeout = 20*time.Second 111 | ``` 112 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/syslog/README.md: -------------------------------------------------------------------------------- 1 | # Syslog Hooks for Logrus :walrus: 2 | 3 | ## Usage 4 | 5 | ```go 6 | import ( 7 | "log/syslog" 8 | "github.com/Sirupsen/logrus" 9 | logrus_syslog "github.com/Sirupsen/logrus/hooks/syslog" 10 | ) 11 | 12 | func main() { 13 | log := logrus.New() 14 | hook, err := logrus_syslog.NewSyslogHook("udp", "localhost:514", syslog.LOG_INFO, "") 15 | 16 | if err == nil { 17 | log.Hooks.Add(hook) 18 | } 19 | } 20 | ``` 21 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/hooks/syslog/syslog.go: -------------------------------------------------------------------------------- 1 | package logrus_syslog 2 | 3 | import ( 4 | "fmt" 5 | "github.com/Sirupsen/logrus" 6 | "log/syslog" 7 | "os" 8 | ) 9 | 10 | // SyslogHook to send logs via syslog. 11 | type SyslogHook struct { 12 | Writer *syslog.Writer 13 | SyslogNetwork string 14 | SyslogRaddr string 15 | } 16 | 17 | // Creates a hook to be added to an instance of logger. This is called with 18 | // `hook, err := NewSyslogHook("udp", "localhost:514", syslog.LOG_DEBUG, "")` 19 | // `if err == nil { log.Hooks.Add(hook) }` 20 | func NewSyslogHook(network, raddr string, priority syslog.Priority, tag string) (*SyslogHook, error) { 21 | w, err := syslog.Dial(network, raddr, priority, tag) 22 | return &SyslogHook{w, network, raddr}, err 23 | } 24 | 25 | func (hook *SyslogHook) Fire(entry *logrus.Entry) error { 26 | line, err := entry.String() 27 | if err != nil { 28 | fmt.Fprintf(os.Stderr, "Unable to read entry, %v", err) 29 | return err 30 | } 31 | 32 | switch entry.Level { 33 | case logrus.PanicLevel: 34 | return hook.Writer.Crit(line) 35 | case logrus.FatalLevel: 36 | return hook.Writer.Crit(line) 37 | case logrus.ErrorLevel: 38 | return hook.Writer.Err(line) 39 | case logrus.WarnLevel: 40 | return hook.Writer.Warning(line) 41 | case logrus.InfoLevel: 42 | return hook.Writer.Info(line) 43 | case logrus.DebugLevel: 44 | return hook.Writer.Debug(line) 45 | default: 46 | return nil 47 | } 48 | } 49 | 50 | func (hook *SyslogHook) Levels() []logrus.Level { 51 | return []logrus.Level{ 52 | logrus.PanicLevel, 53 | logrus.FatalLevel, 54 | logrus.ErrorLevel, 55 | logrus.WarnLevel, 56 | logrus.InfoLevel, 57 | logrus.DebugLevel, 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/json_formatter.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | type JSONFormatter struct { 9 | // TimestampFormat sets the format used for marshaling timestamps. 10 | TimestampFormat string 11 | } 12 | 13 | func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) { 14 | data := make(Fields, len(entry.Data)+3) 15 | for k, v := range entry.Data { 16 | switch v := v.(type) { 17 | case error: 18 | // Otherwise errors are ignored by `encoding/json` 19 | // https://github.com/Sirupsen/logrus/issues/137 20 | data[k] = v.Error() 21 | default: 22 | data[k] = v 23 | } 24 | } 25 | prefixFieldClashes(data) 26 | 27 | timestampFormat := f.TimestampFormat 28 | if timestampFormat == "" { 29 | timestampFormat = DefaultTimestampFormat 30 | } 31 | 32 | data["time"] = entry.Time.Format(timestampFormat) 33 | data["msg"] = entry.Message 34 | data["level"] = entry.Level.String() 35 | 36 | serialized, err := json.Marshal(data) 37 | if err != nil { 38 | return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err) 39 | } 40 | return append(serialized, '\n'), nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/logrus.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | ) 7 | 8 | // Fields type, used to pass to `WithFields`. 9 | type Fields map[string]interface{} 10 | 11 | // Level type 12 | type Level uint8 13 | 14 | // Convert the Level to a string. E.g. PanicLevel becomes "panic". 15 | func (level Level) String() string { 16 | switch level { 17 | case DebugLevel: 18 | return "debug" 19 | case InfoLevel: 20 | return "info" 21 | case WarnLevel: 22 | return "warning" 23 | case ErrorLevel: 24 | return "error" 25 | case FatalLevel: 26 | return "fatal" 27 | case PanicLevel: 28 | return "panic" 29 | } 30 | 31 | return "unknown" 32 | } 33 | 34 | // ParseLevel takes a string level and returns the Logrus log level constant. 35 | func ParseLevel(lvl string) (Level, error) { 36 | switch lvl { 37 | case "panic": 38 | return PanicLevel, nil 39 | case "fatal": 40 | return FatalLevel, nil 41 | case "error": 42 | return ErrorLevel, nil 43 | case "warn", "warning": 44 | return WarnLevel, nil 45 | case "info": 46 | return InfoLevel, nil 47 | case "debug": 48 | return DebugLevel, nil 49 | } 50 | 51 | var l Level 52 | return l, fmt.Errorf("not a valid logrus Level: %q", lvl) 53 | } 54 | 55 | // These are the different logging levels. You can set the logging level to log 56 | // on your instance of logger, obtained with `logrus.New()`. 57 | const ( 58 | // PanicLevel level, highest level of severity. Logs and then calls panic with the 59 | // message passed to Debug, Info, ... 60 | PanicLevel Level = iota 61 | // FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the 62 | // logging level is set to Panic. 63 | FatalLevel 64 | // ErrorLevel level. Logs. Used for errors that should definitely be noted. 65 | // Commonly used for hooks to send errors to an error tracking service. 66 | ErrorLevel 67 | // WarnLevel level. Non-critical entries that deserve eyes. 68 | WarnLevel 69 | // InfoLevel level. General operational entries about what's going on inside the 70 | // application. 71 | InfoLevel 72 | // DebugLevel level. Usually only enabled when debugging. Very verbose logging. 73 | DebugLevel 74 | ) 75 | 76 | // Won't compile if StdLogger can't be realized by a log.Logger 77 | var _ StdLogger = &log.Logger{} 78 | 79 | // StdLogger is what your logrus-enabled library should take, that way 80 | // it'll accept a stdlib logger and a logrus logger. There's no standard 81 | // interface, this is the closest we get, unfortunately. 82 | type StdLogger interface { 83 | Print(...interface{}) 84 | Printf(string, ...interface{}) 85 | Println(...interface{}) 86 | 87 | Fatal(...interface{}) 88 | Fatalf(string, ...interface{}) 89 | Fatalln(...interface{}) 90 | 91 | Panic(...interface{}) 92 | Panicf(string, ...interface{}) 93 | Panicln(...interface{}) 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_bsd.go: -------------------------------------------------------------------------------- 1 | // +build darwin freebsd openbsd netbsd dragonfly 2 | 3 | package logrus 4 | 5 | import "syscall" 6 | 7 | const ioctlReadTermios = syscall.TIOCGETA 8 | 9 | type Termios syscall.Termios 10 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_linux.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2013 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | package logrus 7 | 8 | import "syscall" 9 | 10 | const ioctlReadTermios = syscall.TCGETS 11 | 12 | type Termios syscall.Termios 13 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_notwindows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build linux darwin freebsd openbsd netbsd dragonfly 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | // IsTerminal returns true if the given file descriptor is a terminal. 16 | func IsTerminal() bool { 17 | fd := syscall.Stdout 18 | var termios Termios 19 | _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&termios)), 0, 0, 0) 20 | return err == 0 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/terminal_windows.go: -------------------------------------------------------------------------------- 1 | // Based on ssh/terminal: 2 | // Copyright 2011 The Go Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style 4 | // license that can be found in the LICENSE file. 5 | 6 | // +build windows 7 | 8 | package logrus 9 | 10 | import ( 11 | "syscall" 12 | "unsafe" 13 | ) 14 | 15 | var kernel32 = syscall.NewLazyDLL("kernel32.dll") 16 | 17 | var ( 18 | procGetConsoleMode = kernel32.NewProc("GetConsoleMode") 19 | ) 20 | 21 | // IsTerminal returns true if the given file descriptor is a terminal. 22 | func IsTerminal() bool { 23 | fd := syscall.Stdout 24 | var st uint32 25 | r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(fd), uintptr(unsafe.Pointer(&st)), 0) 26 | return r != 0 && e == 0 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/Sirupsen/logrus/writer.go: -------------------------------------------------------------------------------- 1 | package logrus 2 | 3 | import ( 4 | "bufio" 5 | "io" 6 | "runtime" 7 | ) 8 | 9 | func (logger *Logger) Writer() *io.PipeWriter { 10 | reader, writer := io.Pipe() 11 | 12 | go logger.writerScanner(reader) 13 | runtime.SetFinalizer(writer, writerFinalizer) 14 | 15 | return writer 16 | } 17 | 18 | func (logger *Logger) writerScanner(reader *io.PipeReader) { 19 | scanner := bufio.NewScanner(reader) 20 | for scanner.Scan() { 21 | logger.Print(scanner.Text()) 22 | } 23 | if err := scanner.Err(); err != nil { 24 | logger.Errorf("Error while reading from Writer: %s", err) 25 | } 26 | reader.Close() 27 | } 28 | 29 | func writerFinalizer(writer *io.PipeWriter) { 30 | writer.Close() 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Space Monkey, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/README.md: -------------------------------------------------------------------------------- 1 | gls 2 | === 3 | 4 | Goroutine local storage 5 | 6 | ### IMPORTANT NOTE ### 7 | 8 | It is my duty to point you to https://blog.golang.org/context, which is how 9 | Google solves all of the problems you'd perhaps consider using this package 10 | for at scale. 11 | 12 | One downside to Google's approach is that *all* of your functions must have 13 | a new first argument, but after clearing that hurdle everything else is much 14 | better. 15 | 16 | If you aren't interested in this warning, read on. 17 | 18 | ### Huhwaht? Why? ### 19 | 20 | Every so often, a thread shows up on the 21 | [golang-nuts](https://groups.google.com/d/forum/golang-nuts) asking for some 22 | form of goroutine-local-storage, or some kind of goroutine id, or some kind of 23 | context. There are a few valid use cases for goroutine-local-storage, one of 24 | the most prominent being log line context. One poster was interested in being 25 | able to log an HTTP request context id in every log line in the same goroutine 26 | as the incoming HTTP request, without having to change every library and 27 | function call he was interested in logging. 28 | 29 | This would be pretty useful. Provided that you could get some kind of 30 | goroutine-local-storage, you could call 31 | [log.SetOutput](http://golang.org/pkg/log/#SetOutput) with your own logging 32 | writer that checks goroutine-local-storage for some context information and 33 | adds that context to your log lines. 34 | 35 | But alas, Andrew Gerrand's typically diplomatic answer to the question of 36 | goroutine-local variables was: 37 | 38 | > We wouldn't even be having this discussion if thread local storage wasn't 39 | > useful. But every feature comes at a cost, and in my opinion the cost of 40 | > threadlocals far outweighs their benefits. They're just not a good fit for 41 | > Go. 42 | 43 | So, yeah, that makes sense. That's a pretty good reason for why the language 44 | won't support a specific and (relatively) unuseful feature that requires some 45 | runtime changes, just for the sake of a little bit of log improvement. 46 | 47 | But does Go require runtime changes? 48 | 49 | ### How it works ### 50 | 51 | Go has pretty fantastic introspective and reflective features, but one thing Go 52 | doesn't give you is any kind of access to the stack pointer, or frame pointer, 53 | or goroutine id, or anything contextual about your current stack. It gives you 54 | access to your list of callers, but only along with program counters, which are 55 | fixed at compile time. 56 | 57 | But it does give you the stack. 58 | 59 | So, we define 16 special functions and embed base-16 tags into the stack using 60 | the call order of those 16 functions. Then, we can read our tags back out of 61 | the stack looking at the callers list. 62 | 63 | We then use these tags as an index into a traditional map for implementing 64 | this library. 65 | 66 | ### What are people saying? ### 67 | 68 | "Wow, that's horrifying." 69 | 70 | "This is the most terrible thing I have seen in a very long time." 71 | 72 | "Where is it getting a context from? Is this serializing all the requests? 73 | What the heck is the client being bound to? What are these tags? Why does he 74 | need callers? Oh god no. No no no." 75 | 76 | ### Docs ### 77 | 78 | Please see the docs at http://godoc.org/github.com/jtolds/gls 79 | 80 | ### Related ### 81 | 82 | If you're okay relying on the string format of the current runtime stacktrace 83 | including a unique goroutine id (not guaranteed by the spec or anything, but 84 | very unlikely to change within a Go release), you might be able to squeeze 85 | out a bit more performance by using this similar library, inspired by some 86 | code Brad Fitzpatrick wrote for debugging his HTTP/2 library: 87 | https://github.com/tylerb/gls (in contrast, jtolds/gls doesn't require 88 | any knowledge of the string format of the runtime stacktrace, which 89 | probably adds unnecessary overhead). 90 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gen_sym.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | var ( 4 | symPool = &idPool{} 5 | ) 6 | 7 | // ContextKey is a throwaway value you can use as a key to a ContextManager 8 | type ContextKey struct{ id uint } 9 | 10 | // GenSym will return a brand new, never-before-used ContextKey 11 | func GenSym() ContextKey { 12 | return ContextKey{id: symPool.Acquire()} 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/id_pool.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // though this could probably be better at keeping ids smaller, the goal of 4 | // this class is to keep a registry of the smallest unique integer ids 5 | // per-process possible 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | type idPool struct { 12 | mtx sync.Mutex 13 | released []uint 14 | max_id uint 15 | } 16 | 17 | func (p *idPool) Acquire() (id uint) { 18 | p.mtx.Lock() 19 | defer p.mtx.Unlock() 20 | if len(p.released) > 0 { 21 | id = p.released[len(p.released)-1] 22 | p.released = p.released[:len(p.released)-1] 23 | return id 24 | } 25 | id = p.max_id 26 | p.max_id++ 27 | return id 28 | } 29 | 30 | func (p *idPool) Release(id uint) { 31 | p.mtx.Lock() 32 | defer p.mtx.Unlock() 33 | p.released = append(p.released, id) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // so, basically, we're going to encode integer tags in base-16 on the stack 4 | 5 | import ( 6 | "reflect" 7 | "runtime" 8 | ) 9 | 10 | const ( 11 | bitWidth = 4 12 | ) 13 | 14 | func addStackTag(tag uint, context_call func()) { 15 | if context_call == nil { 16 | return 17 | } 18 | markS(tag, context_call) 19 | } 20 | 21 | func markS(tag uint, cb func()) { _m(tag, cb) } 22 | func mark0(tag uint, cb func()) { _m(tag, cb) } 23 | func mark1(tag uint, cb func()) { _m(tag, cb) } 24 | func mark2(tag uint, cb func()) { _m(tag, cb) } 25 | func mark3(tag uint, cb func()) { _m(tag, cb) } 26 | func mark4(tag uint, cb func()) { _m(tag, cb) } 27 | func mark5(tag uint, cb func()) { _m(tag, cb) } 28 | func mark6(tag uint, cb func()) { _m(tag, cb) } 29 | func mark7(tag uint, cb func()) { _m(tag, cb) } 30 | func mark8(tag uint, cb func()) { _m(tag, cb) } 31 | func mark9(tag uint, cb func()) { _m(tag, cb) } 32 | func markA(tag uint, cb func()) { _m(tag, cb) } 33 | func markB(tag uint, cb func()) { _m(tag, cb) } 34 | func markC(tag uint, cb func()) { _m(tag, cb) } 35 | func markD(tag uint, cb func()) { _m(tag, cb) } 36 | func markE(tag uint, cb func()) { _m(tag, cb) } 37 | func markF(tag uint, cb func()) { _m(tag, cb) } 38 | 39 | var pc_lookup = make(map[uintptr]int8, 17) 40 | var mark_lookup [16]func(uint, func()) 41 | 42 | func init() { 43 | setEntries := func(f func(uint, func()), v int8) { 44 | pc_lookup[reflect.ValueOf(f).Pointer()] = v 45 | if v >= 0 { 46 | mark_lookup[v] = f 47 | } 48 | } 49 | setEntries(markS, -0x1) 50 | setEntries(mark0, 0x0) 51 | setEntries(mark1, 0x1) 52 | setEntries(mark2, 0x2) 53 | setEntries(mark3, 0x3) 54 | setEntries(mark4, 0x4) 55 | setEntries(mark5, 0x5) 56 | setEntries(mark6, 0x6) 57 | setEntries(mark7, 0x7) 58 | setEntries(mark8, 0x8) 59 | setEntries(mark9, 0x9) 60 | setEntries(markA, 0xa) 61 | setEntries(markB, 0xb) 62 | setEntries(markC, 0xc) 63 | setEntries(markD, 0xd) 64 | setEntries(markE, 0xe) 65 | setEntries(markF, 0xf) 66 | } 67 | 68 | func _m(tag_remainder uint, cb func()) { 69 | if tag_remainder == 0 { 70 | cb() 71 | } else { 72 | mark_lookup[tag_remainder&0xf](tag_remainder>>bitWidth, cb) 73 | } 74 | } 75 | 76 | func readStackTags(stack []uintptr) (tags []uint) { 77 | var current_tag uint 78 | for _, pc := range stack { 79 | pc = runtime.FuncForPC(pc).Entry() 80 | val, ok := pc_lookup[pc] 81 | if !ok { 82 | continue 83 | } 84 | if val < 0 { 85 | tags = append(tags, current_tag) 86 | current_tag = 0 87 | continue 88 | } 89 | current_tag <<= bitWidth 90 | current_tag += uint(val) 91 | } 92 | return 93 | } 94 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.2 5 | - 1.3 6 | - 1.4 7 | - 1.5 8 | 9 | install: 10 | - go get -t ./... 11 | 12 | script: go test -v 13 | 14 | sudo: false 15 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/assertions.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -coverpkg=github.com/smartystreets/assertions,github.com/smartystreets/assertions/internal/oglematchers -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/filter.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | const ( 6 | success = "" 7 | needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." 8 | needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." 9 | ) 10 | 11 | func need(needed int, expected []interface{}) string { 12 | if len(expected) != needed { 13 | return fmt.Sprintf(needExactValues, needed, len(expected)) 14 | } 15 | return success 16 | } 17 | 18 | func atLeast(minimum int, expected []interface{}) string { 19 | if len(expected) < 1 { 20 | return needNonEmptyCollection 21 | } 22 | return success 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile pulls the latest oglematchers (with dependencies), 2 | # rewrites the imports to match this location, 3 | # and ensures that all the tests pass. 4 | 5 | go: clean clone rewrite test 6 | 7 | clean: 8 | rm -rf ogle* 9 | rm -rf reqtrace 10 | 11 | clone: 12 | git clone https://github.com/jacobsa/ogletest.git && rm -rf ogletest/.git 13 | git clone https://github.com/jacobsa/oglemock.git && rm -rf oglemock/.git 14 | git clone https://github.com/jacobsa/oglematchers.git && rm -rf oglematchers/.git 15 | git clone https://github.com/jacobsa/reqtrace.git && rm -rf reqtrace/.git 16 | 17 | rewrite: 18 | grep -rl --exclude Makefile 'github.com/jacobsa' . | xargs sed -i '' 's#github.com/jacobsa#github.com/smartystreets/assertions/internal#g' 19 | 20 | test: 21 | go test github.com/smartystreets/assertions/... 22 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | 6.out 3 | _obj/ 4 | _test/ 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml: -------------------------------------------------------------------------------- 1 | # Cf. http://docs.travis-ci.com/user/getting-started/ 2 | # Cf. http://docs.travis-ci.com/user/languages/go/ 3 | 4 | language: go 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) 2 | 3 | `oglematchers` is a package for the Go programming language containing a set of 4 | matchers, useful in a testing or mocking framework, inspired by and mostly 5 | compatible with [Google Test][googletest] for C++ and 6 | [Google JS Test][google-js-test]. The package is used by the 7 | [ogletest][ogletest] testing framework and [oglemock][oglemock] mocking 8 | framework, which may be more directly useful to you, but can be generically used 9 | elsewhere as well. 10 | 11 | A "matcher" is simply an object with a `Matches` method defining a set of golang 12 | values matched by the matcher, and a `Description` method describing that set. 13 | For example, here are some matchers: 14 | 15 | ```go 16 | // Numbers 17 | Equals(17.13) 18 | LessThan(19) 19 | 20 | // Strings 21 | Equals("taco") 22 | HasSubstr("burrito") 23 | MatchesRegex("t.*o") 24 | 25 | // Combining matchers 26 | AnyOf(LessThan(17), GreaterThan(19)) 27 | ``` 28 | 29 | There are lots more; see [here][reference] for a reference. You can also add 30 | your own simply by implementing the `oglematchers.Matcher` interface. 31 | 32 | 33 | Installation 34 | ------------ 35 | 36 | First, make sure you have installed Go 1.0.2 or newer. See 37 | [here][golang-install] for instructions. 38 | 39 | Use the following command to install `oglematchers` and keep it up to date: 40 | 41 | go get -u github.com/smartystreets/assertions/internal/oglematchers 42 | 43 | 44 | Documentation 45 | ------------- 46 | 47 | See [here][reference] for documentation. Alternatively, you can install the 48 | package and then use `godoc`: 49 | 50 | godoc github.com/smartystreets/assertions/internal/oglematchers 51 | 52 | 53 | [reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers 54 | [golang-install]: http://golang.org/doc/install.html 55 | [googletest]: http://code.google.com/p/googletest/ 56 | [google-js-test]: http://code.google.com/p/google-js-test/ 57 | [ogletest]: http://github.com/smartystreets/assertions/internal/ogletest 58 | [oglemock]: http://github.com/smartystreets/assertions/internal/oglemock 59 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/all_of.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "strings" 20 | ) 21 | 22 | // AllOf accepts a set of matchers S and returns a matcher that follows the 23 | // algorithm below when considering a candidate c: 24 | // 25 | // 1. Return true if for every Matcher m in S, m matches c. 26 | // 27 | // 2. Otherwise, if there is a matcher m in S such that m returns a fatal 28 | // error for c, return that matcher's error message. 29 | // 30 | // 3. Otherwise, return false with the error from some wrapped matcher. 31 | // 32 | // This is akin to a logical AND operation for matchers. 33 | func AllOf(matchers ...Matcher) Matcher { 34 | return &allOfMatcher{matchers} 35 | } 36 | 37 | type allOfMatcher struct { 38 | wrappedMatchers []Matcher 39 | } 40 | 41 | func (m *allOfMatcher) Description() string { 42 | // Special case: the empty set. 43 | if len(m.wrappedMatchers) == 0 { 44 | return "is anything" 45 | } 46 | 47 | // Join the descriptions for the wrapped matchers. 48 | wrappedDescs := make([]string, len(m.wrappedMatchers)) 49 | for i, wrappedMatcher := range m.wrappedMatchers { 50 | wrappedDescs[i] = wrappedMatcher.Description() 51 | } 52 | 53 | return strings.Join(wrappedDescs, ", and ") 54 | } 55 | 56 | func (m *allOfMatcher) Matches(c interface{}) (err error) { 57 | for _, wrappedMatcher := range m.wrappedMatchers { 58 | if wrappedErr := wrappedMatcher.Matches(c); wrappedErr != nil { 59 | err = wrappedErr 60 | 61 | // If the error is fatal, return immediately with this error. 62 | _, ok := wrappedErr.(*FatalError) 63 | if ok { 64 | return 65 | } 66 | } 67 | } 68 | 69 | return 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/any.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // Any returns a matcher that matches any value. 19 | func Any() Matcher { 20 | return &anyMatcher{} 21 | } 22 | 23 | type anyMatcher struct { 24 | } 25 | 26 | func (m *anyMatcher) Description() string { 27 | return "is anything" 28 | } 29 | 30 | func (m *anyMatcher) Matches(c interface{}) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/any_of.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // AnyOf accepts a set of values S and returns a matcher that follows the 26 | // algorithm below when considering a candidate c: 27 | // 28 | // 1. If there exists a value m in S such that m implements the Matcher 29 | // interface and m matches c, return true. 30 | // 31 | // 2. Otherwise, if there exists a value v in S such that v does not implement 32 | // the Matcher interface and the matcher Equals(v) matches c, return true. 33 | // 34 | // 3. Otherwise, if there is a value m in S such that m implements the Matcher 35 | // interface and m returns a fatal error for c, return that fatal error. 36 | // 37 | // 4. Otherwise, return false. 38 | // 39 | // This is akin to a logical OR operation for matchers, with non-matchers x 40 | // being treated as Equals(x). 41 | func AnyOf(vals ...interface{}) Matcher { 42 | // Get ahold of a type variable for the Matcher interface. 43 | var dummy *Matcher 44 | matcherType := reflect.TypeOf(dummy).Elem() 45 | 46 | // Create a matcher for each value, or use the value itself if it's already a 47 | // matcher. 48 | wrapped := make([]Matcher, len(vals)) 49 | for i, v := range vals { 50 | t := reflect.TypeOf(v) 51 | if t != nil && t.Implements(matcherType) { 52 | wrapped[i] = v.(Matcher) 53 | } else { 54 | wrapped[i] = Equals(v) 55 | } 56 | } 57 | 58 | return &anyOfMatcher{wrapped} 59 | } 60 | 61 | type anyOfMatcher struct { 62 | wrapped []Matcher 63 | } 64 | 65 | func (m *anyOfMatcher) Description() string { 66 | wrappedDescs := make([]string, len(m.wrapped)) 67 | for i, matcher := range m.wrapped { 68 | wrappedDescs[i] = matcher.Description() 69 | } 70 | 71 | return fmt.Sprintf("or(%s)", strings.Join(wrappedDescs, ", ")) 72 | } 73 | 74 | func (m *anyOfMatcher) Matches(c interface{}) (err error) { 75 | err = errors.New("") 76 | 77 | // Try each matcher in turn. 78 | for _, matcher := range m.wrapped { 79 | wrappedErr := matcher.Matches(c) 80 | 81 | // Return immediately if there's a match. 82 | if wrappedErr == nil { 83 | err = nil 84 | return 85 | } 86 | 87 | // Note the fatal error, if any. 88 | if _, isFatal := wrappedErr.(*FatalError); isFatal { 89 | err = wrappedErr 90 | } 91 | } 92 | 93 | return 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // Return a matcher that matches arrays slices with at least one element that 24 | // matches the supplied argument. If the argument x is not itself a Matcher, 25 | // this is equivalent to Contains(Equals(x)). 26 | func Contains(x interface{}) Matcher { 27 | var result containsMatcher 28 | var ok bool 29 | 30 | if result.elementMatcher, ok = x.(Matcher); !ok { 31 | result.elementMatcher = Equals(x) 32 | } 33 | 34 | return &result 35 | } 36 | 37 | type containsMatcher struct { 38 | elementMatcher Matcher 39 | } 40 | 41 | func (m *containsMatcher) Description() string { 42 | return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) 43 | } 44 | 45 | func (m *containsMatcher) Matches(candidate interface{}) error { 46 | // The candidate must be a slice or an array. 47 | v := reflect.ValueOf(candidate) 48 | if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { 49 | return NewFatalError("which is not a slice or array") 50 | } 51 | 52 | // Check each element. 53 | for i := 0; i < v.Len(); i++ { 54 | elem := v.Index(i) 55 | if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { 56 | return nil 57 | } 58 | } 59 | 60 | return fmt.Errorf("") 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/deep_equals.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "bytes" 20 | "errors" 21 | "fmt" 22 | "reflect" 23 | ) 24 | 25 | var byteSliceType reflect.Type = reflect.TypeOf([]byte{}) 26 | 27 | // DeepEquals returns a matcher that matches based on 'deep equality', as 28 | // defined by the reflect package. This matcher requires that values have 29 | // identical types to x. 30 | func DeepEquals(x interface{}) Matcher { 31 | return &deepEqualsMatcher{x} 32 | } 33 | 34 | type deepEqualsMatcher struct { 35 | x interface{} 36 | } 37 | 38 | func (m *deepEqualsMatcher) Description() string { 39 | xDesc := fmt.Sprintf("%v", m.x) 40 | xValue := reflect.ValueOf(m.x) 41 | 42 | // Special case: fmt.Sprintf presents nil slices as "[]", but 43 | // reflect.DeepEqual makes a distinction between nil and empty slices. Make 44 | // this less confusing. 45 | if xValue.Kind() == reflect.Slice && xValue.IsNil() { 46 | xDesc = "" 47 | } 48 | 49 | return fmt.Sprintf("deep equals: %s", xDesc) 50 | } 51 | 52 | func (m *deepEqualsMatcher) Matches(c interface{}) error { 53 | // Make sure the types match. 54 | ct := reflect.TypeOf(c) 55 | xt := reflect.TypeOf(m.x) 56 | 57 | if ct != xt { 58 | return NewFatalError(fmt.Sprintf("which is of type %v", ct)) 59 | } 60 | 61 | // Special case: handle byte slices more efficiently. 62 | cValue := reflect.ValueOf(c) 63 | xValue := reflect.ValueOf(m.x) 64 | 65 | if ct == byteSliceType && !cValue.IsNil() && !xValue.IsNil() { 66 | xBytes := m.x.([]byte) 67 | cBytes := c.([]byte) 68 | 69 | if bytes.Equal(cBytes, xBytes) { 70 | return nil 71 | } 72 | 73 | return errors.New("") 74 | } 75 | 76 | // Defer to the reflect package. 77 | if reflect.DeepEqual(m.x, c) { 78 | return nil 79 | } 80 | 81 | // Special case: if the comparison failed because c is the nil slice, given 82 | // an indication of this (since its value is printed as "[]"). 83 | if cValue.Kind() == reflect.Slice && cValue.IsNil() { 84 | return errors.New("which is nil") 85 | } 86 | 87 | return errors.New("") 88 | } 89 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/elements_are.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // Given a list of arguments M, ElementsAre returns a matcher that matches 26 | // arrays and slices A where all of the following hold: 27 | // 28 | // * A is the same length as M. 29 | // 30 | // * For each i < len(A) where M[i] is a matcher, A[i] matches M[i]. 31 | // 32 | // * For each i < len(A) where M[i] is not a matcher, A[i] matches 33 | // Equals(M[i]). 34 | // 35 | func ElementsAre(M ...interface{}) Matcher { 36 | // Copy over matchers, or convert to Equals(x) for non-matcher x. 37 | subMatchers := make([]Matcher, len(M)) 38 | for i, x := range M { 39 | if matcher, ok := x.(Matcher); ok { 40 | subMatchers[i] = matcher 41 | continue 42 | } 43 | 44 | subMatchers[i] = Equals(x) 45 | } 46 | 47 | return &elementsAreMatcher{subMatchers} 48 | } 49 | 50 | type elementsAreMatcher struct { 51 | subMatchers []Matcher 52 | } 53 | 54 | func (m *elementsAreMatcher) Description() string { 55 | subDescs := make([]string, len(m.subMatchers)) 56 | for i, sm := range m.subMatchers { 57 | subDescs[i] = sm.Description() 58 | } 59 | 60 | return fmt.Sprintf("elements are: [%s]", strings.Join(subDescs, ", ")) 61 | } 62 | 63 | func (m *elementsAreMatcher) Matches(candidates interface{}) error { 64 | // The candidate must be a slice or an array. 65 | v := reflect.ValueOf(candidates) 66 | if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { 67 | return NewFatalError("which is not a slice or array") 68 | } 69 | 70 | // The length must be correct. 71 | if v.Len() != len(m.subMatchers) { 72 | return errors.New(fmt.Sprintf("which is of length %d", v.Len())) 73 | } 74 | 75 | // Check each element. 76 | for i, subMatcher := range m.subMatchers { 77 | c := v.Index(i) 78 | if matchErr := subMatcher.Matches(c.Interface()); matchErr != nil { 79 | // Return an errors indicating which element doesn't match. If the 80 | // matcher error was fatal, make this one fatal too. 81 | err := errors.New(fmt.Sprintf("whose element %d doesn't match", i)) 82 | if _, isFatal := matchErr.(*FatalError); isFatal { 83 | err = NewFatalError(err.Error()) 84 | } 85 | 86 | return err 87 | } 88 | } 89 | 90 | return nil 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/error.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // Error returns a matcher that matches non-nil values implementing the 19 | // built-in error interface for whom the return value of Error() matches the 20 | // supplied matcher. 21 | // 22 | // For example: 23 | // 24 | // err := errors.New("taco burrito") 25 | // 26 | // Error(Equals("taco burrito")) // matches err 27 | // Error(HasSubstr("taco")) // matches err 28 | // Error(HasSubstr("enchilada")) // doesn't match err 29 | // 30 | func Error(m Matcher) Matcher { 31 | return &errorMatcher{m} 32 | } 33 | 34 | type errorMatcher struct { 35 | wrappedMatcher Matcher 36 | } 37 | 38 | func (m *errorMatcher) Description() string { 39 | return "error " + m.wrappedMatcher.Description() 40 | } 41 | 42 | func (m *errorMatcher) Matches(c interface{}) error { 43 | // Make sure that c is an error. 44 | e, ok := c.(error) 45 | if !ok { 46 | return NewFatalError("which is not an error") 47 | } 48 | 49 | // Pass on the error text to the wrapped matcher. 50 | return m.wrappedMatcher.Matches(e.Error()) 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v >= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterOrEqual will panic. 30 | func GreaterOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than or equal to \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessThan(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterThan returns a matcher that matches integer, floating point, or 24 | // strings values v such that v > x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterThan will panic. 30 | func GreaterThan(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessOrEqual(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/has_same_type_as.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // HasSameTypeAs returns a matcher that matches values with exactly the same 24 | // type as the supplied prototype. 25 | func HasSameTypeAs(p interface{}) Matcher { 26 | expected := reflect.TypeOf(p) 27 | pred := func(c interface{}) error { 28 | actual := reflect.TypeOf(c) 29 | if actual != expected { 30 | return fmt.Errorf("which has type %v", actual) 31 | } 32 | 33 | return nil 34 | } 35 | 36 | return NewMatcher(pred, fmt.Sprintf("has type %v", expected)) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/has_substr.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "strings" 23 | ) 24 | 25 | // HasSubstr returns a matcher that matches strings containing s as a 26 | // substring. 27 | func HasSubstr(s string) Matcher { 28 | return NewMatcher( 29 | func(c interface{}) error { return hasSubstr(s, c) }, 30 | fmt.Sprintf("has substring \"%s\"", s)) 31 | } 32 | 33 | func hasSubstr(needle string, c interface{}) error { 34 | v := reflect.ValueOf(c) 35 | if v.Kind() != reflect.String { 36 | return NewFatalError("which is not a string") 37 | } 38 | 39 | // Perform the substring search. 40 | haystack := v.String() 41 | if strings.Contains(haystack, needle) { 42 | return nil 43 | } 44 | 45 | return errors.New("") 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // LessOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v <= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // LessOrEqual will panic. 30 | func LessOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("less than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("less than or equal to \"%s\"", x) 36 | } 37 | 38 | // Put LessThan last so that its error messages will be used in the event of 39 | // failure. 40 | return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/matcher.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package oglematchers provides a set of matchers useful in a testing or 17 | // mocking framework. These matchers are inspired by and mostly compatible with 18 | // Google Test for C++ and Google JS Test. 19 | // 20 | // This package is used by github.com/smartystreets/assertions/internal/ogletest and 21 | // github.com/smartystreets/assertions/internal/oglemock, which may be more directly useful if you're not 22 | // writing your own testing package or defining your own matchers. 23 | package oglematchers 24 | 25 | // A Matcher is some predicate implicitly defining a set of values that it 26 | // matches. For example, GreaterThan(17) matches all numeric values greater 27 | // than 17, and HasSubstr("taco") matches all strings with the substring 28 | // "taco". 29 | // 30 | // Matchers are typically exposed to tests via constructor functions like 31 | // HasSubstr. In order to implement such a function you can either define your 32 | // own matcher type or use NewMatcher. 33 | type Matcher interface { 34 | // Check whether the supplied value belongs to the the set defined by the 35 | // matcher. Return a non-nil error if and only if it does not. 36 | // 37 | // The error describes why the value doesn't match. The error text is a 38 | // relative clause that is suitable for being placed after the value. For 39 | // example, a predicate that matches strings with a particular substring may, 40 | // when presented with a numerical value, return the following error text: 41 | // 42 | // "which is not a string" 43 | // 44 | // Then the failure message may look like: 45 | // 46 | // Expected: has substring "taco" 47 | // Actual: 17, which is not a string 48 | // 49 | // If the error is self-apparent based on the description of the matcher, the 50 | // error text may be empty (but the error still non-nil). For example: 51 | // 52 | // Expected: 17 53 | // Actual: 19 54 | // 55 | // If you are implementing a new matcher, see also the documentation on 56 | // FatalError. 57 | Matches(candidate interface{}) error 58 | 59 | // Description returns a string describing the property that values matching 60 | // this matcher have, as a verb phrase where the subject is the value. For 61 | // example, "is greather than 17" or "has substring "taco"". 62 | Description() string 63 | } 64 | 65 | // FatalError is an implementation of the error interface that may be returned 66 | // from matchers, indicating the error should be propagated. Returning a 67 | // *FatalError indicates that the matcher doesn't process values of the 68 | // supplied type, or otherwise doesn't know how to handle the value. 69 | // 70 | // For example, if GreaterThan(17) returned false for the value "taco" without 71 | // a fatal error, then Not(GreaterThan(17)) would return true. This is 72 | // technically correct, but is surprising and may mask failures where the wrong 73 | // sort of matcher is accidentally used. Instead, GreaterThan(17) can return a 74 | // fatal error, which will be propagated by Not(). 75 | type FatalError struct { 76 | errorText string 77 | } 78 | 79 | // NewFatalError creates a FatalError struct with the supplied error text. 80 | func NewFatalError(s string) *FatalError { 81 | return &FatalError{s} 82 | } 83 | 84 | func (e *FatalError) Error() string { 85 | return e.errorText 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/matches_regexp.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | "regexp" 23 | ) 24 | 25 | // MatchesRegexp returns a matcher that matches strings and byte slices whose 26 | // contents match the supplied regular expression. The semantics are those of 27 | // regexp.Match. In particular, that means the match is not implicitly anchored 28 | // to the ends of the string: MatchesRegexp("bar") will match "foo bar baz". 29 | func MatchesRegexp(pattern string) Matcher { 30 | re, err := regexp.Compile(pattern) 31 | if err != nil { 32 | panic("MatchesRegexp: " + err.Error()) 33 | } 34 | 35 | return &matchesRegexpMatcher{re} 36 | } 37 | 38 | type matchesRegexpMatcher struct { 39 | re *regexp.Regexp 40 | } 41 | 42 | func (m *matchesRegexpMatcher) Description() string { 43 | return fmt.Sprintf("matches regexp \"%s\"", m.re.String()) 44 | } 45 | 46 | func (m *matchesRegexpMatcher) Matches(c interface{}) (err error) { 47 | v := reflect.ValueOf(c) 48 | isString := v.Kind() == reflect.String 49 | isByteSlice := v.Kind() == reflect.Slice && v.Elem().Kind() == reflect.Uint8 50 | 51 | err = errors.New("") 52 | 53 | switch { 54 | case isString: 55 | if m.re.MatchString(v.String()) { 56 | err = nil 57 | } 58 | 59 | case isByteSlice: 60 | if m.re.Match(v.Bytes()) { 61 | err = nil 62 | } 63 | 64 | default: 65 | err = NewFatalError("which is not a string or []byte") 66 | } 67 | 68 | return 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/new_matcher.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // Create a matcher with the given description and predicate function, which 19 | // will be invoked to handle calls to Matchers. 20 | // 21 | // Using this constructor may be a convenience over defining your own type that 22 | // implements Matcher if you do not need any logic in your Description method. 23 | func NewMatcher( 24 | predicate func(interface{}) error, 25 | description string) Matcher { 26 | return &predicateMatcher{ 27 | predicate: predicate, 28 | description: description, 29 | } 30 | } 31 | 32 | type predicateMatcher struct { 33 | predicate func(interface{}) error 34 | description string 35 | } 36 | 37 | func (pm *predicateMatcher) Matches(c interface{}) error { 38 | return pm.predicate(c) 39 | } 40 | 41 | func (pm *predicateMatcher) Description() string { 42 | return pm.description 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | ) 22 | 23 | // Not returns a matcher that inverts the set of values matched by the wrapped 24 | // matcher. It does not transform the result for values for which the wrapped 25 | // matcher returns a fatal error. 26 | func Not(m Matcher) Matcher { 27 | return ¬Matcher{m} 28 | } 29 | 30 | type notMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *notMatcher) Matches(c interface{}) (err error) { 35 | err = m.wrapped.Matches(c) 36 | 37 | // Did the wrapped matcher say yes? 38 | if err == nil { 39 | return errors.New("") 40 | } 41 | 42 | // Did the wrapped matcher return a fatal error? 43 | if _, isFatal := err.(*FatalError); isFatal { 44 | return err 45 | } 46 | 47 | // The wrapped matcher returned a non-fatal error. 48 | return nil 49 | } 50 | 51 | func (m *notMatcher) Description() string { 52 | return fmt.Sprintf("not(%s)", m.wrapped.Description()) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/panics.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | ) 23 | 24 | // Panics matches zero-arg functions which, when invoked, panic with an error 25 | // that matches the supplied matcher. 26 | // 27 | // NOTE(jacobsa): This matcher cannot detect the case where the function panics 28 | // using panic(nil), by design of the language. See here for more info: 29 | // 30 | // http://goo.gl/9aIQL 31 | // 32 | func Panics(m Matcher) Matcher { 33 | return &panicsMatcher{m} 34 | } 35 | 36 | type panicsMatcher struct { 37 | wrappedMatcher Matcher 38 | } 39 | 40 | func (m *panicsMatcher) Description() string { 41 | return "panics with: " + m.wrappedMatcher.Description() 42 | } 43 | 44 | func (m *panicsMatcher) Matches(c interface{}) (err error) { 45 | // Make sure c is a zero-arg function. 46 | v := reflect.ValueOf(c) 47 | if v.Kind() != reflect.Func || v.Type().NumIn() != 0 { 48 | err = NewFatalError("which is not a zero-arg function") 49 | return 50 | } 51 | 52 | // Call the function and check its panic error. 53 | defer func() { 54 | if e := recover(); e != nil { 55 | err = m.wrappedMatcher.Matches(e) 56 | 57 | // Set a clearer error message if the matcher said no. 58 | if err != nil { 59 | wrappedClause := "" 60 | if err.Error() != "" { 61 | wrappedClause = ", " + err.Error() 62 | } 63 | 64 | err = errors.New(fmt.Sprintf("which panicked with: %v%s", e, wrappedClause)) 65 | } 66 | } 67 | }() 68 | 69 | v.Call([]reflect.Value{}) 70 | 71 | // If we get here, the function didn't panic. 72 | err = errors.New("which didn't panic") 73 | return 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/pointee.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | ) 23 | 24 | // Return a matcher that matches non-nil pointers whose pointee matches the 25 | // wrapped matcher. 26 | func Pointee(m Matcher) Matcher { 27 | return &pointeeMatcher{m} 28 | } 29 | 30 | type pointeeMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *pointeeMatcher) Matches(c interface{}) (err error) { 35 | // Make sure the candidate is of the appropriate type. 36 | cv := reflect.ValueOf(c) 37 | if !cv.IsValid() || cv.Kind() != reflect.Ptr { 38 | return NewFatalError("which is not a pointer") 39 | } 40 | 41 | // Make sure the candidate is non-nil. 42 | if cv.IsNil() { 43 | return NewFatalError("") 44 | } 45 | 46 | // Defer to the wrapped matcher. Fix up empty errors so that failure messages 47 | // are more helpful than just printing a pointer for "Actual". 48 | pointee := cv.Elem().Interface() 49 | err = m.wrapped.Matches(pointee) 50 | if err != nil && err.Error() == "" { 51 | s := fmt.Sprintf("whose pointee is %v", pointee) 52 | 53 | if _, ok := err.(*FatalError); ok { 54 | err = NewFatalError(s) 55 | } else { 56 | err = errors.New(s) 57 | } 58 | } 59 | 60 | return err 61 | } 62 | 63 | func (m *pointeeMatcher) Description() string { 64 | return fmt.Sprintf("pointee(%s)", m.wrapped.Description()) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // transformDescription returns a matcher that is equivalent to the supplied 19 | // one, except that it has the supplied description instead of the one attached 20 | // to the existing matcher. 21 | func transformDescription(m Matcher, newDesc string) Matcher { 22 | return &transformDescriptionMatcher{newDesc, m} 23 | } 24 | 25 | type transformDescriptionMatcher struct { 26 | desc string 27 | wrappedMatcher Matcher 28 | } 29 | 30 | func (m *transformDescriptionMatcher) Description() string { 31 | return m.desc 32 | } 33 | 34 | func (m *transformDescriptionMatcher) Matches(c interface{}) error { 35 | return m.wrappedMatcher.Matches(c) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | 6.out 3 | _obj/ 4 | _test/ 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/.travis.yml: -------------------------------------------------------------------------------- 1 | # Cf. http://docs.travis-ci.com/user/getting-started/ 2 | # Cf. http://docs.travis-ci.com/user/languages/go/ 3 | 4 | language: go 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/action.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | import ( 19 | "reflect" 20 | ) 21 | 22 | // Action represents an action to be taken in response to a call to a mock 23 | // method. 24 | type Action interface { 25 | // Set the signature of the function with which this action is being used. 26 | // This must be called before Invoke is called. 27 | SetSignature(signature reflect.Type) error 28 | 29 | // Invoke runs the specified action, given the arguments to the mock method. 30 | // It returns zero or more values that may be treated as the return values of 31 | // the method. If the action doesn't return any values, it may return the nil 32 | // slice. 33 | // 34 | // You must call SetSignature before calling Invoke. 35 | Invoke(methodArgs []interface{}) []interface{} 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_interfaces: -------------------------------------------------------------------------------- 1 | Usage: createmock [package] [interface ...] 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.no_package: -------------------------------------------------------------------------------- 1 | Usage: createmock [package] [interface ...] 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_interface: -------------------------------------------------------------------------------- 1 | Unknown interface: Frobnicator 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/createmock/test_cases/golden.unknown_package: -------------------------------------------------------------------------------- 1 | Unknown package: foo/bar 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/do_all.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // Create an Action that invokes the supplied actions one after another. The 24 | // return values from the final action are used; others are ignored. 25 | func DoAll(first Action, others ...Action) Action { 26 | return &doAll{ 27 | wrapped: append([]Action{first}, others...), 28 | } 29 | } 30 | 31 | type doAll struct { 32 | wrapped []Action 33 | } 34 | 35 | func (a *doAll) SetSignature(signature reflect.Type) (err error) { 36 | for i, w := range a.wrapped { 37 | err = w.SetSignature(signature) 38 | if err != nil { 39 | err = fmt.Errorf("Action %v: %v", i, err) 40 | return 41 | } 42 | } 43 | 44 | return 45 | } 46 | 47 | func (a *doAll) Invoke(methodArgs []interface{}) (rets []interface{}) { 48 | for _, w := range a.wrapped { 49 | rets = w.Invoke(methodArgs) 50 | } 51 | 52 | return 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/error_reporter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | // ErrorReporter is an interface that wraps methods for reporting errors that 19 | // should cause test failures. 20 | type ErrorReporter interface { 21 | // Report that some failure (e.g. an unsatisfied expectation) occurred. If 22 | // known, fileName and lineNumber should contain information about where it 23 | // occurred. The test may continue if the test framework supports it. 24 | ReportError(fileName string, lineNumber int, err error) 25 | 26 | // Like ReportError, but the test should be halted immediately. It is assumed 27 | // that this method does not return. 28 | ReportFatalError(fileName string, lineNumber int, err error) 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/expectation.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | // Expectation is an expectation for zero or more calls to a mock method with 19 | // particular arguments or sets of arguments. 20 | type Expectation interface { 21 | // Times expresses that a matching method call should happen exactly N times. 22 | // Times must not be called more than once, and must not be called after 23 | // WillOnce or WillRepeatedly. 24 | // 25 | // The full rules for the cardinality of an expectation are as follows: 26 | // 27 | // 1. If an explicit cardinality is set with Times(N), then anything other 28 | // than exactly N matching calls will cause a test failure. 29 | // 30 | // 2. Otherwise, if there are any one-time actions set up, then it is 31 | // expected there will be at least that many matching calls. If there is 32 | // not also a fallback action, then it is expected that there will be 33 | // exactly that many. 34 | // 35 | // 3. Otherwise, if there is a fallback action configured, any number of 36 | // matching calls (including zero) is allowed. 37 | // 38 | // 4. Otherwise, the implicit cardinality is one. 39 | // 40 | Times(n uint) Expectation 41 | 42 | // WillOnce configures a "one-time action". WillOnce can be called zero or 43 | // more times, but must be called after any call to Times and before any call 44 | // to WillRepeatedly. 45 | // 46 | // When matching method calls are made on the mock object, one-time actions 47 | // are invoked one per matching call in the order that they were set up until 48 | // they are exhausted. Afterward the fallback action, if any, will be used. 49 | WillOnce(a Action) Expectation 50 | 51 | // WillRepeatedly configures a "fallback action". WillRepeatedly can be 52 | // called zero or one times, and must not be called before Times or WillOnce. 53 | // 54 | // Once all one-time actions are exhausted (see above), the fallback action 55 | // will be invoked for any further method calls. If WillRepeatedly is not 56 | // called, the fallback action is implicitly an action that returns zero 57 | // values for the method's return values. 58 | WillRepeatedly(a Action) Expectation 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/complicated_pkg/complicated_pkg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package complicated_pkg contains an interface with lots of interesting 17 | // cases, for use in integration testing. 18 | package complicated_pkg 19 | 20 | import ( 21 | "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" 22 | "image" 23 | "io" 24 | "net" 25 | ) 26 | 27 | type Byte uint8 28 | 29 | type ComplicatedThing interface { 30 | Channels(a chan chan<- <-chan net.Conn) chan int 31 | Pointers(a *int, b *net.Conn, c **io.Reader) (*int, error) 32 | Functions(a func(int, image.Image) int) func(string, int) net.Conn 33 | Maps(a map[string]*int) (map[int]*string, error) 34 | Arrays(a [3]string) ([3]int, error) 35 | Slices(a []string) ([]int, error) 36 | NamedScalarType(a Byte) ([]Byte, error) 37 | EmptyInterface(a interface{}) (interface{}, error) 38 | RenamedPackage(a tony.SomeUint8Alias) 39 | Variadic(a int, b ...net.Conn) int 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.io_reader_writer.go: -------------------------------------------------------------------------------- 1 | // This file was auto-generated using createmock. See the following page for 2 | // more information: 3 | // 4 | // https://github.com/smartystreets/assertions/internal/oglemock 5 | // 6 | 7 | package some_pkg 8 | 9 | import ( 10 | fmt "fmt" 11 | oglemock "github.com/smartystreets/assertions/internal/oglemock" 12 | io "io" 13 | runtime "runtime" 14 | unsafe "unsafe" 15 | ) 16 | 17 | type MockReader interface { 18 | io.Reader 19 | oglemock.MockObject 20 | } 21 | 22 | type mockReader struct { 23 | controller oglemock.Controller 24 | description string 25 | } 26 | 27 | func NewMockReader( 28 | c oglemock.Controller, 29 | desc string) MockReader { 30 | return &mockReader{ 31 | controller: c, 32 | description: desc, 33 | } 34 | } 35 | 36 | func (m *mockReader) Oglemock_Id() uintptr { 37 | return uintptr(unsafe.Pointer(m)) 38 | } 39 | 40 | func (m *mockReader) Oglemock_Description() string { 41 | return m.description 42 | } 43 | 44 | func (m *mockReader) Read(p0 []uint8) (o0 int, o1 error) { 45 | // Get a file name and line number for the caller. 46 | _, file, line, _ := runtime.Caller(1) 47 | 48 | // Hand the call off to the controller, which does most of the work. 49 | retVals := m.controller.HandleMethodCall( 50 | m, 51 | "Read", 52 | file, 53 | line, 54 | []interface{}{p0}) 55 | 56 | if len(retVals) != 2 { 57 | panic(fmt.Sprintf("mockReader.Read: invalid return values: %v", retVals)) 58 | } 59 | 60 | // o0 int 61 | if retVals[0] != nil { 62 | o0 = retVals[0].(int) 63 | } 64 | 65 | // o1 error 66 | if retVals[1] != nil { 67 | o1 = retVals[1].(error) 68 | } 69 | 70 | return 71 | } 72 | 73 | type MockWriter interface { 74 | io.Writer 75 | oglemock.MockObject 76 | } 77 | 78 | type mockWriter struct { 79 | controller oglemock.Controller 80 | description string 81 | } 82 | 83 | func NewMockWriter( 84 | c oglemock.Controller, 85 | desc string) MockWriter { 86 | return &mockWriter{ 87 | controller: c, 88 | description: desc, 89 | } 90 | } 91 | 92 | func (m *mockWriter) Oglemock_Id() uintptr { 93 | return uintptr(unsafe.Pointer(m)) 94 | } 95 | 96 | func (m *mockWriter) Oglemock_Description() string { 97 | return m.description 98 | } 99 | 100 | func (m *mockWriter) Write(p0 []uint8) (o0 int, o1 error) { 101 | // Get a file name and line number for the caller. 102 | _, file, line, _ := runtime.Caller(1) 103 | 104 | // Hand the call off to the controller, which does most of the work. 105 | retVals := m.controller.HandleMethodCall( 106 | m, 107 | "Write", 108 | file, 109 | line, 110 | []interface{}{p0}) 111 | 112 | if len(retVals) != 2 { 113 | panic(fmt.Sprintf("mockWriter.Write: invalid return values: %v", retVals)) 114 | } 115 | 116 | // o0 int 117 | if retVals[0] != nil { 118 | o0 = retVals[0].(int) 119 | } 120 | 121 | // o1 error 122 | if retVals[1] != nil { 123 | o1 = retVals[1].(error) 124 | } 125 | 126 | return 127 | } 128 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/golden.renamed_pkg.go: -------------------------------------------------------------------------------- 1 | // This file was auto-generated using createmock. See the following page for 2 | // more information: 3 | // 4 | // https://github.com/smartystreets/assertions/internal/oglemock 5 | // 6 | 7 | package some_pkg 8 | 9 | import ( 10 | fmt "fmt" 11 | oglemock "github.com/smartystreets/assertions/internal/oglemock" 12 | tony "github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg" 13 | runtime "runtime" 14 | unsafe "unsafe" 15 | ) 16 | 17 | type MockSomeInterface interface { 18 | tony.SomeInterface 19 | oglemock.MockObject 20 | } 21 | 22 | type mockSomeInterface struct { 23 | controller oglemock.Controller 24 | description string 25 | } 26 | 27 | func NewMockSomeInterface( 28 | c oglemock.Controller, 29 | desc string) MockSomeInterface { 30 | return &mockSomeInterface{ 31 | controller: c, 32 | description: desc, 33 | } 34 | } 35 | 36 | func (m *mockSomeInterface) Oglemock_Id() uintptr { 37 | return uintptr(unsafe.Pointer(m)) 38 | } 39 | 40 | func (m *mockSomeInterface) Oglemock_Description() string { 41 | return m.description 42 | } 43 | 44 | func (m *mockSomeInterface) DoFoo(p0 int) (o0 int) { 45 | // Get a file name and line number for the caller. 46 | _, file, line, _ := runtime.Caller(1) 47 | 48 | // Hand the call off to the controller, which does most of the work. 49 | retVals := m.controller.HandleMethodCall( 50 | m, 51 | "DoFoo", 52 | file, 53 | line, 54 | []interface{}{p0}) 55 | 56 | if len(retVals) != 1 { 57 | panic(fmt.Sprintf("mockSomeInterface.DoFoo: invalid return values: %v", retVals)) 58 | } 59 | 60 | // o0 int 61 | if retVals[0] != nil { 62 | o0 = retVals[0].(int) 63 | } 64 | 65 | return 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/generate/test_cases/renamed_pkg/renamed_pkg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // A package that calls itself something different than its package path would 17 | // have you believe. 18 | package tony 19 | 20 | type SomeUint8Alias uint8 21 | 22 | type SomeInterface interface { 23 | DoFoo(a int) int 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/invoke.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | "reflect" 22 | ) 23 | 24 | // Create an Action that invokes the supplied function, returning whatever it 25 | // returns. The signature of the function must match that of the mocked method 26 | // exactly. 27 | func Invoke(f interface{}) Action { 28 | // Make sure f is a function. 29 | fv := reflect.ValueOf(f) 30 | fk := fv.Kind() 31 | 32 | if fk != reflect.Func { 33 | desc := "" 34 | if fk != reflect.Invalid { 35 | desc = fv.Type().String() 36 | } 37 | 38 | panic(fmt.Sprintf("Invoke: expected function, got %s", desc)) 39 | } 40 | 41 | return &invokeAction{fv} 42 | } 43 | 44 | type invokeAction struct { 45 | f reflect.Value 46 | } 47 | 48 | func (a *invokeAction) SetSignature(signature reflect.Type) error { 49 | // The signature must match exactly. 50 | ft := a.f.Type() 51 | if ft != signature { 52 | return errors.New(fmt.Sprintf("Invoke: expected %v, got %v", signature, ft)) 53 | } 54 | 55 | return nil 56 | } 57 | 58 | func (a *invokeAction) Invoke(vals []interface{}) []interface{} { 59 | // Create a slice of args for the function. 60 | in := make([]reflect.Value, len(vals)) 61 | for i, x := range vals { 62 | in[i] = reflect.ValueOf(x) 63 | } 64 | 65 | // Call the function and return its return values. 66 | out := a.f.Call(in) 67 | result := make([]interface{}, len(out)) 68 | for i, v := range out { 69 | result[i] = v.Interface() 70 | } 71 | 72 | return result 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/mock_object.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | // MockObject is an interface that mock object implementations must conform to 19 | // in order to register expectations with and hand off calls to a 20 | // MockController. Users should not interact with this interface directly. 21 | type MockObject interface { 22 | // Oglemock_Id returns an identifier for the mock object that is guaranteed 23 | // to be unique within the process at least until the mock object is garbage 24 | // collected. 25 | Oglemock_Id() uintptr 26 | 27 | // Oglemock_Description returns a description of the mock object that may be 28 | // helpful in test failure messages. 29 | Oglemock_Description() string 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/sample/README.markdown: -------------------------------------------------------------------------------- 1 | This directory contains sample code generated with the `createmock` command. For 2 | example, the file `mock_io.go` can be regenerated with: 3 | 4 | createmock io Reader > sample/mock_io/mock_io.go 5 | 6 | The files are also used by `integration_test.go`. 7 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/sample/mock_io/mock_io.go: -------------------------------------------------------------------------------- 1 | // This file was auto-generated using createmock. See the following page for 2 | // more information: 3 | // 4 | // https://github.com/smartystreets/assertions/internal/oglemock 5 | // 6 | 7 | package mock_io 8 | 9 | import ( 10 | fmt "fmt" 11 | oglemock "github.com/smartystreets/assertions/internal/oglemock" 12 | io "io" 13 | runtime "runtime" 14 | unsafe "unsafe" 15 | ) 16 | 17 | type MockReader interface { 18 | io.Reader 19 | oglemock.MockObject 20 | } 21 | 22 | type mockReader struct { 23 | controller oglemock.Controller 24 | description string 25 | } 26 | 27 | func NewMockReader( 28 | c oglemock.Controller, 29 | desc string) MockReader { 30 | return &mockReader{ 31 | controller: c, 32 | description: desc, 33 | } 34 | } 35 | 36 | func (m *mockReader) Oglemock_Id() uintptr { 37 | return uintptr(unsafe.Pointer(m)) 38 | } 39 | 40 | func (m *mockReader) Oglemock_Description() string { 41 | return m.description 42 | } 43 | 44 | func (m *mockReader) Read(p0 []uint8) (o0 int, o1 error) { 45 | // Get a file name and line number for the caller. 46 | _, file, line, _ := runtime.Caller(1) 47 | 48 | // Hand the call off to the controller, which does most of the work. 49 | retVals := m.controller.HandleMethodCall( 50 | m, 51 | "Read", 52 | file, 53 | line, 54 | []interface{}{p0}) 55 | 56 | if len(retVals) != 2 { 57 | panic(fmt.Sprintf("mockReader.Read: invalid return values: %v", retVals)) 58 | } 59 | 60 | // o0 int 61 | if retVals[0] != nil { 62 | o0 = retVals[0].(int) 63 | } 64 | 65 | // o1 error 66 | if retVals[1] != nil { 67 | o1 = retVals[1].(error) 68 | } 69 | 70 | return 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglemock/save_arg.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglemock 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // Create an Action that saves the argument at the given zero-based index to 24 | // the supplied destination, which must be a pointer to a type that is 25 | // assignable from the argument type. 26 | func SaveArg(index int, dst interface{}) Action { 27 | return &saveArg{ 28 | index: index, 29 | dstPointer: dst, 30 | } 31 | } 32 | 33 | type saveArg struct { 34 | index int 35 | dstPointer interface{} 36 | 37 | // Set by SetSignature. 38 | dstValue reflect.Value 39 | } 40 | 41 | func (a *saveArg) SetSignature(signature reflect.Type) (err error) { 42 | // Extract the source type. 43 | if a.index >= signature.NumIn() { 44 | err = fmt.Errorf( 45 | "Out of range argument index %v for function type %v", 46 | a.index, 47 | signature) 48 | return 49 | } 50 | 51 | srcType := signature.In(a.index) 52 | 53 | // The destination must be a pointer. 54 | v := reflect.ValueOf(a.dstPointer) 55 | if v.Kind() != reflect.Ptr { 56 | err = fmt.Errorf("Destination is %v, not a pointer", v.Kind()) 57 | return 58 | } 59 | 60 | // Dereference the pointer. 61 | if v.IsNil() { 62 | err = fmt.Errorf("Destination pointer must be non-nil") 63 | return 64 | } 65 | 66 | a.dstValue = v.Elem() 67 | 68 | // The destination must be assignable from the source. 69 | if !srcType.AssignableTo(a.dstValue.Type()) { 70 | err = fmt.Errorf( 71 | "%v is not assignable to %v", 72 | srcType, 73 | a.dstValue.Type()) 74 | return 75 | } 76 | 77 | return 78 | } 79 | 80 | func (a *saveArg) Invoke(methodArgs []interface{}) (rets []interface{}) { 81 | a.dstValue.Set(reflect.ValueOf(methodArgs[a.index])) 82 | return 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | 6.out 3 | _obj/ 4 | _test/ 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/.travis.yml: -------------------------------------------------------------------------------- 1 | # Cf. http://docs.travis-ci.com/user/getting-started/ 2 | # Cf. http://docs.travis-ci.com/user/languages/go/ 3 | 4 | language: go 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/assert_aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import ( 19 | "github.com/smartystreets/assertions/internal/oglematchers" 20 | ) 21 | 22 | // AssertEq(e, a) is equivalent to AssertThat(a, oglematchers.Equals(e)). 23 | func AssertEq(expected, actual interface{}, errorParts ...interface{}) { 24 | assertThat( 25 | actual, 26 | oglematchers.Equals(expected), 27 | 1, 28 | errorParts) 29 | } 30 | 31 | // AssertNe(e, a) is equivalent to 32 | // AssertThat(a, oglematchers.Not(oglematchers.Equals(e))). 33 | func AssertNe(expected, actual interface{}, errorParts ...interface{}) { 34 | assertThat( 35 | actual, 36 | oglematchers.Not(oglematchers.Equals(expected)), 37 | 1, 38 | errorParts) 39 | } 40 | 41 | // AssertLt(x, y) is equivalent to AssertThat(x, oglematchers.LessThan(y)). 42 | func AssertLt(x, y interface{}, errorParts ...interface{}) { 43 | assertThat(x, oglematchers.LessThan(y), 1, errorParts) 44 | } 45 | 46 | // AssertLe(x, y) is equivalent to AssertThat(x, oglematchers.LessOrEqual(y)). 47 | func AssertLe(x, y interface{}, errorParts ...interface{}) { 48 | assertThat(x, oglematchers.LessOrEqual(y), 1, errorParts) 49 | } 50 | 51 | // AssertGt(x, y) is equivalent to AssertThat(x, oglematchers.GreaterThan(y)). 52 | func AssertGt(x, y interface{}, errorParts ...interface{}) { 53 | assertThat(x, oglematchers.GreaterThan(y), 1, errorParts) 54 | } 55 | 56 | // AssertGe(x, y) is equivalent to 57 | // AssertThat(x, oglematchers.GreaterOrEqual(y)). 58 | func AssertGe(x, y interface{}, errorParts ...interface{}) { 59 | assertThat(x, oglematchers.GreaterOrEqual(y), 1, errorParts) 60 | } 61 | 62 | // AssertTrue(b) is equivalent to AssertThat(b, oglematchers.Equals(true)). 63 | func AssertTrue(b interface{}, errorParts ...interface{}) { 64 | assertThat(b, oglematchers.Equals(true), 1, errorParts) 65 | } 66 | 67 | // AssertFalse(b) is equivalent to AssertThat(b, oglematchers.Equals(false)). 68 | func AssertFalse(b interface{}, errorParts ...interface{}) { 69 | assertThat(b, oglematchers.Equals(false), 1, errorParts) 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/assert_that.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import ( 19 | "github.com/smartystreets/assertions/internal/oglematchers" 20 | ) 21 | 22 | func assertThat( 23 | x interface{}, 24 | m oglematchers.Matcher, 25 | depth int, 26 | errorParts []interface{}) { 27 | passed := expectThat(x, m, depth+1, errorParts) 28 | if !passed { 29 | AbortTest() 30 | } 31 | } 32 | 33 | // AssertThat is identical to ExpectThat, except that in the event of failure 34 | // it halts the currently running test immediately. It is thus useful for 35 | // things like bounds checking: 36 | // 37 | // someSlice := [...] 38 | // AssertEq(1, len(someSlice)) // Protects next line from panicking. 39 | // ExpectEq("taco", someSlice[0]) 40 | // 41 | func AssertThat( 42 | x interface{}, 43 | m oglematchers.Matcher, 44 | errorParts ...interface{}) { 45 | assertThat(x, m, 1, errorParts) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | // Package ogletest provides a framework for writing expressive unit tests. It 17 | // integrates with the builtin testing package, so it works with the gotest 18 | // command. Unlike the testing package which offers only basic capabilities for 19 | // signalling failures, it offers ways to express expectations and get nice 20 | // failure messages automatically. 21 | // 22 | // For example: 23 | // 24 | // //////////////////////////////////////////////////////////////////////// 25 | // // testing package test 26 | // //////////////////////////////////////////////////////////////////////// 27 | // 28 | // someStr, err := ComputeSomeString() 29 | // if err != nil { 30 | // t.Errorf("ComputeSomeString: expected nil error, got %v", err) 31 | // } 32 | // 33 | // !strings.Contains(someStr, "foo") { 34 | // t.Errorf("ComputeSomeString: expected substring foo, got %v", someStr) 35 | // } 36 | // 37 | // //////////////////////////////////////////////////////////////////////// 38 | // // ogletest test 39 | // //////////////////////////////////////////////////////////////////////// 40 | // 41 | // someStr, err := ComputeSomeString() 42 | // ExpectEq(nil, err) 43 | // ExpectThat(someStr, HasSubstr("foo") 44 | // 45 | // Failure messages require no work from the user, and look like the following: 46 | // 47 | // foo_test.go:103: 48 | // Expected: has substring "foo" 49 | // Actual: "bar baz" 50 | // 51 | package ogletest 52 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/expect_aliases.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import "github.com/smartystreets/assertions/internal/oglematchers" 19 | 20 | // ExpectEq(e, a) is equivalent to ExpectThat(a, oglematchers.Equals(e)). 21 | func ExpectEq(expected, actual interface{}, errorParts ...interface{}) { 22 | expectThat(actual, oglematchers.Equals(expected), 1, errorParts) 23 | } 24 | 25 | // ExpectNe(e, a) is equivalent to 26 | // ExpectThat(a, oglematchers.Not(oglematchers.Equals(e))). 27 | func ExpectNe(expected, actual interface{}, errorParts ...interface{}) { 28 | expectThat( 29 | actual, 30 | oglematchers.Not(oglematchers.Equals(expected)), 31 | 1, 32 | errorParts) 33 | } 34 | 35 | // ExpectLt(x, y) is equivalent to ExpectThat(x, oglematchers.LessThan(y)). 36 | func ExpectLt(x, y interface{}, errorParts ...interface{}) { 37 | expectThat(x, oglematchers.LessThan(y), 1, errorParts) 38 | } 39 | 40 | // ExpectLe(x, y) is equivalent to ExpectThat(x, oglematchers.LessOrEqual(y)). 41 | func ExpectLe(x, y interface{}, errorParts ...interface{}) { 42 | expectThat(x, oglematchers.LessOrEqual(y), 1, errorParts) 43 | } 44 | 45 | // ExpectGt(x, y) is equivalent to ExpectThat(x, oglematchers.GreaterThan(y)). 46 | func ExpectGt(x, y interface{}, errorParts ...interface{}) { 47 | expectThat(x, oglematchers.GreaterThan(y), 1, errorParts) 48 | } 49 | 50 | // ExpectGe(x, y) is equivalent to 51 | // ExpectThat(x, oglematchers.GreaterOrEqual(y)). 52 | func ExpectGe(x, y interface{}, errorParts ...interface{}) { 53 | expectThat(x, oglematchers.GreaterOrEqual(y), 1, errorParts) 54 | } 55 | 56 | // ExpectTrue(b) is equivalent to ExpectThat(b, oglematchers.Equals(true)). 57 | func ExpectTrue(b interface{}, errorParts ...interface{}) { 58 | expectThat(b, oglematchers.Equals(true), 1, errorParts) 59 | } 60 | 61 | // ExpectFalse(b) is equivalent to ExpectThat(b, oglematchers.Equals(false)). 62 | func ExpectFalse(b interface{}, errorParts ...interface{}) { 63 | expectThat(b, oglematchers.Equals(false), 1, errorParts) 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/expect_call.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import ( 19 | "github.com/smartystreets/assertions/internal/oglemock" 20 | "runtime" 21 | ) 22 | 23 | // ExpectCall expresses an expectation that the method of the given name 24 | // should be called on the supplied mock object. It returns a function that 25 | // should be called with the expected arguments, matchers for the arguments, 26 | // or a mix of both. 27 | // 28 | // For example: 29 | // 30 | // mockWriter := [...] 31 | // ogletest.ExpectCall(mockWriter, "Write")(oglematchers.ElementsAre(0x1)) 32 | // .WillOnce(oglemock.Return(1, nil)) 33 | // 34 | // This is a shortcut for calling i.MockController.ExpectCall, where i is the 35 | // TestInfo struct for the currently-running test. Unlike that direct approach, 36 | // this function automatically sets the correct file name and line number for 37 | // the expectation. 38 | func ExpectCall(o oglemock.MockObject, method string) oglemock.PartialExpecation { 39 | // Get information about the call site. 40 | _, file, lineNumber, ok := runtime.Caller(1) 41 | if !ok { 42 | panic("ExpectCall: runtime.Caller") 43 | } 44 | 45 | // Grab the current test info. 46 | info := currentlyRunningTest 47 | if info == nil { 48 | panic("ExpectCall: no test info.") 49 | } 50 | 51 | // Grab the mock controller. 52 | controller := currentlyRunningTest.MockController 53 | if controller == nil { 54 | panic("ExpectCall: no mock controller.") 55 | } 56 | 57 | // Report the expectation. 58 | return controller.ExpectCall(o, method, file, lineNumber) 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/expect_that.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import ( 19 | "fmt" 20 | "path" 21 | "reflect" 22 | "runtime" 23 | 24 | "github.com/smartystreets/assertions/internal/oglematchers" 25 | ) 26 | 27 | // ExpectThat confirms that the supplied matcher matches the value x, adding a 28 | // failure record to the currently running test if it does not. If additional 29 | // parameters are supplied, the first will be used as a format string for the 30 | // later ones, and the user-supplied error message will be added to the test 31 | // output in the event of a failure. 32 | // 33 | // For example: 34 | // 35 | // ExpectThat(userName, Equals("jacobsa")) 36 | // ExpectThat(users[i], Equals("jacobsa"), "while processing user %d", i) 37 | // 38 | func ExpectThat( 39 | x interface{}, 40 | m oglematchers.Matcher, 41 | errorParts ...interface{}) { 42 | expectThat(x, m, 1, errorParts) 43 | } 44 | 45 | // The generalized form of ExpectThat. depth is the distance on the stack 46 | // between the caller's frame and the user's frame. Returns passed iff the 47 | // match succeeded. 48 | func expectThat( 49 | x interface{}, 50 | m oglematchers.Matcher, 51 | depth int, 52 | errorParts []interface{}) (passed bool) { 53 | // Check whether the value matches. If it does, we are finished. 54 | matcherErr := m.Matches(x) 55 | if matcherErr == nil { 56 | passed = true 57 | return 58 | } 59 | 60 | var r FailureRecord 61 | 62 | // Get information about the call site. 63 | var ok bool 64 | if _, r.FileName, r.LineNumber, ok = runtime.Caller(depth + 1); !ok { 65 | panic("expectThat: runtime.Caller") 66 | } 67 | 68 | r.FileName = path.Base(r.FileName) 69 | 70 | // Create an appropriate failure message. Make sure that the expected and 71 | // actual values align properly. 72 | relativeClause := "" 73 | if matcherErr.Error() != "" { 74 | relativeClause = fmt.Sprintf(", %s", matcherErr.Error()) 75 | } 76 | 77 | r.Error = fmt.Sprintf( 78 | "Expected: %s\nActual: %v%s", 79 | m.Description(), 80 | x, 81 | relativeClause) 82 | 83 | // Add the user error, if any. 84 | if len(errorParts) != 0 { 85 | v := reflect.ValueOf(errorParts[0]) 86 | if v.Kind() != reflect.String { 87 | panic(fmt.Sprintf("ExpectThat: invalid format string type %v", v.Kind())) 88 | } 89 | 90 | r.Error = fmt.Sprintf( 91 | "%s\n%s", 92 | r.Error, 93 | fmt.Sprintf(v.String(), errorParts[1:]...)) 94 | } 95 | 96 | // Report the failure. 97 | AddFailureRecord(r) 98 | 99 | return 100 | } 101 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/failure.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import ( 19 | "fmt" 20 | "path" 21 | "runtime" 22 | ) 23 | 24 | // FailureRecord represents a single failed expectation or assertion for a 25 | // test. Most users don't want to interact with these directly; they are 26 | // generated implicitly using ExpectThat, AssertThat, ExpectLt, etc. 27 | type FailureRecord struct { 28 | // The file name within which the expectation failed, e.g. "foo_test.go". 29 | FileName string 30 | 31 | // The line number at which the expectation failed. 32 | LineNumber int 33 | 34 | // The error associated with the file:line pair above. For example, the 35 | // following expectation: 36 | // 37 | // ExpectEq(17, "taco")" 38 | // 39 | // May cause this error: 40 | // 41 | // Expected: 17 42 | // Actual: "taco", which is not numeric 43 | // 44 | Error string 45 | } 46 | 47 | // Record a failure for the currently running test (and continue running it). 48 | // Most users will want to use ExpectThat, ExpectEq, etc. instead of this 49 | // function. Those that do want to report arbitrary errors will probably be 50 | // satisfied with AddFailure, which is easier to use. 51 | func AddFailureRecord(r FailureRecord) { 52 | currentlyRunningTest.mu.Lock() 53 | defer currentlyRunningTest.mu.Unlock() 54 | 55 | currentlyRunningTest.failureRecords = append( 56 | currentlyRunningTest.failureRecords, 57 | r) 58 | } 59 | 60 | // Call AddFailureRecord with a record whose file name and line number come 61 | // from the caller of this function, and whose error string is created by 62 | // calling fmt.Sprintf using the arguments to this function. 63 | func AddFailure(format string, a ...interface{}) { 64 | r := FailureRecord{ 65 | Error: fmt.Sprintf(format, a...), 66 | } 67 | 68 | // Get information about the call site. 69 | var ok bool 70 | if _, r.FileName, r.LineNumber, ok = runtime.Caller(1); !ok { 71 | panic("Can't find caller") 72 | } 73 | 74 | r.FileName = path.Base(r.FileName) 75 | 76 | AddFailureRecord(r) 77 | } 78 | 79 | // A sentinel type that is used in a conspiracy between AbortTest and runTests. 80 | // If runTests sees an abortError as the value given to a panic() call, it will 81 | // avoid printing the panic error. 82 | type abortError struct { 83 | } 84 | 85 | // Immediately stop executing the running test, causing it to fail with the 86 | // failures previously recorded. Behavior is undefined if no failures have been 87 | // recorded. 88 | func AbortTest() { 89 | panic(abortError{}) 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/register.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | // The input to ogletest.Register. Most users will want to use 19 | // ogletest.RegisterTestSuite. 20 | // 21 | // A test suite is the basic unit of registration in ogletest. It consists of 22 | // zero or more named test functions which will be run in sequence, along with 23 | // optional setup and tear-down functions. 24 | type TestSuite struct { 25 | // The name of the overall suite, e.g. "MyPackageTest". 26 | Name string 27 | 28 | // If non-nil, a function that will be run exactly once, before any of the 29 | // test functions are run. 30 | SetUp func() 31 | 32 | // The test functions comprising this suite. 33 | TestFunctions []TestFunction 34 | 35 | // If non-nil, a function that will be run exactly once, after all of the 36 | // test functions have run. 37 | TearDown func() 38 | } 39 | 40 | type TestFunction struct { 41 | // The name of this test function, relative to the suite in which it resides. 42 | // If the name is "TweaksFrobnicator", then the function might be presented 43 | // in the ogletest UI as "FooTest.TweaksFrobnicator". 44 | Name string 45 | 46 | // If non-nil, a function that is run before Run, passed a pointer to a 47 | // struct containing information about the test run. 48 | SetUp func(*TestInfo) 49 | 50 | // The function to invoke for the test body. Must be non-nil. Will not be run 51 | // if SetUp panics. 52 | Run func() 53 | 54 | // If non-nil, a function that is run after Run. 55 | TearDown func() 56 | } 57 | 58 | // Register a test suite for execution by RunTests. 59 | // 60 | // This is the most general registration mechanism. Most users will want 61 | // RegisterTestSuite, which is a wrapper around this function that requires 62 | // less boilerplate. 63 | // 64 | // Panics on invalid input. 65 | func Register(suite TestSuite) { 66 | // Make sure the suite is legal. 67 | if suite.Name == "" { 68 | panic("Test suites must have names.") 69 | } 70 | 71 | for _, tf := range suite.TestFunctions { 72 | if tf.Name == "" { 73 | panic("Test functions must have names.") 74 | } 75 | 76 | if tf.Run == nil { 77 | panic("Test functions must have non-nil run fields.") 78 | } 79 | } 80 | 81 | // Save the suite for later. 82 | registeredSuites = append(registeredSuites, suite) 83 | } 84 | 85 | // The list of test suites previously registered. 86 | var registeredSuites []TestSuite 87 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/docs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | 4 | // Functions for working with source code. 5 | package srcutil 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/srcutil/methods.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package srcutil 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | "runtime" 22 | "sort" 23 | ) 24 | 25 | func getLine(m reflect.Method) int { 26 | pc := m.Func.Pointer() 27 | 28 | f := runtime.FuncForPC(pc) 29 | if f == nil { 30 | panic(fmt.Sprintf("Couldn't get runtime func for method (pc=%d): %v", pc, m)) 31 | } 32 | 33 | _, line := f.FileLine(pc) 34 | return line 35 | } 36 | 37 | type sortableMethodSet []reflect.Method 38 | 39 | func (s sortableMethodSet) Len() int { 40 | return len(s) 41 | } 42 | 43 | func (s sortableMethodSet) Less(i, j int) bool { 44 | return getLine(s[i]) < getLine(s[j]) 45 | } 46 | 47 | func (s sortableMethodSet) Swap(i, j int) { 48 | s[i], s[j] = s[j], s[i] 49 | } 50 | 51 | // Given a type t, return all of the methods of t sorted such that source file 52 | // order is preserved. Order across files is undefined. Order within lines is 53 | // undefined. 54 | func GetMethodsInSourceOrder(t reflect.Type) []reflect.Method { 55 | // Build the list of methods. 56 | methods := sortableMethodSet{} 57 | for i := 0; i < t.NumMethod(); i++ { 58 | methods = append(methods, t.Method(i)) 59 | } 60 | 61 | // Sort it. 62 | sort.Sort(methods) 63 | 64 | return methods 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/filtered.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | "fmt" 20 | . "github.com/smartystreets/assertions/internal/oglematchers" 21 | . "github.com/smartystreets/assertions/internal/ogletest" 22 | "testing" 23 | ) 24 | 25 | func TestFiltered(t *testing.T) { RunTests(t) } 26 | 27 | //////////////////////////////////////////////////////////////////////// 28 | // Partially filtered out 29 | //////////////////////////////////////////////////////////////////////// 30 | 31 | type PartiallyFilteredTest struct { 32 | } 33 | 34 | func init() { RegisterTestSuite(&PartiallyFilteredTest{}) } 35 | 36 | func (t *PartiallyFilteredTest) PassingTestFoo() { 37 | ExpectThat(19, Equals(19)) 38 | } 39 | 40 | func (t *PartiallyFilteredTest) PassingTestBar() { 41 | ExpectThat(17, Equals(17)) 42 | } 43 | 44 | func (t *PartiallyFilteredTest) PartiallyFilteredTestFoo() { 45 | ExpectThat(18, LessThan(17)) 46 | } 47 | 48 | func (t *PartiallyFilteredTest) PartiallyFilteredTestBar() { 49 | ExpectThat("taco", HasSubstr("blah")) 50 | } 51 | 52 | func (t *PartiallyFilteredTest) PartiallyFilteredTestBaz() { 53 | ExpectThat(18, LessThan(17)) 54 | } 55 | 56 | //////////////////////////////////////////////////////////////////////// 57 | // Completely filtered out 58 | //////////////////////////////////////////////////////////////////////// 59 | 60 | type CompletelyFilteredTest struct { 61 | } 62 | 63 | func init() { RegisterTestSuite(&CompletelyFilteredTest{}) } 64 | 65 | func (t *CompletelyFilteredTest) SetUpTestSuite() { 66 | fmt.Println("SetUpTestSuite run!") 67 | } 68 | 69 | func (t *CompletelyFilteredTest) TearDownTestSuite() { 70 | fmt.Println("TearDownTestSuite run!") 71 | } 72 | 73 | func (t *PartiallyFilteredTest) SomePassingTest() { 74 | ExpectThat(19, Equals(19)) 75 | } 76 | 77 | func (t *PartiallyFilteredTest) SomeFailingTest() { 78 | ExpectThat(19, Equals(17)) 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.filtered_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from PartiallyFilteredTest 2 | [ RUN ] PartiallyFilteredTest.PassingTestBar 3 | [ OK ] PartiallyFilteredTest.PassingTestBar 4 | [ RUN ] PartiallyFilteredTest.PartiallyFilteredTestBar 5 | filtered_test.go:49: 6 | Expected: has substring "blah" 7 | Actual: taco 8 | 9 | [ FAILED ] PartiallyFilteredTest.PartiallyFilteredTestBar 10 | [ RUN ] PartiallyFilteredTest.PartiallyFilteredTestBaz 11 | filtered_test.go:53: 12 | Expected: less than 17 13 | Actual: 18 14 | 15 | [ FAILED ] PartiallyFilteredTest.PartiallyFilteredTestBaz 16 | [----------] Finished with tests from PartiallyFilteredTest 17 | [----------] Running tests from CompletelyFilteredTest 18 | SetUpTestSuite run! 19 | TearDownTestSuite run! 20 | [----------] Finished with tests from CompletelyFilteredTest 21 | --- FAIL: TestSomething (1.23s) 22 | FAIL 23 | exit status 1 24 | FAIL somepkg 1.234s 25 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.mock_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from MockTest 2 | [ RUN ] MockTest.ExpectationSatisfied 3 | [ OK ] MockTest.ExpectationSatisfied 4 | [ RUN ] MockTest.MockExpectationNotSatisfied 5 | /some/path/mock_test.go:56: 6 | Unsatisfied expectation; expected At to be called at least 1 times; called 0 times. 7 | 8 | [ FAILED ] MockTest.MockExpectationNotSatisfied 9 | [ RUN ] MockTest.ExpectCallForUnknownMethod 10 | /some/path/mock_test.go:61: 11 | Unknown method: FooBar 12 | 13 | [ FAILED ] MockTest.ExpectCallForUnknownMethod 14 | [ RUN ] MockTest.UnexpectedCall 15 | /some/path/mock_test.go:65: 16 | Unexpected call to At with args: [11 23] 17 | 18 | [ FAILED ] MockTest.UnexpectedCall 19 | [ RUN ] MockTest.InvokeFunction 20 | [ OK ] MockTest.InvokeFunction 21 | [----------] Finished with tests from MockTest 22 | --- FAIL: TestSomething (1.23s) 23 | FAIL 24 | exit status 1 25 | FAIL somepkg 1.234s 26 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.no_cases_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from NoCasesTest 2 | SetUpTestSuite run! 3 | TearDownTestSuite run! 4 | [----------] Finished with tests from NoCasesTest 5 | PASS 6 | ok somepkg 1.234s 7 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.panicking_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from PanickingTest 2 | [ RUN ] PanickingTest.ExplicitPanic 3 | TearDown running. 4 | panicking_test.go:47: 5 | panic: Panic in ExplicitPanic 6 | 7 | github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).ExplicitPanic 8 | some_file.txt:0 9 | runtime.call16 10 | /some/path/asm_amd64.s:401 11 | reflect.Value.call 12 | some_file.txt:0 13 | reflect.Value.Call 14 | some_file.txt:0 15 | 16 | 17 | [ FAILED ] PanickingTest.ExplicitPanic 18 | [ RUN ] PanickingTest.ExplicitPanicInHelperFunction 19 | TearDown running. 20 | panicking_test.go:34: 21 | panic: Panic in someFuncThatPanics 22 | 23 | github.com/smartystreets/assertions/internal/ogletest/somepkg_test.someFuncThatPanics 24 | some_file.txt:0 25 | github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).ExplicitPanicInHelperFunction 26 | some_file.txt:0 27 | runtime.call16 28 | /some/path/asm_amd64.s:401 29 | reflect.Value.call 30 | some_file.txt:0 31 | reflect.Value.Call 32 | some_file.txt:0 33 | 34 | 35 | [ FAILED ] PanickingTest.ExplicitPanicInHelperFunction 36 | [ RUN ] PanickingTest.NilPointerDerefence 37 | TearDown running. 38 | panicking_test.go:56: 39 | panic: runtime error: invalid memory address or nil pointer dereference 40 | 41 | github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*PanickingTest).NilPointerDerefence 42 | some_file.txt:0 43 | runtime.call16 44 | /some/path/asm_amd64.s:401 45 | reflect.Value.call 46 | some_file.txt:0 47 | reflect.Value.Call 48 | some_file.txt:0 49 | 50 | 51 | [ FAILED ] PanickingTest.NilPointerDerefence 52 | [ RUN ] PanickingTest.ZzzSomeOtherTest 53 | TearDown running. 54 | [ OK ] PanickingTest.ZzzSomeOtherTest 55 | [----------] Finished with tests from PanickingTest 56 | [----------] Running tests from SetUpPanicTest 57 | [ RUN ] SetUpPanicTest.SomeTestCase 58 | SetUp about to panic. 59 | TearDown running. 60 | panicking_test.go:74: 61 | panic: Panic in SetUp 62 | 63 | github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*SetUpPanicTest).SetUp 64 | some_file.txt:0 65 | github.com/smartystreets/assertions/internal/ogletest.func·003 66 | some_file.txt:0 67 | github.com/smartystreets/assertions/internal/ogletest.func·007 68 | some_file.txt:0 69 | 70 | 71 | [ FAILED ] SetUpPanicTest.SomeTestCase 72 | [----------] Finished with tests from SetUpPanicTest 73 | [----------] Running tests from TearDownPanicTest 74 | [ RUN ] TearDownPanicTest.SomeTestCase 75 | TearDown about to panic. 76 | panicking_test.go:95: 77 | panic: Panic in TearDown 78 | 79 | github.com/smartystreets/assertions/internal/ogletest/somepkg_test.(*TearDownPanicTest).TearDown 80 | some_file.txt:0 81 | github.com/smartystreets/assertions/internal/ogletest.func·005 82 | some_file.txt:0 83 | 84 | 85 | [ FAILED ] TearDownPanicTest.SomeTestCase 86 | [----------] Finished with tests from TearDownPanicTest 87 | --- FAIL: TestSomething (1.23s) 88 | FAIL 89 | exit status 1 90 | FAIL somepkg 1.234s 91 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.passing_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from PassingTest 2 | [ RUN ] PassingTest.EmptyTestMethod 3 | [ OK ] PassingTest.EmptyTestMethod 4 | [ RUN ] PassingTest.SuccessfullMatches 5 | [ OK ] PassingTest.SuccessfullMatches 6 | [ RUN ] PassingTest.ExpectAliases 7 | [ OK ] PassingTest.ExpectAliases 8 | [ RUN ] PassingTest.AssertAliases 9 | [ OK ] PassingTest.AssertAliases 10 | [ RUN ] PassingTest.SlowTest 11 | [ OK ] PassingTest.SlowTest (1234ms) 12 | [----------] Finished with tests from PassingTest 13 | [----------] Running tests from PassingTestWithHelpers 14 | SetUpTestSuite ran. 15 | [ RUN ] PassingTestWithHelpers.EmptyTestMethod 16 | SetUp ran. 17 | TearDown ran. 18 | [ OK ] PassingTestWithHelpers.EmptyTestMethod 19 | TearDownTestSuite ran. 20 | [----------] Finished with tests from PassingTestWithHelpers 21 | PASS 22 | ok somepkg 1.234s 23 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.run_twice_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from RunTwiceTest 2 | [ RUN ] RunTwiceTest.PassingMethod 3 | [ OK ] RunTwiceTest.PassingMethod 4 | [ RUN ] RunTwiceTest.FailingMethod 5 | run_twice_test.go:46: 6 | Expected: 17.5 7 | Actual: 17 8 | 9 | [ FAILED ] RunTwiceTest.FailingMethod 10 | [----------] Finished with tests from RunTwiceTest 11 | --- FAIL: TestSomething (1.23s) 12 | FAIL 13 | exit status 1 14 | FAIL somepkg 1.234s 15 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.stop_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from StopTest 2 | [ RUN ] StopTest.First 3 | TearDown running. 4 | [ OK ] StopTest.First 5 | [ RUN ] StopTest.Second 6 | About to call StopRunningTests. 7 | Called StopRunningTests. 8 | TearDown running. 9 | [ OK ] StopTest.Second 10 | TearDownTestSuite running. 11 | Exiting early due to user request. 12 | exit status 1 13 | FAIL somepkg 1.234s 14 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/golden.unexported_test: -------------------------------------------------------------------------------- 1 | [----------] Running tests from UnexportedTest 2 | [ RUN ] UnexportedTest.SomeTest 3 | unexported_test.go:42: 4 | Expected: 4 5 | Actual: 3 6 | 7 | [ FAILED ] UnexportedTest.SomeTest 8 | [----------] Finished with tests from UnexportedTest 9 | --- FAIL: TestSomething (1.23s) 10 | FAIL 11 | exit status 1 12 | FAIL somepkg 1.234s 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | . "github.com/smartystreets/assertions/internal/oglematchers" 20 | "github.com/smartystreets/assertions/internal/oglemock" 21 | . "github.com/smartystreets/assertions/internal/ogletest" 22 | "github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image" 23 | "image/color" 24 | "testing" 25 | ) 26 | 27 | //////////////////////////////////////////////////////////////////////// 28 | // Helpers 29 | //////////////////////////////////////////////////////////////////////// 30 | 31 | type MockTest struct { 32 | controller oglemock.Controller 33 | image mock_image.MockImage 34 | } 35 | 36 | func init() { RegisterTestSuite(&MockTest{}) } 37 | func TestMockTest(t *testing.T) { RunTests(t) } 38 | 39 | func (t *MockTest) SetUp(i *TestInfo) { 40 | t.controller = i.MockController 41 | t.image = mock_image.NewMockImage(t.controller, "some mock image") 42 | } 43 | 44 | //////////////////////////////////////////////////////////////////////// 45 | // Tests 46 | //////////////////////////////////////////////////////////////////////// 47 | 48 | func (t *MockTest) ExpectationSatisfied() { 49 | ExpectCall(t.image, "At")(11, GreaterThan(19)). 50 | WillOnce(oglemock.Return(color.Gray{0})) 51 | 52 | ExpectThat(t.image.At(11, 23), IdenticalTo(color.Gray{0})) 53 | } 54 | 55 | func (t *MockTest) MockExpectationNotSatisfied() { 56 | ExpectCall(t.image, "At")(11, GreaterThan(19)). 57 | WillOnce(oglemock.Return(color.Gray{0})) 58 | } 59 | 60 | func (t *MockTest) ExpectCallForUnknownMethod() { 61 | ExpectCall(t.image, "FooBar")(11) 62 | } 63 | 64 | func (t *MockTest) UnexpectedCall() { 65 | t.image.At(11, 23) 66 | } 67 | 68 | func (t *MockTest) InvokeFunction() { 69 | var suppliedX, suppliedY int 70 | f := func(x, y int) color.Color { 71 | suppliedX = x 72 | suppliedY = y 73 | return color.Gray{17} 74 | } 75 | 76 | ExpectCall(t.image, "At")(Any(), Any()). 77 | WillOnce(oglemock.Invoke(f)) 78 | 79 | ExpectThat(t.image.At(-1, 12), IdenticalTo(color.Gray{17})) 80 | ExpectEq(-1, suppliedX) 81 | ExpectEq(12, suppliedY) 82 | } 83 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/mock_image/mock_image.go: -------------------------------------------------------------------------------- 1 | // This file was auto-generated using createmock. See the following page for 2 | // more information: 3 | // 4 | // https://github.com/smartystreets/assertions/internal/oglemock 5 | // 6 | 7 | package mock_image 8 | 9 | import ( 10 | fmt "fmt" 11 | oglemock "github.com/smartystreets/assertions/internal/oglemock" 12 | image "image" 13 | color "image/color" 14 | runtime "runtime" 15 | unsafe "unsafe" 16 | ) 17 | 18 | type MockImage interface { 19 | image.Image 20 | oglemock.MockObject 21 | } 22 | 23 | type mockImage struct { 24 | controller oglemock.Controller 25 | description string 26 | } 27 | 28 | func NewMockImage( 29 | c oglemock.Controller, 30 | desc string) MockImage { 31 | return &mockImage{ 32 | controller: c, 33 | description: desc, 34 | } 35 | } 36 | 37 | func (m *mockImage) Oglemock_Id() uintptr { 38 | return uintptr(unsafe.Pointer(m)) 39 | } 40 | 41 | func (m *mockImage) Oglemock_Description() string { 42 | return m.description 43 | } 44 | 45 | func (m *mockImage) At(p0 int, p1 int) (o0 color.Color) { 46 | // Get a file name and line number for the caller. 47 | _, file, line, _ := runtime.Caller(1) 48 | 49 | // Hand the call off to the controller, which does most of the work. 50 | retVals := m.controller.HandleMethodCall( 51 | m, 52 | "At", 53 | file, 54 | line, 55 | []interface{}{p0, p1}) 56 | 57 | if len(retVals) != 1 { 58 | panic(fmt.Sprintf("mockImage.At: invalid return values: %v", retVals)) 59 | } 60 | 61 | // o0 color.Color 62 | if retVals[0] != nil { 63 | o0 = retVals[0].(color.Color) 64 | } 65 | 66 | return 67 | } 68 | 69 | func (m *mockImage) Bounds() (o0 image.Rectangle) { 70 | // Get a file name and line number for the caller. 71 | _, file, line, _ := runtime.Caller(1) 72 | 73 | // Hand the call off to the controller, which does most of the work. 74 | retVals := m.controller.HandleMethodCall( 75 | m, 76 | "Bounds", 77 | file, 78 | line, 79 | []interface{}{}) 80 | 81 | if len(retVals) != 1 { 82 | panic(fmt.Sprintf("mockImage.Bounds: invalid return values: %v", retVals)) 83 | } 84 | 85 | // o0 image.Rectangle 86 | if retVals[0] != nil { 87 | o0 = retVals[0].(image.Rectangle) 88 | } 89 | 90 | return 91 | } 92 | 93 | func (m *mockImage) ColorModel() (o0 color.Model) { 94 | // Get a file name and line number for the caller. 95 | _, file, line, _ := runtime.Caller(1) 96 | 97 | // Hand the call off to the controller, which does most of the work. 98 | retVals := m.controller.HandleMethodCall( 99 | m, 100 | "ColorModel", 101 | file, 102 | line, 103 | []interface{}{}) 104 | 105 | if len(retVals) != 1 { 106 | panic(fmt.Sprintf("mockImage.ColorModel: invalid return values: %v", retVals)) 107 | } 108 | 109 | // o0 color.Model 110 | if retVals[0] != nil { 111 | o0 = retVals[0].(color.Model) 112 | } 113 | 114 | return 115 | } 116 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/no_cases.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | "fmt" 20 | . "github.com/smartystreets/assertions/internal/ogletest" 21 | "testing" 22 | ) 23 | 24 | func TestNoCases(t *testing.T) { RunTests(t) } 25 | 26 | //////////////////////////////////////////////////////////////////////// 27 | // Helpers 28 | //////////////////////////////////////////////////////////////////////// 29 | 30 | type NoCasesTest struct { 31 | } 32 | 33 | func init() { RegisterTestSuite(&NoCasesTest{}) } 34 | 35 | func (t *NoCasesTest) SetUpTestSuite() { 36 | fmt.Println("SetUpTestSuite run!") 37 | } 38 | 39 | func (t *NoCasesTest) TearDownTestSuite() { 40 | fmt.Println("TearDownTestSuite run!") 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/panicking.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | "fmt" 20 | "log" 21 | "testing" 22 | 23 | . "github.com/smartystreets/assertions/internal/oglematchers" 24 | . "github.com/smartystreets/assertions/internal/ogletest" 25 | ) 26 | 27 | func TestPanickingTest(t *testing.T) { RunTests(t) } 28 | 29 | //////////////////////////////////////////////////////////////////////// 30 | // PanickingTest 31 | //////////////////////////////////////////////////////////////////////// 32 | 33 | func someFuncThatPanics() { 34 | panic("Panic in someFuncThatPanics") 35 | } 36 | 37 | type PanickingTest struct { 38 | } 39 | 40 | func init() { RegisterTestSuite(&PanickingTest{}) } 41 | 42 | func (t *PanickingTest) TearDown() { 43 | fmt.Println("TearDown running.") 44 | } 45 | 46 | func (t *PanickingTest) ExplicitPanic() { 47 | panic("Panic in ExplicitPanic") 48 | } 49 | 50 | func (t *PanickingTest) ExplicitPanicInHelperFunction() { 51 | someFuncThatPanics() 52 | } 53 | 54 | func (t *PanickingTest) NilPointerDerefence() { 55 | var p *int 56 | log.Println(*p) 57 | } 58 | 59 | func (t *PanickingTest) ZzzSomeOtherTest() { 60 | ExpectThat(17, Equals(17.0)) 61 | } 62 | 63 | //////////////////////////////////////////////////////////////////////// 64 | // SetUpPanicTest 65 | //////////////////////////////////////////////////////////////////////// 66 | 67 | type SetUpPanicTest struct { 68 | } 69 | 70 | func init() { RegisterTestSuite(&SetUpPanicTest{}) } 71 | 72 | func (t *SetUpPanicTest) SetUp(ti *TestInfo) { 73 | fmt.Println("SetUp about to panic.") 74 | panic("Panic in SetUp") 75 | } 76 | 77 | func (t *SetUpPanicTest) TearDown() { 78 | fmt.Println("TearDown running.") 79 | } 80 | 81 | func (t *SetUpPanicTest) SomeTestCase() { 82 | } 83 | 84 | //////////////////////////////////////////////////////////////////////// 85 | // TearDownPanicTest 86 | //////////////////////////////////////////////////////////////////////// 87 | 88 | type TearDownPanicTest struct { 89 | } 90 | 91 | func init() { RegisterTestSuite(&TearDownPanicTest{}) } 92 | 93 | func (t *TearDownPanicTest) TearDown() { 94 | fmt.Println("TearDown about to panic.") 95 | panic("Panic in TearDown") 96 | } 97 | 98 | func (t *TearDownPanicTest) SomeTestCase() { 99 | } 100 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/passing.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | "fmt" 20 | "testing" 21 | "time" 22 | 23 | . "github.com/smartystreets/assertions/internal/oglematchers" 24 | . "github.com/smartystreets/assertions/internal/ogletest" 25 | ) 26 | 27 | func TestPassingTest(t *testing.T) { RunTests(t) } 28 | 29 | //////////////////////////////////////////////////////////////////////// 30 | // PassingTest 31 | //////////////////////////////////////////////////////////////////////// 32 | 33 | type PassingTest struct { 34 | } 35 | 36 | func init() { RegisterTestSuite(&PassingTest{}) } 37 | 38 | func (t *PassingTest) EmptyTestMethod() { 39 | } 40 | 41 | func (t *PassingTest) SuccessfullMatches() { 42 | ExpectThat(17, Equals(17.0)) 43 | ExpectThat(16.9, LessThan(17)) 44 | ExpectThat("taco", HasSubstr("ac")) 45 | 46 | AssertThat(17, Equals(17.0)) 47 | AssertThat(16.9, LessThan(17)) 48 | AssertThat("taco", HasSubstr("ac")) 49 | } 50 | 51 | func (t *PassingTest) ExpectAliases() { 52 | ExpectEq(17, 17.0) 53 | 54 | ExpectLe(17, 17.0) 55 | ExpectLe(17, 18.0) 56 | ExpectLt(17, 18.0) 57 | 58 | ExpectGe(17, 17.0) 59 | ExpectGe(17, 16.0) 60 | ExpectGt(17, 16.0) 61 | 62 | ExpectNe(17, 18.0) 63 | 64 | ExpectTrue(true) 65 | ExpectFalse(false) 66 | } 67 | 68 | func (t *PassingTest) AssertAliases() { 69 | AssertEq(17, 17.0) 70 | 71 | AssertLe(17, 17.0) 72 | AssertLe(17, 18.0) 73 | AssertLt(17, 18.0) 74 | 75 | AssertGe(17, 17.0) 76 | AssertGe(17, 16.0) 77 | AssertGt(17, 16.0) 78 | 79 | AssertNe(17, 18.0) 80 | 81 | AssertTrue(true) 82 | AssertFalse(false) 83 | } 84 | 85 | func (t *PassingTest) SlowTest() { 86 | time.Sleep(37 * time.Millisecond) 87 | } 88 | 89 | //////////////////////////////////////////////////////////////////////// 90 | // PassingTestWithHelpers 91 | //////////////////////////////////////////////////////////////////////// 92 | 93 | type PassingTestWithHelpers struct { 94 | } 95 | 96 | var _ SetUpTestSuiteInterface = &PassingTestWithHelpers{} 97 | var _ SetUpInterface = &PassingTestWithHelpers{} 98 | var _ TearDownInterface = &PassingTestWithHelpers{} 99 | var _ TearDownTestSuiteInterface = &PassingTestWithHelpers{} 100 | 101 | func init() { RegisterTestSuite(&PassingTestWithHelpers{}) } 102 | 103 | func (t *PassingTestWithHelpers) SetUpTestSuite() { 104 | fmt.Println("SetUpTestSuite ran.") 105 | } 106 | 107 | func (t *PassingTestWithHelpers) SetUp(ti *TestInfo) { 108 | fmt.Println("SetUp ran.") 109 | } 110 | 111 | func (t *PassingTestWithHelpers) TearDown() { 112 | fmt.Println("TearDown ran.") 113 | } 114 | 115 | func (t *PassingTestWithHelpers) TearDownTestSuite() { 116 | fmt.Println("TearDownTestSuite ran.") 117 | } 118 | 119 | func (t *PassingTestWithHelpers) EmptyTestMethod() { 120 | } 121 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/run_twice.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | . "github.com/smartystreets/assertions/internal/oglematchers" 20 | . "github.com/smartystreets/assertions/internal/ogletest" 21 | "testing" 22 | ) 23 | 24 | //////////////////////////////////////////////////////////////////////// 25 | // Helpers 26 | //////////////////////////////////////////////////////////////////////// 27 | 28 | type RunTwiceTest struct { 29 | } 30 | 31 | func init() { RegisterTestSuite(&RunTwiceTest{}) } 32 | 33 | // Set up two helpers that call RunTests. The test should still only be run 34 | // once. 35 | func TestOgletest(t *testing.T) { RunTests(t) } 36 | func TestOgletest2(t *testing.T) { RunTests(t) } 37 | 38 | //////////////////////////////////////////////////////////////////////// 39 | // Tests 40 | //////////////////////////////////////////////////////////////////////// 41 | 42 | func (t *RunTwiceTest) PassingMethod() { 43 | } 44 | 45 | func (t *RunTwiceTest) FailingMethod() { 46 | ExpectThat(17, Equals(17.5)) 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/stop.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | "fmt" 20 | "testing" 21 | 22 | . "github.com/smartystreets/assertions/internal/ogletest" 23 | ) 24 | 25 | func TestStop(t *testing.T) { RunTests(t) } 26 | 27 | //////////////////////////////////////////////////////////////////////// 28 | // Boilerplate 29 | //////////////////////////////////////////////////////////////////////// 30 | 31 | type StopTest struct { 32 | } 33 | 34 | var _ TearDownInterface = &StopTest{} 35 | var _ TearDownTestSuiteInterface = &StopTest{} 36 | 37 | func init() { RegisterTestSuite(&StopTest{}) } 38 | 39 | func (t *StopTest) TearDown() { 40 | fmt.Println("TearDown running.") 41 | } 42 | 43 | func (t *StopTest) TearDownTestSuite() { 44 | fmt.Println("TearDownTestSuite running.") 45 | } 46 | 47 | //////////////////////////////////////////////////////////////////////// 48 | // Tests 49 | //////////////////////////////////////////////////////////////////////// 50 | 51 | func (t *StopTest) First() { 52 | } 53 | 54 | func (t *StopTest) Second() { 55 | fmt.Println("About to call StopRunningTests.") 56 | StopRunningTests() 57 | fmt.Println("Called StopRunningTests.") 58 | } 59 | 60 | func (t *StopTest) Third() { 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_cases/unexported.test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers_test 17 | 18 | import ( 19 | . "github.com/smartystreets/assertions/internal/oglematchers" 20 | . "github.com/smartystreets/assertions/internal/ogletest" 21 | "testing" 22 | ) 23 | 24 | //////////////////////////////////////////////////////////////////////// 25 | // Helpers 26 | //////////////////////////////////////////////////////////////////////// 27 | 28 | type UnexportedTest struct { 29 | } 30 | 31 | func init() { RegisterTestSuite(&UnexportedTest{}) } 32 | func TestUnexportedTest(t *testing.T) { RunTests(t) } 33 | 34 | func (t *UnexportedTest) someUnexportedMethod() { 35 | } 36 | 37 | //////////////////////////////////////////////////////////////////////// 38 | // Tests 39 | //////////////////////////////////////////////////////////////////////// 40 | 41 | func (t *UnexportedTest) SomeTest() { 42 | ExpectThat(3, Equals(4)) 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/ogletest/test_info.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package ogletest 17 | 18 | import ( 19 | "sync" 20 | 21 | "golang.org/x/net/context" 22 | 23 | "github.com/smartystreets/assertions/internal/oglemock" 24 | ) 25 | 26 | // TestInfo represents information about a currently running or previously-run 27 | // test. 28 | type TestInfo struct { 29 | // A mock controller that is set up to report errors to the ogletest test 30 | // runner. This can be used for setting up mock expectations and handling 31 | // mock calls. The Finish method should not be run by the user; ogletest will 32 | // do that automatically after the test's TearDown method is run. 33 | // 34 | // Note that this feature is still experimental, and is subject to change. 35 | MockController oglemock.Controller 36 | 37 | // A context that can be used by tests for long-running operations. In 38 | // particular, this enables conveniently tracing the execution of a test 39 | // function with reqtrace. 40 | Ctx context.Context 41 | 42 | // A mutex protecting shared state. 43 | mu sync.RWMutex 44 | 45 | // A set of failure records that the test has produced. 46 | // 47 | // GUARDED_BY(mu) 48 | failureRecords []FailureRecord 49 | } 50 | 51 | // currentlyRunningTest is the state for the currently running test, if any. 52 | var currentlyRunningTest *TestInfo 53 | 54 | // newTestInfo creates a valid but empty TestInfo struct. 55 | func newTestInfo() (info *TestInfo) { 56 | info = &TestInfo{} 57 | info.MockController = oglemock.NewController(&testInfoErrorReporter{info}) 58 | info.Ctx = context.Background() 59 | 60 | return 61 | } 62 | 63 | // testInfoErrorReporter is an oglemock.ErrorReporter that writes failure 64 | // records into a test info struct. 65 | type testInfoErrorReporter struct { 66 | testInfo *TestInfo 67 | } 68 | 69 | func (r *testInfoErrorReporter) ReportError( 70 | fileName string, 71 | lineNumber int, 72 | err error) { 73 | r.testInfo.mu.Lock() 74 | defer r.testInfo.mu.Unlock() 75 | 76 | record := FailureRecord{ 77 | FileName: fileName, 78 | LineNumber: lineNumber, 79 | Error: err.Error(), 80 | } 81 | 82 | r.testInfo.failureRecords = append(r.testInfo.failureRecords, record) 83 | } 84 | 85 | func (r *testInfoErrorReporter) ReportFatalError( 86 | fileName string, 87 | lineNumber int, 88 | err error) { 89 | r.ReportError(fileName, lineNumber, err) 90 | AbortTest() 91 | } 92 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/reqtrace/.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files, Static and Dynamic libs (Shared Objects) 2 | *.o 3 | *.a 4 | *.so 5 | 6 | # Folders 7 | _obj 8 | _test 9 | 10 | # Architecture specific extensions/prefixes 11 | *.[568vq] 12 | [568vq].out 13 | 14 | *.cgo1.go 15 | *.cgo2.c 16 | _cgo_defun.c 17 | _cgo_gotypes.go 18 | _cgo_export.* 19 | 20 | _testmain.go 21 | 22 | *.exe 23 | *.test 24 | *.prof 25 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/reqtrace/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/reqtrace?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/reqtrace) 2 | 3 | reqtrace is a package for simple request tracing. It requires nothing of its 4 | user except: 5 | 6 | * They must use [golang.org/x/net/context][context]. 7 | * They must add a single line to each function they want to be visible in 8 | traces. 9 | 10 | [context]: http://godoc.org/golang.org/x/net/context 11 | 12 | In particular, reqtrace is console-based and doesn't require an HTTP server. 13 | 14 | **Warning**: This package is still barebones and in its early days. I reserve 15 | the right to make backwards-incompatible changes to its API. But if it's useful 16 | to you in your current form, have at it. 17 | 18 | ## Use 19 | 20 | Call reqtrace.Trace anywhere you want to start a new root trace. (This is 21 | probably where you create your root context.) This returns a new context that 22 | you should pass to child operations, and a reporting function that you must use 23 | to inform reqtrace when the trace is complete. 24 | 25 | For example: 26 | 27 | ```Go 28 | func HandleRequest(r *someRequest) (err error) { 29 | ctx, report := reqtrace.Trace(context.Background(), "HandleRequest") 30 | defer func() { report(err) }() 31 | 32 | // Do two things for this request. 33 | DoSomething(ctx, r) 34 | DoSomethingElse(ctx, r) 35 | } 36 | ``` 37 | 38 | Within other functions that you want to show up in the trace, you 39 | reqtrace.StartSpan (or its more convenient sibling reqtrace.StartSpanWithError): 40 | 41 | ```Go 42 | func DoSomething(ctx context.Context, r *someRequest) (err error) { 43 | defer reqtrace.StartSpanWithError(&ctx, &err, "DoSomething")() 44 | 45 | // Process the request somehow using ctx. If downstream code also annotes 46 | // using reqtrace, reqtrace will know that its spans are descendants of 47 | // this one. 48 | CallAnotherLibrary(ctx, r.Param) 49 | } 50 | ``` 51 | 52 | When `--reqtrace.enable` is set, the completion of a trace will cause helpful 53 | ASCII art to be spit out. 54 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/panic.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | // ShouldPanic receives a void, niladic function and expects to recover a panic. 6 | func ShouldPanic(actual interface{}, expected ...interface{}) (message string) { 7 | if fail := need(0, expected); fail != success { 8 | return fail 9 | } 10 | 11 | action, _ := actual.(func()) 12 | 13 | if action == nil { 14 | message = shouldUseVoidNiladicFunction 15 | return 16 | } 17 | 18 | defer func() { 19 | recovered := recover() 20 | if recovered == nil { 21 | message = shouldHavePanicked 22 | } else { 23 | message = success 24 | } 25 | }() 26 | action() 27 | 28 | return 29 | } 30 | 31 | // ShouldNotPanic receives a void, niladic function and expects to execute the function without any panic. 32 | func ShouldNotPanic(actual interface{}, expected ...interface{}) (message string) { 33 | if fail := need(0, expected); fail != success { 34 | return fail 35 | } 36 | 37 | action, _ := actual.(func()) 38 | 39 | if action == nil { 40 | message = shouldUseVoidNiladicFunction 41 | return 42 | } 43 | 44 | defer func() { 45 | recovered := recover() 46 | if recovered != nil { 47 | message = fmt.Sprintf(shouldNotHavePanicked, recovered) 48 | } else { 49 | message = success 50 | } 51 | }() 52 | action() 53 | 54 | return 55 | } 56 | 57 | // ShouldPanicWith receives a void, niladic function and expects to recover a panic with the second argument as the content. 58 | func ShouldPanicWith(actual interface{}, expected ...interface{}) (message string) { 59 | if fail := need(1, expected); fail != success { 60 | return fail 61 | } 62 | 63 | action, _ := actual.(func()) 64 | 65 | if action == nil { 66 | message = shouldUseVoidNiladicFunction 67 | return 68 | } 69 | 70 | defer func() { 71 | recovered := recover() 72 | if recovered == nil { 73 | message = shouldHavePanicked 74 | } else { 75 | if equal := ShouldEqual(recovered, expected[0]); equal != success { 76 | message = serializer.serialize(expected[0], recovered, fmt.Sprintf(shouldHavePanickedWith, expected[0], recovered)) 77 | } else { 78 | message = success 79 | } 80 | } 81 | }() 82 | action() 83 | 84 | return 85 | } 86 | 87 | // ShouldNotPanicWith receives a void, niladic function and expects to recover a panic whose content differs from the second argument. 88 | func ShouldNotPanicWith(actual interface{}, expected ...interface{}) (message string) { 89 | if fail := need(1, expected); fail != success { 90 | return fail 91 | } 92 | 93 | action, _ := actual.(func()) 94 | 95 | if action == nil { 96 | message = shouldUseVoidNiladicFunction 97 | return 98 | } 99 | 100 | defer func() { 101 | recovered := recover() 102 | if recovered == nil { 103 | message = success 104 | } else { 105 | if equal := ShouldEqual(recovered, expected[0]); equal == success { 106 | message = fmt.Sprintf(shouldNotHavePanickedWith, expected[0]) 107 | } else { 108 | message = success 109 | } 110 | } 111 | }() 112 | action() 113 | 114 | return 115 | } 116 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/serializer.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/smartystreets/goconvey/convey/reporting" 8 | ) 9 | 10 | type Serializer interface { 11 | serialize(expected, actual interface{}, message string) string 12 | serializeDetailed(expected, actual interface{}, message string) string 13 | } 14 | 15 | type failureSerializer struct{} 16 | 17 | func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { 18 | view := self.format(expected, actual, message, "%#v") 19 | serialized, err := json.Marshal(view) 20 | if err != nil { 21 | return message 22 | } 23 | return string(serialized) 24 | } 25 | 26 | func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { 27 | view := self.format(expected, actual, message, "%+v") 28 | serialized, err := json.Marshal(view) 29 | if err != nil { 30 | return message 31 | } 32 | return string(serialized) 33 | } 34 | 35 | func (self *failureSerializer) format(expected, actual interface{}, message string, format string) reporting.FailureView { 36 | return reporting.FailureView{ 37 | Message: message, 38 | Expected: fmt.Sprintf(format, expected), 39 | Actual: fmt.Sprintf(format, actual), 40 | } 41 | } 42 | 43 | func newSerializer() *failureSerializer { 44 | return &failureSerializer{} 45 | } 46 | 47 | /////////////////////////////////////////////////////// 48 | 49 | // noopSerializer just gives back the original message. This is useful when we are using 50 | // the assertions from a context other than the web UI, that requires the JSON structure 51 | // provided by the failureSerializer. 52 | type noopSerializer struct{} 53 | 54 | func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { 55 | return message 56 | } 57 | func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { 58 | return message 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/should/should.go: -------------------------------------------------------------------------------- 1 | // package should is simply a rewording of the assertion 2 | // functions in the assertions package. 3 | package should 4 | 5 | import "github.com/smartystreets/assertions" 6 | 7 | var ( 8 | Equal = assertions.ShouldEqual 9 | NotEqual = assertions.ShouldNotEqual 10 | AlmostEqual = assertions.ShouldAlmostEqual 11 | NotAlmostEqual = assertions.ShouldNotAlmostEqual 12 | Resemble = assertions.ShouldResemble 13 | NotResemble = assertions.ShouldNotResemble 14 | PointTo = assertions.ShouldPointTo 15 | NotPointTo = assertions.ShouldNotPointTo 16 | BeNil = assertions.ShouldBeNil 17 | NotBeNil = assertions.ShouldNotBeNil 18 | BeTrue = assertions.ShouldBeTrue 19 | BeFalse = assertions.ShouldBeFalse 20 | BeZeroValue = assertions.ShouldBeZeroValue 21 | 22 | BeGreaterThan = assertions.ShouldBeGreaterThan 23 | BeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo 24 | BeLessThan = assertions.ShouldBeLessThan 25 | BeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo 26 | BeBetween = assertions.ShouldBeBetween 27 | NotBeBetween = assertions.ShouldNotBeBetween 28 | BeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual 29 | NotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual 30 | 31 | Contain = assertions.ShouldContain 32 | NotContain = assertions.ShouldNotContain 33 | ContainKey = assertions.ShouldContainKey 34 | NotContainKey = assertions.ShouldNotContainKey 35 | BeIn = assertions.ShouldBeIn 36 | NotBeIn = assertions.ShouldNotBeIn 37 | BeEmpty = assertions.ShouldBeEmpty 38 | NotBeEmpty = assertions.ShouldNotBeEmpty 39 | HaveLength = assertions.ShouldHaveLength 40 | 41 | StartWith = assertions.ShouldStartWith 42 | NotStartWith = assertions.ShouldNotStartWith 43 | EndWith = assertions.ShouldEndWith 44 | NotEndWith = assertions.ShouldNotEndWith 45 | BeBlank = assertions.ShouldBeBlank 46 | NotBeBlank = assertions.ShouldNotBeBlank 47 | ContainSubstring = assertions.ShouldContainSubstring 48 | NotContainSubstring = assertions.ShouldNotContainSubstring 49 | 50 | EqualWithout = assertions.ShouldEqualWithout 51 | EqualTrimSpace = assertions.ShouldEqualTrimSpace 52 | 53 | Panic = assertions.ShouldPanic 54 | NotPanic = assertions.ShouldNotPanic 55 | PanicWith = assertions.ShouldPanicWith 56 | NotPanicWith = assertions.ShouldNotPanicWith 57 | 58 | HaveSameTypeAs = assertions.ShouldHaveSameTypeAs 59 | NotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs 60 | Implement = assertions.ShouldImplement 61 | NotImplement = assertions.ShouldNotImplement 62 | 63 | HappenBefore = assertions.ShouldHappenBefore 64 | HappenOnOrBefore = assertions.ShouldHappenOnOrBefore 65 | HappenAfter = assertions.ShouldHappenAfter 66 | HappenOnOrAfter = assertions.ShouldHappenOnOrAfter 67 | HappenBetween = assertions.ShouldHappenBetween 68 | HappenOnOrBetween = assertions.ShouldHappenOnOrBetween 69 | NotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween 70 | HappenWithin = assertions.ShouldHappenWithin 71 | NotHappenWithin = assertions.ShouldNotHappenWithin 72 | BeChronological = assertions.ShouldBeChronological 73 | ) 74 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/type.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | // ShouldHaveSameTypeAs receives exactly two parameters and compares their underlying types for equality. 9 | func ShouldHaveSameTypeAs(actual interface{}, expected ...interface{}) string { 10 | if fail := need(1, expected); fail != success { 11 | return fail 12 | } 13 | 14 | first := reflect.TypeOf(actual) 15 | second := reflect.TypeOf(expected[0]) 16 | 17 | if equal := ShouldEqual(first, second); equal != success { 18 | return serializer.serialize(second, first, fmt.Sprintf(shouldHaveBeenA, actual, second, first)) 19 | } 20 | return success 21 | } 22 | 23 | // ShouldNotHaveSameTypeAs receives exactly two parameters and compares their underlying types for inequality. 24 | func ShouldNotHaveSameTypeAs(actual interface{}, expected ...interface{}) string { 25 | if fail := need(1, expected); fail != success { 26 | return fail 27 | } 28 | 29 | first := reflect.TypeOf(actual) 30 | second := reflect.TypeOf(expected[0]) 31 | 32 | if equal := ShouldEqual(first, second); equal == success { 33 | return fmt.Sprintf(shouldNotHaveBeenA, actual, second) 34 | } 35 | return success 36 | } 37 | 38 | // ShouldImplement receives exactly two parameters and ensures 39 | // that the first implements the interface type of the second. 40 | func ShouldImplement(actual interface{}, expectedList ...interface{}) string { 41 | if fail := need(1, expectedList); fail != success { 42 | return fail 43 | } 44 | 45 | expected := expectedList[0] 46 | if fail := ShouldBeNil(expected); fail != success { 47 | return shouldCompareWithInterfacePointer 48 | } 49 | 50 | if fail := ShouldNotBeNil(actual); fail != success { 51 | return shouldNotBeNilActual 52 | } 53 | 54 | var actualType reflect.Type 55 | if reflect.TypeOf(actual).Kind() != reflect.Ptr { 56 | actualType = reflect.PtrTo(reflect.TypeOf(actual)) 57 | } else { 58 | actualType = reflect.TypeOf(actual) 59 | } 60 | 61 | expectedType := reflect.TypeOf(expected) 62 | if fail := ShouldNotBeNil(expectedType); fail != success { 63 | return shouldCompareWithInterfacePointer 64 | } 65 | 66 | expectedInterface := expectedType.Elem() 67 | 68 | if actualType == nil { 69 | return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actual) 70 | } 71 | 72 | if !actualType.Implements(expectedInterface) { 73 | return fmt.Sprintf(shouldHaveImplemented, expectedInterface, actualType) 74 | } 75 | return success 76 | } 77 | 78 | // ShouldNotImplement receives exactly two parameters and ensures 79 | // that the first does NOT implement the interface type of the second. 80 | func ShouldNotImplement(actual interface{}, expectedList ...interface{}) string { 81 | if fail := need(1, expectedList); fail != success { 82 | return fail 83 | } 84 | 85 | expected := expectedList[0] 86 | if fail := ShouldBeNil(expected); fail != success { 87 | return shouldCompareWithInterfacePointer 88 | } 89 | 90 | if fail := ShouldNotBeNil(actual); fail != success { 91 | return shouldNotBeNilActual 92 | } 93 | 94 | var actualType reflect.Type 95 | if reflect.TypeOf(actual).Kind() != reflect.Ptr { 96 | actualType = reflect.PtrTo(reflect.TypeOf(actual)) 97 | } else { 98 | actualType = reflect.TypeOf(actual) 99 | } 100 | 101 | expectedType := reflect.TypeOf(expected) 102 | if fail := ShouldNotBeNil(expectedType); fail != success { 103 | return shouldCompareWithInterfacePointer 104 | } 105 | 106 | expectedInterface := expectedType.Elem() 107 | 108 | if actualType.Implements(expectedInterface) { 109 | return fmt.Sprintf(shouldNotHaveImplemented, actualType, expectedInterface) 110 | } 111 | return success 112 | } 113 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/assertions.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import "github.com/smartystreets/assertions" 4 | 5 | var ( 6 | ShouldEqual = assertions.ShouldEqual 7 | ShouldNotEqual = assertions.ShouldNotEqual 8 | ShouldAlmostEqual = assertions.ShouldAlmostEqual 9 | ShouldNotAlmostEqual = assertions.ShouldNotAlmostEqual 10 | ShouldResemble = assertions.ShouldResemble 11 | ShouldNotResemble = assertions.ShouldNotResemble 12 | ShouldPointTo = assertions.ShouldPointTo 13 | ShouldNotPointTo = assertions.ShouldNotPointTo 14 | ShouldBeNil = assertions.ShouldBeNil 15 | ShouldNotBeNil = assertions.ShouldNotBeNil 16 | ShouldBeTrue = assertions.ShouldBeTrue 17 | ShouldBeFalse = assertions.ShouldBeFalse 18 | ShouldBeZeroValue = assertions.ShouldBeZeroValue 19 | 20 | ShouldBeGreaterThan = assertions.ShouldBeGreaterThan 21 | ShouldBeGreaterThanOrEqualTo = assertions.ShouldBeGreaterThanOrEqualTo 22 | ShouldBeLessThan = assertions.ShouldBeLessThan 23 | ShouldBeLessThanOrEqualTo = assertions.ShouldBeLessThanOrEqualTo 24 | ShouldBeBetween = assertions.ShouldBeBetween 25 | ShouldNotBeBetween = assertions.ShouldNotBeBetween 26 | ShouldBeBetweenOrEqual = assertions.ShouldBeBetweenOrEqual 27 | ShouldNotBeBetweenOrEqual = assertions.ShouldNotBeBetweenOrEqual 28 | 29 | ShouldContain = assertions.ShouldContain 30 | ShouldNotContain = assertions.ShouldNotContain 31 | ShouldContainKey = assertions.ShouldContainKey 32 | ShouldNotContainKey = assertions.ShouldNotContainKey 33 | ShouldBeIn = assertions.ShouldBeIn 34 | ShouldNotBeIn = assertions.ShouldNotBeIn 35 | ShouldBeEmpty = assertions.ShouldBeEmpty 36 | ShouldNotBeEmpty = assertions.ShouldNotBeEmpty 37 | ShouldHaveLength = assertions.ShouldHaveLength 38 | 39 | ShouldStartWith = assertions.ShouldStartWith 40 | ShouldNotStartWith = assertions.ShouldNotStartWith 41 | ShouldEndWith = assertions.ShouldEndWith 42 | ShouldNotEndWith = assertions.ShouldNotEndWith 43 | ShouldBeBlank = assertions.ShouldBeBlank 44 | ShouldNotBeBlank = assertions.ShouldNotBeBlank 45 | ShouldContainSubstring = assertions.ShouldContainSubstring 46 | ShouldNotContainSubstring = assertions.ShouldNotContainSubstring 47 | 48 | ShouldPanic = assertions.ShouldPanic 49 | ShouldNotPanic = assertions.ShouldNotPanic 50 | ShouldPanicWith = assertions.ShouldPanicWith 51 | ShouldNotPanicWith = assertions.ShouldNotPanicWith 52 | 53 | ShouldHaveSameTypeAs = assertions.ShouldHaveSameTypeAs 54 | ShouldNotHaveSameTypeAs = assertions.ShouldNotHaveSameTypeAs 55 | ShouldImplement = assertions.ShouldImplement 56 | ShouldNotImplement = assertions.ShouldNotImplement 57 | 58 | ShouldHappenBefore = assertions.ShouldHappenBefore 59 | ShouldHappenOnOrBefore = assertions.ShouldHappenOnOrBefore 60 | ShouldHappenAfter = assertions.ShouldHappenAfter 61 | ShouldHappenOnOrAfter = assertions.ShouldHappenOnOrAfter 62 | ShouldHappenBetween = assertions.ShouldHappenBetween 63 | ShouldHappenOnOrBetween = assertions.ShouldHappenOnOrBetween 64 | ShouldNotHappenOnOrBetween = assertions.ShouldNotHappenOnOrBetween 65 | ShouldHappenWithin = assertions.ShouldHappenWithin 66 | ShouldNotHappenWithin = assertions.ShouldNotHappenWithin 67 | ShouldBeChronological = assertions.ShouldBeChronological 68 | ) 69 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/convey.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | #-covermode=count 4 | #-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/discovery.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | type actionSpecifier uint8 4 | 5 | const ( 6 | noSpecifier actionSpecifier = iota 7 | skipConvey 8 | focusConvey 9 | ) 10 | 11 | type suite struct { 12 | Situation string 13 | Test t 14 | Focus bool 15 | Func func(C) // nil means skipped 16 | FailMode FailureMode 17 | } 18 | 19 | func newSuite(situation string, failureMode FailureMode, f func(C), test t, specifier actionSpecifier) *suite { 20 | ret := &suite{ 21 | Situation: situation, 22 | Test: test, 23 | Func: f, 24 | FailMode: failureMode, 25 | } 26 | switch specifier { 27 | case skipConvey: 28 | ret.Func = nil 29 | case focusConvey: 30 | ret.Focus = true 31 | } 32 | return ret 33 | } 34 | 35 | func discover(items []interface{}) *suite { 36 | name, items := parseName(items) 37 | test, items := parseGoTest(items) 38 | failure, items := parseFailureMode(items) 39 | action, items := parseAction(items) 40 | specifier, items := parseSpecifier(items) 41 | 42 | if len(items) != 0 { 43 | conveyPanic(parseError) 44 | } 45 | 46 | return newSuite(name, failure, action, test, specifier) 47 | } 48 | func item(items []interface{}) interface{} { 49 | if len(items) == 0 { 50 | conveyPanic(parseError) 51 | } 52 | return items[0] 53 | } 54 | func parseName(items []interface{}) (string, []interface{}) { 55 | if name, parsed := item(items).(string); parsed { 56 | return name, items[1:] 57 | } 58 | conveyPanic(parseError) 59 | panic("never get here") 60 | } 61 | func parseGoTest(items []interface{}) (t, []interface{}) { 62 | if test, parsed := item(items).(t); parsed { 63 | return test, items[1:] 64 | } 65 | return nil, items 66 | } 67 | func parseFailureMode(items []interface{}) (FailureMode, []interface{}) { 68 | if mode, parsed := item(items).(FailureMode); parsed { 69 | return mode, items[1:] 70 | } 71 | return FailureInherits, items 72 | } 73 | func parseAction(items []interface{}) (func(C), []interface{}) { 74 | switch x := item(items).(type) { 75 | case nil: 76 | return nil, items[1:] 77 | case func(C): 78 | return x, items[1:] 79 | case func(): 80 | return func(C) { x() }, items[1:] 81 | } 82 | conveyPanic(parseError) 83 | panic("never get here") 84 | } 85 | func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) { 86 | if len(items) == 0 { 87 | return noSpecifier, items 88 | } 89 | if spec, ok := items[0].(actionSpecifier); ok { 90 | return spec, items[1:] 91 | } 92 | conveyPanic(parseError) 93 | panic("never get here") 94 | } 95 | 96 | // This interface allows us to pass the *testing.T struct 97 | // throughout the internals of this package without ever 98 | // having to import the "testing" package. 99 | type t interface { 100 | Fail() 101 | } 102 | 103 | const parseError = "You must provide a name (string), then a *testing.T (if in outermost scope), an optional FailureMode, and then an action (func())." 104 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go: -------------------------------------------------------------------------------- 1 | // Package gotest contains internal functionality. Although this package 2 | // contains one or more exported names it is not intended for public 3 | // consumption. See the examples package for how to use this project. 4 | package gotest 5 | 6 | import ( 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | func ResolveExternalCaller() (file string, line int, name string) { 12 | var caller_id uintptr 13 | callers := runtime.Callers(0, callStack) 14 | 15 | for x := 0; x < callers; x++ { 16 | caller_id, file, line, _ = runtime.Caller(x) 17 | if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { 18 | name = runtime.FuncForPC(caller_id).Name() 19 | return 20 | } 21 | } 22 | file, line, name = "", -1, "" 23 | return // panic? 24 | } 25 | 26 | const maxStackDepth = 100 // This had better be enough... 27 | 28 | var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) 29 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/init.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | "github.com/jtolds/gls" 8 | "github.com/smartystreets/assertions" 9 | "github.com/smartystreets/goconvey/convey/reporting" 10 | ) 11 | 12 | func init() { 13 | assertions.GoConveyMode(true) 14 | 15 | declareFlags() 16 | 17 | ctxMgr = gls.NewContextManager() 18 | } 19 | 20 | func declareFlags() { 21 | flag.BoolVar(&json, "json", false, "When true, emits results in JSON blocks. Default: 'false'") 22 | flag.BoolVar(&silent, "silent", false, "When true, all output from GoConvey is suppressed.") 23 | flag.BoolVar(&story, "story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") 24 | 25 | if noStoryFlagProvided() { 26 | story = verboseEnabled 27 | } 28 | 29 | // FYI: flag.Parse() is called from the testing package. 30 | } 31 | 32 | func noStoryFlagProvided() bool { 33 | return !story && !storyDisabled 34 | } 35 | 36 | func buildReporter() reporting.Reporter { 37 | switch { 38 | case testReporter != nil: 39 | return testReporter 40 | case json: 41 | return reporting.BuildJsonReporter() 42 | case silent: 43 | return reporting.BuildSilentReporter() 44 | case story: 45 | return reporting.BuildStoryReporter() 46 | default: 47 | return reporting.BuildDotReporter() 48 | } 49 | } 50 | 51 | var ( 52 | ctxMgr *gls.ContextManager 53 | 54 | // only set by internal tests 55 | testReporter reporting.Reporter 56 | ) 57 | 58 | var ( 59 | json bool 60 | silent bool 61 | story bool 62 | 63 | verboseEnabled = flagFound("-test.v=true") 64 | storyDisabled = flagFound("-story=false") 65 | ) 66 | 67 | // flagFound parses the command line args manually for flags defined in other 68 | // packages. Like the '-v' flag from the "testing" package, for instance. 69 | func flagFound(flagValue string) bool { 70 | for _, arg := range os.Args { 71 | if arg == flagValue { 72 | return true 73 | } 74 | } 75 | return false 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/nilReporter.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "github.com/smartystreets/goconvey/convey/reporting" 5 | ) 6 | 7 | type nilReporter struct{} 8 | 9 | func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} 10 | func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} 11 | func (self *nilReporter) Report(report *reporting.AssertionResult) {} 12 | func (self *nilReporter) Exit() {} 13 | func (self *nilReporter) EndStory() {} 14 | func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } 15 | func newNilReporter() *nilReporter { return &nilReporter{} } 16 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/console.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type console struct{} 9 | 10 | func (self *console) Write(p []byte) (n int, err error) { 11 | return fmt.Print(string(p)) 12 | } 13 | 14 | func NewConsole() io.Writer { 15 | return new(console) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go: -------------------------------------------------------------------------------- 1 | // Package reporting contains internal functionality related 2 | // to console reporting and output. Although this package has 3 | // exported names is not intended for public consumption. See the 4 | // examples package for how to use this project. 5 | package reporting 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type dot struct{ out *Printer } 6 | 7 | func (self *dot) BeginStory(story *StoryReport) {} 8 | 9 | func (self *dot) Enter(scope *ScopeReport) {} 10 | 11 | func (self *dot) Report(report *AssertionResult) { 12 | if report.Error != nil { 13 | fmt.Print(redColor) 14 | self.out.Insert(dotError) 15 | } else if report.Failure != "" { 16 | fmt.Print(yellowColor) 17 | self.out.Insert(dotFailure) 18 | } else if report.Skipped { 19 | fmt.Print(yellowColor) 20 | self.out.Insert(dotSkip) 21 | } else { 22 | fmt.Print(greenColor) 23 | self.out.Insert(dotSuccess) 24 | } 25 | fmt.Print(resetColor) 26 | } 27 | 28 | func (self *dot) Exit() {} 29 | 30 | func (self *dot) EndStory() {} 31 | 32 | func (self *dot) Write(content []byte) (written int, err error) { 33 | return len(content), nil // no-op 34 | } 35 | 36 | func NewDotReporter(out *Printer) *dot { 37 | self := new(dot) 38 | self.out = out 39 | return self 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | type gotestReporter struct{ test T } 4 | 5 | func (self *gotestReporter) BeginStory(story *StoryReport) { 6 | self.test = story.Test 7 | } 8 | 9 | func (self *gotestReporter) Enter(scope *ScopeReport) {} 10 | 11 | func (self *gotestReporter) Report(r *AssertionResult) { 12 | if !passed(r) { 13 | self.test.Fail() 14 | } 15 | } 16 | 17 | func (self *gotestReporter) Exit() {} 18 | 19 | func (self *gotestReporter) EndStory() { 20 | self.test = nil 21 | } 22 | 23 | func (self *gotestReporter) Write(content []byte) (written int, err error) { 24 | return len(content), nil // no-op 25 | } 26 | 27 | func NewGoTestReporter() *gotestReporter { 28 | return new(gotestReporter) 29 | } 30 | 31 | func passed(r *AssertionResult) bool { 32 | return r.Error == nil && r.Failure == "" 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/init.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | func init() { 11 | if !isXterm() { 12 | monochrome() 13 | } 14 | 15 | if runtime.GOOS == "windows" { 16 | success, failure, error_ = dotSuccess, dotFailure, dotError 17 | } 18 | } 19 | 20 | func BuildJsonReporter() Reporter { 21 | out := NewPrinter(NewConsole()) 22 | return NewReporters( 23 | NewGoTestReporter(), 24 | NewJsonReporter(out)) 25 | } 26 | func BuildDotReporter() Reporter { 27 | out := NewPrinter(NewConsole()) 28 | return NewReporters( 29 | NewGoTestReporter(), 30 | NewDotReporter(out), 31 | NewProblemReporter(out), 32 | consoleStatistics) 33 | } 34 | func BuildStoryReporter() Reporter { 35 | out := NewPrinter(NewConsole()) 36 | return NewReporters( 37 | NewGoTestReporter(), 38 | NewStoryReporter(out), 39 | NewProblemReporter(out), 40 | consoleStatistics) 41 | } 42 | func BuildSilentReporter() Reporter { 43 | out := NewPrinter(NewConsole()) 44 | return NewReporters( 45 | NewGoTestReporter(), 46 | NewProblemReporter(out)) 47 | } 48 | 49 | var ( 50 | newline = "\n" 51 | success = "✔" 52 | failure = "✘" 53 | error_ = "🔥" 54 | skip = "⚠" 55 | dotSuccess = "." 56 | dotFailure = "x" 57 | dotError = "E" 58 | dotSkip = "S" 59 | errorTemplate = "* %s \nLine %d: - %v \n%s\n" 60 | failureTemplate = "* %s \nLine %d:\n%s\n" 61 | ) 62 | 63 | var ( 64 | greenColor = "\033[32m" 65 | yellowColor = "\033[33m" 66 | redColor = "\033[31m" 67 | resetColor = "\033[0m" 68 | ) 69 | 70 | var consoleStatistics = NewStatisticsReporter(NewPrinter(NewConsole())) 71 | 72 | func SuppressConsoleStatistics() { consoleStatistics.Suppress() } 73 | func PrintConsoleStatistics() { consoleStatistics.PrintSummary() } 74 | 75 | // QuiteMode disables all console output symbols. This is only meant to be used 76 | // for tests that are internal to goconvey where the output is distracting or 77 | // otherwise not needed in the test output. 78 | func QuietMode() { 79 | success, failure, error_, skip, dotSuccess, dotFailure, dotError, dotSkip = "", "", "", "", "", "", "", "" 80 | } 81 | 82 | func monochrome() { 83 | greenColor, yellowColor, redColor, resetColor = "", "", "", "" 84 | } 85 | 86 | func isXterm() bool { 87 | env := fmt.Sprintf("%v", os.Environ()) 88 | return strings.Contains(env, " TERM=isXterm") || 89 | strings.Contains(env, " TERM=xterm") 90 | } 91 | 92 | // This interface allows us to pass the *testing.T struct 93 | // throughout the internals of this tool without ever 94 | // having to import the "testing" package. 95 | type T interface { 96 | Fail() 97 | } 98 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/json.go: -------------------------------------------------------------------------------- 1 | // TODO: under unit test 2 | 3 | package reporting 4 | 5 | import ( 6 | "bytes" 7 | "encoding/json" 8 | "fmt" 9 | "strings" 10 | ) 11 | 12 | type JsonReporter struct { 13 | out *Printer 14 | currentKey []string 15 | current *ScopeResult 16 | index map[string]*ScopeResult 17 | scopes []*ScopeResult 18 | } 19 | 20 | func (self *JsonReporter) depth() int { return len(self.currentKey) } 21 | 22 | func (self *JsonReporter) BeginStory(story *StoryReport) {} 23 | 24 | func (self *JsonReporter) Enter(scope *ScopeReport) { 25 | self.currentKey = append(self.currentKey, scope.Title) 26 | ID := strings.Join(self.currentKey, "|") 27 | if _, found := self.index[ID]; !found { 28 | next := newScopeResult(scope.Title, self.depth(), scope.File, scope.Line) 29 | self.scopes = append(self.scopes, next) 30 | self.index[ID] = next 31 | } 32 | self.current = self.index[ID] 33 | } 34 | 35 | func (self *JsonReporter) Report(report *AssertionResult) { 36 | self.current.Assertions = append(self.current.Assertions, report) 37 | } 38 | 39 | func (self *JsonReporter) Exit() { 40 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 41 | } 42 | 43 | func (self *JsonReporter) EndStory() { 44 | self.report() 45 | self.reset() 46 | } 47 | func (self *JsonReporter) report() { 48 | scopes := []string{} 49 | for _, scope := range self.scopes { 50 | serialized, err := json.Marshal(scope) 51 | if err != nil { 52 | self.out.Println(jsonMarshalFailure) 53 | panic(err) 54 | } 55 | var buffer bytes.Buffer 56 | json.Indent(&buffer, serialized, "", " ") 57 | scopes = append(scopes, buffer.String()) 58 | } 59 | self.out.Print(fmt.Sprintf("%s\n%s,\n%s\n", OpenJson, strings.Join(scopes, ","), CloseJson)) 60 | } 61 | func (self *JsonReporter) reset() { 62 | self.scopes = []*ScopeResult{} 63 | self.index = map[string]*ScopeResult{} 64 | self.currentKey = nil 65 | } 66 | 67 | func (self *JsonReporter) Write(content []byte) (written int, err error) { 68 | self.current.Output += string(content) 69 | return len(content), nil 70 | } 71 | 72 | func NewJsonReporter(out *Printer) *JsonReporter { 73 | self := new(JsonReporter) 74 | self.out = out 75 | self.reset() 76 | return self 77 | } 78 | 79 | const OpenJson = ">->->OPEN-JSON->->->" // "⌦" 80 | const CloseJson = "<-<-<-CLOSE-JSON<-<-<" // "⌫" 81 | const jsonMarshalFailure = ` 82 | 83 | GOCONVEY_JSON_MARSHALL_FAILURE: There was an error when attempting to convert test results to JSON. 84 | Please file a bug report and reference the code that caused this failure if possible. 85 | 86 | Here's the panic: 87 | 88 | ` 89 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "strings" 7 | ) 8 | 9 | type Printer struct { 10 | out io.Writer 11 | prefix string 12 | } 13 | 14 | func (self *Printer) Println(message string, values ...interface{}) { 15 | formatted := self.format(message, values...) + newline 16 | self.out.Write([]byte(formatted)) 17 | } 18 | 19 | func (self *Printer) Print(message string, values ...interface{}) { 20 | formatted := self.format(message, values...) 21 | self.out.Write([]byte(formatted)) 22 | } 23 | 24 | func (self *Printer) Insert(text string) { 25 | self.out.Write([]byte(text)) 26 | } 27 | 28 | func (self *Printer) format(message string, values ...interface{}) string { 29 | var formatted string 30 | if len(values) == 0 { 31 | formatted = self.prefix + message 32 | } else { 33 | formatted = self.prefix + fmt.Sprintf(message, values...) 34 | } 35 | indented := strings.Replace(formatted, newline, newline+self.prefix, -1) 36 | return strings.TrimRight(indented, space) 37 | } 38 | 39 | func (self *Printer) Indent() { 40 | self.prefix += pad 41 | } 42 | 43 | func (self *Printer) Dedent() { 44 | if len(self.prefix) >= padLength { 45 | self.prefix = self.prefix[:len(self.prefix)-padLength] 46 | } 47 | } 48 | 49 | func NewPrinter(out io.Writer) *Printer { 50 | self := new(Printer) 51 | self.out = out 52 | return self 53 | } 54 | 55 | const space = " " 56 | const pad = space + space 57 | const padLength = len(pad) 58 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type problem struct { 6 | out *Printer 7 | errors []*AssertionResult 8 | failures []*AssertionResult 9 | } 10 | 11 | func (self *problem) BeginStory(story *StoryReport) {} 12 | 13 | func (self *problem) Enter(scope *ScopeReport) {} 14 | 15 | func (self *problem) Report(report *AssertionResult) { 16 | if report.Error != nil { 17 | self.errors = append(self.errors, report) 18 | } else if report.Failure != "" { 19 | self.failures = append(self.failures, report) 20 | } 21 | } 22 | 23 | func (self *problem) Exit() {} 24 | 25 | func (self *problem) EndStory() { 26 | self.show(self.showErrors, redColor) 27 | self.show(self.showFailures, yellowColor) 28 | self.prepareForNextStory() 29 | } 30 | func (self *problem) show(display func(), color string) { 31 | fmt.Print(color) 32 | display() 33 | fmt.Print(resetColor) 34 | self.out.Dedent() 35 | } 36 | func (self *problem) showErrors() { 37 | for i, e := range self.errors { 38 | if i == 0 { 39 | self.out.Println("\nErrors:\n") 40 | self.out.Indent() 41 | } 42 | self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) 43 | } 44 | } 45 | func (self *problem) showFailures() { 46 | for i, f := range self.failures { 47 | if i == 0 { 48 | self.out.Println("\nFailures:\n") 49 | self.out.Indent() 50 | } 51 | self.out.Println(failureTemplate, f.File, f.Line, f.Failure) 52 | } 53 | } 54 | 55 | func (self *problem) Write(content []byte) (written int, err error) { 56 | return len(content), nil // no-op 57 | } 58 | 59 | func NewProblemReporter(out *Printer) *problem { 60 | self := new(problem) 61 | self.out = out 62 | self.prepareForNextStory() 63 | return self 64 | } 65 | func (self *problem) prepareForNextStory() { 66 | self.errors = []*AssertionResult{} 67 | self.failures = []*AssertionResult{} 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "io" 4 | 5 | type Reporter interface { 6 | BeginStory(story *StoryReport) 7 | Enter(scope *ScopeReport) 8 | Report(r *AssertionResult) 9 | Exit() 10 | EndStory() 11 | io.Writer 12 | } 13 | 14 | type reporters struct{ collection []Reporter } 15 | 16 | func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } 17 | func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } 18 | func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } 19 | func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } 20 | func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } 21 | 22 | func (self *reporters) Write(contents []byte) (written int, err error) { 23 | self.foreach(func(r Reporter) { 24 | written, err = r.Write(contents) 25 | }) 26 | return written, err 27 | } 28 | 29 | func (self *reporters) foreach(action func(Reporter)) { 30 | for _, r := range self.collection { 31 | action(r) 32 | } 33 | } 34 | 35 | func NewReporters(collection ...Reporter) *reporters { 36 | self := new(reporters) 37 | self.collection = collection 38 | return self 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/statistics.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | func (self *statistics) BeginStory(story *StoryReport) {} 6 | 7 | func (self *statistics) Enter(scope *ScopeReport) {} 8 | 9 | func (self *statistics) Report(report *AssertionResult) { 10 | if !self.failing && report.Failure != "" { 11 | self.failing = true 12 | } 13 | if !self.erroring && report.Error != nil { 14 | self.erroring = true 15 | } 16 | if report.Skipped { 17 | self.skipped += 1 18 | } else { 19 | self.total++ 20 | } 21 | } 22 | 23 | func (self *statistics) Exit() {} 24 | 25 | func (self *statistics) EndStory() { 26 | if !self.suppressed { 27 | self.PrintSummary() 28 | } 29 | } 30 | 31 | func (self *statistics) Suppress() { 32 | self.suppressed = true 33 | } 34 | 35 | func (self *statistics) PrintSummary() { 36 | self.reportAssertions() 37 | self.reportSkippedSections() 38 | self.completeReport() 39 | } 40 | func (self *statistics) reportAssertions() { 41 | self.decideColor() 42 | self.out.Print("\n%d total %s", self.total, plural("assertion", self.total)) 43 | } 44 | func (self *statistics) decideColor() { 45 | if self.failing && !self.erroring { 46 | fmt.Print(yellowColor) 47 | } else if self.erroring { 48 | fmt.Print(redColor) 49 | } else { 50 | fmt.Print(greenColor) 51 | } 52 | } 53 | func (self *statistics) reportSkippedSections() { 54 | if self.skipped > 0 { 55 | fmt.Print(yellowColor) 56 | self.out.Print(" (one or more sections skipped)") 57 | } 58 | } 59 | func (self *statistics) completeReport() { 60 | fmt.Print(resetColor) 61 | self.out.Print("\n") 62 | self.out.Print("\n") 63 | } 64 | 65 | func (self *statistics) Write(content []byte) (written int, err error) { 66 | return len(content), nil // no-op 67 | } 68 | 69 | func NewStatisticsReporter(out *Printer) *statistics { 70 | self := statistics{} 71 | self.out = out 72 | return &self 73 | } 74 | 75 | type statistics struct { 76 | out *Printer 77 | total int 78 | failing bool 79 | erroring bool 80 | skipped int 81 | suppressed bool 82 | } 83 | 84 | func plural(word string, count int) string { 85 | if count == 1 { 86 | return word 87 | } 88 | return word + "s" 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/story.go: -------------------------------------------------------------------------------- 1 | // TODO: in order for this reporter to be completely honest 2 | // we need to retrofit to be more like the json reporter such that: 3 | // 1. it maintains ScopeResult collections, which count assertions 4 | // 2. it reports only after EndStory(), so that all tick marks 5 | // are placed near the appropriate title. 6 | // 3. Under unit test 7 | 8 | package reporting 9 | 10 | import ( 11 | "fmt" 12 | "strings" 13 | ) 14 | 15 | type story struct { 16 | out *Printer 17 | titlesById map[string]string 18 | currentKey []string 19 | } 20 | 21 | func (self *story) BeginStory(story *StoryReport) {} 22 | 23 | func (self *story) Enter(scope *ScopeReport) { 24 | self.out.Indent() 25 | 26 | self.currentKey = append(self.currentKey, scope.Title) 27 | ID := strings.Join(self.currentKey, "|") 28 | 29 | if _, found := self.titlesById[ID]; !found { 30 | self.out.Println("") 31 | self.out.Print(scope.Title) 32 | self.out.Insert(" ") 33 | self.titlesById[ID] = scope.Title 34 | } 35 | } 36 | 37 | func (self *story) Report(report *AssertionResult) { 38 | if report.Error != nil { 39 | fmt.Print(redColor) 40 | self.out.Insert(error_) 41 | } else if report.Failure != "" { 42 | fmt.Print(yellowColor) 43 | self.out.Insert(failure) 44 | } else if report.Skipped { 45 | fmt.Print(yellowColor) 46 | self.out.Insert(skip) 47 | } else { 48 | fmt.Print(greenColor) 49 | self.out.Insert(success) 50 | } 51 | fmt.Print(resetColor) 52 | } 53 | 54 | func (self *story) Exit() { 55 | self.out.Dedent() 56 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 57 | } 58 | 59 | func (self *story) EndStory() { 60 | self.titlesById = make(map[string]string) 61 | self.out.Println("\n") 62 | } 63 | 64 | func (self *story) Write(content []byte) (written int, err error) { 65 | return len(content), nil // no-op 66 | } 67 | 68 | func NewStoryReporter(out *Printer) *story { 69 | self := new(story) 70 | self.out = out 71 | self.titlesById = make(map[string]string) 72 | return self 73 | } 74 | --------------------------------------------------------------------------------