From b46be927fc7eab19fab2f4b459cd8d290d66dcfd Mon Sep 17 00:00:00 2001 From: Ibrahim AshShohail Date: Tue, 8 Aug 2017 21:52:40 +0300 Subject: [PATCH] prune dep vendor/ Signed-off-by: Ibrahim AshShohail --- .../github.com/Masterminds/semver/.travis.yml | 24 - .../Masterminds/semver/CHANGELOG.md | 17 - vendor/github.com/Masterminds/semver/Makefile | 36 - .../github.com/Masterminds/semver/README.md | 146 --- .../Masterminds/semver/appveyor.yml | 44 - .../Masterminds/semver/benchmark_test.go | 259 ----- .../Masterminds/semver/collection_test.go | 46 - .../Masterminds/semver/set_ops_test.go | 932 ---------------- .../Masterminds/semver/version_test.go | 310 ------ vendor/github.com/Masterminds/vcs/.gitignore | 24 - vendor/github.com/Masterminds/vcs/.travis.yml | 29 - .../github.com/Masterminds/vcs/CHANGELOG.md | 148 --- vendor/github.com/Masterminds/vcs/Makefile | 41 - vendor/github.com/Masterminds/vcs/README.md | 48 - .../github.com/Masterminds/vcs/appveyor.yml | 26 - vendor/github.com/Masterminds/vcs/bzr_test.go | 328 ------ .../github.com/Masterminds/vcs/errors_test.go | 36 - vendor/github.com/Masterminds/vcs/git_test.go | 599 ----------- vendor/github.com/Masterminds/vcs/glide.yaml | 8 - vendor/github.com/Masterminds/vcs/hg_test.go | 332 ------ .../github.com/Masterminds/vcs/repo_test.go | 74 -- vendor/github.com/Masterminds/vcs/svn_test.go | 337 ------ .../Masterminds/vcs/vcs_remote_lookup_test.go | 137 --- vendor/github.com/armon/go-radix/.gitignore | 22 - vendor/github.com/armon/go-radix/.travis.yml | 3 - vendor/github.com/armon/go-radix/README.md | 38 - .../github.com/armon/go-radix/radix_test.go | 319 ------ vendor/github.com/go-yaml/yaml/.travis.yml | 9 - vendor/github.com/go-yaml/yaml/README.md | 131 --- vendor/github.com/go-yaml/yaml/decode_test.go | 998 ------------------ vendor/github.com/go-yaml/yaml/encode_test.go | 501 --------- vendor/github.com/go-yaml/yaml/suite_test.go | 12 - .../github.com/nightlyone/lockfile/.gitignore | 27 - .../nightlyone/lockfile/.gitmodules | 3 - .../nightlyone/lockfile/.travis.yml | 14 - .../github.com/nightlyone/lockfile/README.md | 52 - .../nightlyone/lockfile/appveyor.yml | 12 - .../nightlyone/lockfile/lockfile_test.go | 308 ------ .../pelletier/go-buffruneio/.gitignore | 1 - .../pelletier/go-buffruneio/.travis.yml | 7 - .../pelletier/go-buffruneio/README.md | 62 -- .../go-buffruneio/buffruneio_test.go | 145 --- .../github.com/pelletier/go-toml/.gitignore | 1 - .../github.com/pelletier/go-toml/.travis.yml | 21 - vendor/github.com/pelletier/go-toml/README.md | 120 --- vendor/github.com/pelletier/go-toml/clean.sh | 6 - .../go-toml/cmd/tomljson/main_test.go | 82 -- .../github.com/pelletier/go-toml/doc_test.go | 81 -- .../pelletier/go-toml/example-crlf.toml | 29 - .../github.com/pelletier/go-toml/example.toml | 29 - .../pelletier/go-toml/keysparsing_test.go | 56 - .../pelletier/go-toml/lexer_test.go | 750 ------------- .../pelletier/go-toml/marshal_test.go | 583 ---------- .../pelletier/go-toml/marshal_test.toml | 38 - .../pelletier/go-toml/match_test.go | 201 ---- .../pelletier/go-toml/parser_test.go | 785 -------------- .../pelletier/go-toml/position_test.go | 29 - .../pelletier/go-toml/query_test.go | 70 -- .../pelletier/go-toml/querylexer_test.go | 178 ---- .../pelletier/go-toml/queryparser_test.go | 483 --------- vendor/github.com/pelletier/go-toml/test.sh | 82 -- .../pelletier/go-toml/token_test.go | 67 -- .../github.com/pelletier/go-toml/toml_test.go | 131 --- .../pelletier/go-toml/tomltree_create_test.go | 126 --- .../pelletier/go-toml/tomltree_write_test.go | 271 ----- vendor/github.com/pkg/errors/.gitignore | 24 - vendor/github.com/pkg/errors/.travis.yml | 11 - vendor/github.com/pkg/errors/README.md | 52 - vendor/github.com/pkg/errors/appveyor.yml | 32 - vendor/github.com/pkg/errors/bench_test.go | 59 -- vendor/github.com/pkg/errors/errors_test.go | 226 ---- vendor/github.com/pkg/errors/example_test.go | 205 ---- vendor/github.com/pkg/errors/format_test.go | 535 ---------- vendor/github.com/pkg/errors/stack_test.go | 292 ----- vendor/github.com/sdboyer/constext/README.md | 78 -- .../sdboyer/constext/constext_test.go | 156 --- 76 files changed, 12534 deletions(-) delete mode 100644 vendor/github.com/Masterminds/semver/.travis.yml delete mode 100644 vendor/github.com/Masterminds/semver/CHANGELOG.md delete mode 100644 vendor/github.com/Masterminds/semver/Makefile delete mode 100644 vendor/github.com/Masterminds/semver/README.md delete mode 100644 vendor/github.com/Masterminds/semver/appveyor.yml delete mode 100644 vendor/github.com/Masterminds/semver/benchmark_test.go delete mode 100644 vendor/github.com/Masterminds/semver/collection_test.go delete mode 100644 vendor/github.com/Masterminds/semver/set_ops_test.go delete mode 100644 vendor/github.com/Masterminds/semver/version_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/.gitignore delete mode 100644 vendor/github.com/Masterminds/vcs/.travis.yml delete mode 100644 vendor/github.com/Masterminds/vcs/CHANGELOG.md delete mode 100644 vendor/github.com/Masterminds/vcs/Makefile delete mode 100644 vendor/github.com/Masterminds/vcs/README.md delete mode 100644 vendor/github.com/Masterminds/vcs/appveyor.yml delete mode 100644 vendor/github.com/Masterminds/vcs/bzr_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/errors_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/git_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/glide.yaml delete mode 100644 vendor/github.com/Masterminds/vcs/hg_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/repo_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/svn_test.go delete mode 100644 vendor/github.com/Masterminds/vcs/vcs_remote_lookup_test.go delete mode 100644 vendor/github.com/armon/go-radix/.gitignore delete mode 100644 vendor/github.com/armon/go-radix/.travis.yml delete mode 100644 vendor/github.com/armon/go-radix/README.md delete mode 100644 vendor/github.com/armon/go-radix/radix_test.go delete mode 100644 vendor/github.com/go-yaml/yaml/.travis.yml delete mode 100644 vendor/github.com/go-yaml/yaml/README.md delete mode 100644 vendor/github.com/go-yaml/yaml/decode_test.go delete mode 100644 vendor/github.com/go-yaml/yaml/encode_test.go delete mode 100644 vendor/github.com/go-yaml/yaml/suite_test.go delete mode 100644 vendor/github.com/nightlyone/lockfile/.gitignore delete mode 100644 vendor/github.com/nightlyone/lockfile/.gitmodules delete mode 100644 vendor/github.com/nightlyone/lockfile/.travis.yml delete mode 100644 vendor/github.com/nightlyone/lockfile/README.md delete mode 100644 vendor/github.com/nightlyone/lockfile/appveyor.yml delete mode 100644 vendor/github.com/nightlyone/lockfile/lockfile_test.go delete mode 100644 vendor/github.com/pelletier/go-buffruneio/.gitignore delete mode 100644 vendor/github.com/pelletier/go-buffruneio/.travis.yml delete mode 100644 vendor/github.com/pelletier/go-buffruneio/README.md delete mode 100644 vendor/github.com/pelletier/go-buffruneio/buffruneio_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/.gitignore delete mode 100644 vendor/github.com/pelletier/go-toml/.travis.yml delete mode 100644 vendor/github.com/pelletier/go-toml/README.md delete mode 100755 vendor/github.com/pelletier/go-toml/clean.sh delete mode 100644 vendor/github.com/pelletier/go-toml/cmd/tomljson/main_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/doc_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/example-crlf.toml delete mode 100644 vendor/github.com/pelletier/go-toml/example.toml delete mode 100644 vendor/github.com/pelletier/go-toml/keysparsing_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/lexer_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/marshal_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/marshal_test.toml delete mode 100644 vendor/github.com/pelletier/go-toml/match_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/parser_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/position_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/query_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/querylexer_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/queryparser_test.go delete mode 100755 vendor/github.com/pelletier/go-toml/test.sh delete mode 100644 vendor/github.com/pelletier/go-toml/token_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/toml_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/tomltree_create_test.go delete mode 100644 vendor/github.com/pelletier/go-toml/tomltree_write_test.go delete mode 100644 vendor/github.com/pkg/errors/.gitignore delete mode 100644 vendor/github.com/pkg/errors/.travis.yml delete mode 100644 vendor/github.com/pkg/errors/README.md delete mode 100644 vendor/github.com/pkg/errors/appveyor.yml delete mode 100644 vendor/github.com/pkg/errors/bench_test.go delete mode 100644 vendor/github.com/pkg/errors/errors_test.go delete mode 100644 vendor/github.com/pkg/errors/example_test.go delete mode 100644 vendor/github.com/pkg/errors/format_test.go delete mode 100644 vendor/github.com/pkg/errors/stack_test.go delete mode 100644 vendor/github.com/sdboyer/constext/README.md delete mode 100644 vendor/github.com/sdboyer/constext/constext_test.go diff --git a/vendor/github.com/Masterminds/semver/.travis.yml b/vendor/github.com/Masterminds/semver/.travis.yml deleted file mode 100644 index fa92a5a326..0000000000 --- a/vendor/github.com/Masterminds/semver/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -language: go - -go: - - 1.6 - - 1.7 - - tip - -# Setting sudo access to false will let Travis CI use containers rather than -# VMs to run the tests. For more details see: -# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -# - http://docs.travis-ci.com/user/workers/standard-infrastructure/ -sudo: false - -script: - - make setup - - make test - -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/06e3328629952dabe3e0 - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: never # options: [always|never|change] default: always diff --git a/vendor/github.com/Masterminds/semver/CHANGELOG.md b/vendor/github.com/Masterminds/semver/CHANGELOG.md deleted file mode 100644 index 25550675e9..0000000000 --- a/vendor/github.com/Masterminds/semver/CHANGELOG.md +++ /dev/null @@ -1,17 +0,0 @@ -# Release 1.x.x (xxxx-xx-xx) - -- Issue #9: Speed up version comparison performance (thanks @sdboyer) -- Issue #8: Added benchmarks (thanks @sdboyer) - -# Release 1.1.0 (2015-03-11) - -- Issue #2: Implemented validation to provide reasons a versions failed a - constraint. - -# Release 1.0.1 (2015-12-31) - -- Fixed #1: * constraint failing on valid versions. - -# Release 1.0.0 (2015-10-20) - -- Initial release diff --git a/vendor/github.com/Masterminds/semver/Makefile b/vendor/github.com/Masterminds/semver/Makefile deleted file mode 100644 index a7a1b4e36d..0000000000 --- a/vendor/github.com/Masterminds/semver/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -.PHONY: setup -setup: - go get -u gopkg.in/alecthomas/gometalinter.v1 - gometalinter.v1 --install - -.PHONY: test -test: validate lint - @echo "==> Running tests" - go test -v - -.PHONY: validate -validate: - @echo "==> Running static validations" - @gometalinter.v1 \ - --disable-all \ - --enable deadcode \ - --severity deadcode:error \ - --enable gofmt \ - --enable gosimple \ - --enable ineffassign \ - --enable misspell \ - --enable vet \ - --tests \ - --vendor \ - --deadline 60s \ - ./... || exit_code=1 - -.PHONY: lint -lint: - @echo "==> Running linters" - @gometalinter.v1 \ - --disable-all \ - --enable golint \ - --vendor \ - --deadline 60s \ - ./... || : diff --git a/vendor/github.com/Masterminds/semver/README.md b/vendor/github.com/Masterminds/semver/README.md deleted file mode 100644 index aa133eac57..0000000000 --- a/vendor/github.com/Masterminds/semver/README.md +++ /dev/null @@ -1,146 +0,0 @@ -# SemVer - -The `semver` package provides the ability to work with [Semantic Versions](http://semver.org) in Go. Specifically it provides the ability to: - -* Parse semantic versions -* Sort semantic versions -* Check if a semantic version fits within a set of constraints -* Optionally work with a `v` prefix - -[![Build Status](https://travis-ci.org/Masterminds/semver.svg)](https://travis-ci.org/Masterminds/semver) [![Build status](https://ci.appveyor.com/api/projects/status/jfk66lib7hb985k8/branch/master?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/semver/branch/master) [![GoDoc](https://godoc.org/github.com/Masterminds/semver?status.png)](https://godoc.org/github.com/Masterminds/semver) [![Go Report Card](http://goreportcard.com/badge/Masterminds/semver)](http://goreportcard.com/report/Masterminds/semver) - -## Parsing Semantic Versions - -To parse a semantic version use the `NewVersion` function. For example, - - v, err := semver.NewVersion("1.2.3-beta.1+build345") - -If there is an error the version wasn't parseable. The version object has methods -to get the parts of the version, compare it to other versions, convert the -version back into a string, and get the original string. For more details -please see the [documentation](https://godoc.org/github.com/Masterminds/semver). - -## Sorting Semantic Versions - -A set of versions can be sorted using the [`sort`](https://golang.org/pkg/sort/) -package from the standard library. For example, - - raw := []string{"1.2.3", "1.0", "1.3", "2", "0.4.2",} - vs := make([]*semver.Version, len(raw)) - for i, r := range raw { - v, err := semver.NewVersion(r) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - vs[i] = v - } - - sort.Sort(semver.Collection(vs)) - -## Checking Version Constraints - -Checking a version against version constraints is one of the most featureful -parts of the package. - - c, err := semver.NewConstraint(">= 1.2.3") - if err != nil { - // Handle constraint not being parseable. - } - - v, _ := semver.NewVersion("1.3") - if err != nil { - // Handle version not being parseable. - } - // Check if the version meets the constraints. The a variable will be true. - a := c.Check(v) - -## Basic Comparisons - -There are two elements to the comparisons. First, a comparison string is a list -of comma separated and comparisons. These are then separated by || separated or -comparisons. For example, `">= 1.2, < 3.0.0 || >= 4.2.3"` is looking for a -comparison that's greater than or equal to 1.2 and less than 3.0.0 or is -greater than or equal to 4.2.3. - -The basic comparisons are: - -* `=`: equal (aliased to no operator) -* `!=`: not equal -* `>`: greater than -* `<`: less than -* `>=`: greater than or equal to -* `<=`: less than or equal to - -## Hyphen Range Comparisons - -There are multiple methods to handle ranges and the first is hyphens ranges. -These look like: - -* `1.2 - 1.4.5` which is equivalent to `>= 1.2, <= 1.4.5` -* `2.3.4 - 4.5` which is equivalent to `>= 2.3.4, <= 4.5` - -## Wildcards In Comparisons - -The `x`, `X`, and `*` characters can be used as a wildcard character. This works -for all comparison operators. When used on the `=` operator it falls -back to the pack level comparison (see tilde below). For example, - -* `1.2.x` is equivalent to `>= 1.2.0, < 1.3.0` -* `>= 1.2.x` is equivalent to `>= 1.2.0` -* `<= 2.x` is equivalent to `<= 3` -* `*` is equivalent to `>= 0.0.0` - -## Tilde Range Comparisons (Patch) - -The tilde (`~`) comparison operator is for patch level ranges when a minor -version is specified and major level changes when the minor number is missing. -For example, - -* `~1.2.3` is equivalent to `>= 1.2.3, < 1.3.0` -* `~1` is equivalent to `>= 1, < 2` -* `~2.3` is equivalent to `>= 2.3, < 2.4` -* `~1.2.x` is equivalent to `>= 1.2.0, < 1.3.0` -* `~1.x` is equivalent to `>= 1, < 2` - -## Caret Range Comparisons (Major) - -The caret (`^`) comparison operator is for major level changes. This is useful -when comparisons of API versions as a major change is API breaking. For example, - -* `^1.2.3` is equivalent to `>= 1.2.3, < 2.0.0` -* `^1.2.x` is equivalent to `>= 1.2.0, < 2.0.0` -* `^2.3` is equivalent to `>= 2.3, < 3` -* `^2.x` is equivalent to `>= 2.0.0, < 3` - -# Validation - -In addition to testing a version against a constraint, a version can be validated -against a constraint. When validation fails a slice of errors containing why a -version didn't meet the constraint is returned. For example, - - c, err := semver.NewConstraint("<= 1.2.3, >= 1.4") - if err != nil { - // Handle constraint not being parseable. - } - - v, _ := semver.NewVersion("1.3") - if err != nil { - // Handle version not being parseable. - } - - // Validate a version against a constraint. - a, msgs := c.Validate(v) - // a is false - for _, m := range msgs { - fmt.Println(m) - - // Loops over the errors which would read - // "1.3 is greater than 1.2.3" - // "1.3 is less than 1.4" - } - -# Contribute - -If you find an issue or want to contribute please file an [issue](https://github.com/Masterminds/semver/issues) -or [create a pull request](https://github.com/Masterminds/semver/pulls). diff --git a/vendor/github.com/Masterminds/semver/appveyor.yml b/vendor/github.com/Masterminds/semver/appveyor.yml deleted file mode 100644 index 08d6070875..0000000000 --- a/vendor/github.com/Masterminds/semver/appveyor.yml +++ /dev/null @@ -1,44 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\Masterminds\semver -shallow_clone: true - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -install: - - go version - - go env - - go get -u gopkg.in/alecthomas/gometalinter.v1 - - set PATH=%PATH%;%GOPATH%\bin - - gometalinter.v1.exe --install - -build_script: - - go install -v ./... - -test_script: - - "gometalinter.v1 \ - --disable-all \ - --enable deadcode \ - --severity deadcode:error \ - --enable gofmt \ - --enable gosimple \ - --enable ineffassign \ - --enable misspell \ - --enable vet \ - --tests \ - --vendor \ - --deadline 60s \ - ./... || cmd /C EXIT 0" - - "gometalinter.v1 \ - --disable-all \ - --enable golint \ - --vendor \ - --deadline 60s \ - ./... || cmd /C EXIT 0" - - go test -v - -deploy: off diff --git a/vendor/github.com/Masterminds/semver/benchmark_test.go b/vendor/github.com/Masterminds/semver/benchmark_test.go deleted file mode 100644 index 5a76f6a934..0000000000 --- a/vendor/github.com/Masterminds/semver/benchmark_test.go +++ /dev/null @@ -1,259 +0,0 @@ -package semver - -import "testing" - -func init() { - // disable constraint and version creation caching - CacheConstraints = false - CacheVersions = false -} - -var ( - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - includeMax: true, - } - rc2 = rangeConstraint{ - min: newV(2, 0, 0), - max: newV(3, 0, 0), - } - rc3 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc4 = rangeConstraint{ - min: newV(1, 7, 0), - max: newV(4, 0, 0), - } - rc5 = rangeConstraint{ - min: newV(2, 7, 0), - max: newV(3, 0, 0), - } - rc6 = rangeConstraint{ - min: newV(3, 0, 1), - max: newV(3, 0, 4), - } - rc7 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(1, 2, 0), - } - // Two fully non-overlapping unions - u1 = rc1.Union(rc7) - u2 = rc5.Union(rc6) -) - -/* Constraint creation benchmarks */ - -func benchNewConstraint(c string, b *testing.B) { - for i := 0; i < b.N; i++ { - NewConstraint(c) - } -} - -func BenchmarkNewConstraintUnary(b *testing.B) { - benchNewConstraint("=2.0", b) -} - -func BenchmarkNewConstraintTilde(b *testing.B) { - benchNewConstraint("~2.0.0", b) -} - -func BenchmarkNewConstraintCaret(b *testing.B) { - benchNewConstraint("^2.0.0", b) -} - -func BenchmarkNewConstraintWildcard(b *testing.B) { - benchNewConstraint("1.x", b) -} - -func BenchmarkNewConstraintRange(b *testing.B) { - benchNewConstraint(">=2.1.x, <3.1.0", b) -} - -func BenchmarkNewConstraintUnion(b *testing.B) { - benchNewConstraint("~2.0.0 || =3.1.0", b) -} - -/* Validate benchmarks, including fails */ - -func benchValidateVersion(c, v string, b *testing.B) { - version, _ := NewVersion(v) - constraint, _ := NewConstraint(c) - - for i := 0; i < b.N; i++ { - constraint.Matches(version) - } -} - -func BenchmarkValidateVersionUnary(b *testing.B) { - benchValidateVersion("=2.0", "2.0.0", b) -} - -func BenchmarkValidateVersionUnaryFail(b *testing.B) { - benchValidateVersion("=2.0", "2.0.1", b) -} - -func BenchmarkValidateVersionTilde(b *testing.B) { - benchValidateVersion("~2.0.0", "2.0.5", b) -} - -func BenchmarkValidateVersionTildeFail(b *testing.B) { - benchValidateVersion("~2.0.0", "1.0.5", b) -} - -func BenchmarkValidateVersionCaret(b *testing.B) { - benchValidateVersion("^2.0.0", "2.1.0", b) -} - -func BenchmarkValidateVersionCaretFail(b *testing.B) { - benchValidateVersion("^2.0.0", "4.1.0", b) -} - -func BenchmarkValidateVersionWildcard(b *testing.B) { - benchValidateVersion("1.x", "1.4.0", b) -} - -func BenchmarkValidateVersionWildcardFail(b *testing.B) { - benchValidateVersion("1.x", "2.4.0", b) -} - -func BenchmarkValidateVersionRange(b *testing.B) { - benchValidateVersion(">=2.1.x, <3.1.0", "2.4.5", b) -} - -func BenchmarkValidateVersionRangeFail(b *testing.B) { - benchValidateVersion(">=2.1.x, <3.1.0", "1.4.5", b) -} - -func BenchmarkValidateVersionUnion(b *testing.B) { - benchValidateVersion("~2.0.0 || =3.1.0", "3.1.0", b) -} - -func BenchmarkValidateVersionUnionFail(b *testing.B) { - benchValidateVersion("~2.0.0 || =3.1.0", "3.1.1", b) -} - -/* Version creation benchmarks */ - -func benchNewVersion(v string, b *testing.B) { - for i := 0; i < b.N; i++ { - NewVersion(v) - } -} - -func BenchmarkNewVersionSimple(b *testing.B) { - benchNewVersion("1.0.0", b) -} - -func BenchmarkNewVersionPre(b *testing.B) { - benchNewVersion("1.0.0-alpha", b) -} - -func BenchmarkNewVersionMeta(b *testing.B) { - benchNewVersion("1.0.0+metadata", b) -} - -func BenchmarkNewVersionMetaDash(b *testing.B) { - benchNewVersion("1.0.0+metadata-dash", b) -} - -/* Union benchmarks */ - -func BenchmarkAdjacentRangeUnion(b *testing.B) { - for i := 0; i < b.N; i++ { - Union(rc1, rc2) - } -} - -func BenchmarkAdjacentRangeUnionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - rc1.Union(rc2) - } -} - -func BenchmarkDisjointRangeUnion(b *testing.B) { - for i := 0; i < b.N; i++ { - Union(rc2, rc3) - } -} - -func BenchmarkDisjointRangeUnionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - rc2.Union(rc3) - } -} - -func BenchmarkOverlappingRangeUnion(b *testing.B) { - for i := 0; i < b.N; i++ { - Union(rc1, rc4) - } -} - -func BenchmarkOverlappingRangeUnionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - rc1.Union(rc4) - } -} - -func BenchmarkUnionUnion(b *testing.B) { - for i := 0; i < b.N; i++ { - Union(u1, u2) - } -} - -func BenchmarkUnionUnionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - u1.Union(u2) - } -} - -/* Intersection benchmarks */ - -func BenchmarkSubsetRangeIntersection(b *testing.B) { - for i := 0; i < b.N; i++ { - Intersection(rc2, rc4) - } -} - -func BenchmarkSubsetRangeIntersectionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - rc2.Intersect(rc4) - } -} - -func BenchmarkDisjointRangeIntersection(b *testing.B) { - for i := 0; i < b.N; i++ { - Intersection(rc2, rc3) - } -} - -func BenchmarkDisjointRangeIntersectionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - rc2.Intersect(rc3) - } -} - -func BenchmarkOverlappingRangeIntersection(b *testing.B) { - for i := 0; i < b.N; i++ { - Intersection(rc1, rc4) - } -} - -func BenchmarkOverlappingRangeIntersectionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - rc1.Intersect(rc4) - } -} - -func BenchmarkUnionIntersection(b *testing.B) { - for i := 0; i < b.N; i++ { - Intersection(u1, u2) - } -} - -func BenchmarkUnionIntersectionMethod(b *testing.B) { - for i := 0; i < b.N; i++ { - u1.Intersect(u2) - } -} diff --git a/vendor/github.com/Masterminds/semver/collection_test.go b/vendor/github.com/Masterminds/semver/collection_test.go deleted file mode 100644 index a1d745f476..0000000000 --- a/vendor/github.com/Masterminds/semver/collection_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package semver - -import ( - "reflect" - "sort" - "testing" -) - -func TestCollection(t *testing.T) { - raw := []string{ - "1.2.3", - "1.0", - "1.3", - "2", - "0.4.2", - } - - vs := make([]Version, len(raw)) - for i, r := range raw { - v, err := NewVersion(r) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - vs[i] = v - } - - sort.Sort(Collection(vs)) - - e := []string{ - "0.4.2", - "1.0.0", - "1.2.3", - "1.3.0", - "2.0.0", - } - - a := make([]string, len(vs)) - for i, v := range vs { - a[i] = v.String() - } - - if !reflect.DeepEqual(a, e) { - t.Error("Sorting Collection failed") - } -} diff --git a/vendor/github.com/Masterminds/semver/set_ops_test.go b/vendor/github.com/Masterminds/semver/set_ops_test.go deleted file mode 100644 index c08f27618d..0000000000 --- a/vendor/github.com/Masterminds/semver/set_ops_test.go +++ /dev/null @@ -1,932 +0,0 @@ -package semver - -import "testing" - -func TestIntersection(t *testing.T) { - var actual Constraint - rc1 := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - - if actual = Intersection(); !IsNone(actual) { - t.Errorf("Intersection of nothing should always produce None; got %q", actual) - } - - if actual = Intersection(rc1); !constraintEq(actual, rc1) { - t.Errorf("Intersection of one item should always return that item; got %q", actual) - } - - if actual = Intersection(rc1, None()); !IsNone(actual) { - t.Errorf("Intersection of anything with None should always produce None; got %q", actual) - } - - if actual = Intersection(rc1, Any()); !constraintEq(actual, rc1) { - t.Errorf("Intersection of anything with Any should return self; got %q", actual) - } - - v1 := newV(1, 5, 0) - if actual = Intersection(rc1, v1); !constraintEq(actual, v1) { - t.Errorf("Got constraint %q, but expected %q", actual, v1) - } - - rc2 := rangeConstraint{ - min: newV(1, 2, 0), - max: newV(2, 2, 0), - } - result := rangeConstraint{ - min: newV(1, 2, 0), - max: newV(2, 0, 0), - } - - if actual = Intersection(rc1, rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - u1 := unionConstraint{ - rangeConstraint{ - min: newV(1, 2, 0), - max: newV(3, 0, 0), - }, - newV(3, 1, 0), - } - - if actual = Intersection(u1, rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = Intersection(rc1, newV(2, 0, 5), u1); !IsNone(actual) { - t.Errorf("First two are disjoint, should have gotten None but got %q", actual) - } -} - -func TestRangeIntersection(t *testing.T) { - var actual Constraint - // Test magic cases - rc1 := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - if actual = rc1.Intersect(Any()); !constraintEq(actual, rc1) { - t.Errorf("Intersection of anything with Any should return self; got %q", actual) - } - if actual = rc1.Intersect(None()); !IsNone(actual) { - t.Errorf("Intersection of anything with None should always produce None; got %q", actual) - } - - // Test single version cases - - // single v, in range - v1 := newV(1, 5, 0) - - if actual = rc1.Intersect(v1); !constraintEq(actual, v1) { - t.Errorf("Intersection of version with matching range should return the version; got %q", actual) - } - - // now exclude just that version - rc1.excl = []Version{v1} - if actual = rc1.Intersect(v1); !IsNone(actual) { - t.Errorf("Intersection of version with range having specific exclude for that version should produce None; got %q", actual) - } - - // and, of course, none if the version is out of range - v2 := newV(0, 5, 0) - if actual = rc1.Intersect(v2); !IsNone(actual) { - t.Errorf("Intersection of version with non-matching range should produce None; got %q", actual) - } - - // Test basic overlap case - rc1 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - rc2 := rangeConstraint{ - min: newV(1, 2, 0), - max: newV(2, 2, 0), - } - result := rangeConstraint{ - min: newV(1, 2, 0), - max: newV(2, 0, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // And with includes - rc1.includeMin = true - rc1.includeMax = true - rc2.includeMin = true - rc2.includeMax = true - result.includeMin = true - result.includeMax = true - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Overlaps with nils - rc1 = rangeConstraint{ - min: newV(1, 0, 0), - max: Version{special: infiniteVersion}, - } - rc2 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: newV(2, 2, 0), - } - result = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 2, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // And with includes - rc1.includeMin = true - rc2.includeMax = true - result.includeMin = true - result.includeMax = true - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Test superset overlap case - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(3, 0, 0), - } - result = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Make sure irrelevant includes don't leak in - rc2.includeMin = true - rc2.includeMax = true - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // But relevant includes get used - rc1.includeMin = true - rc1.includeMax = true - result.includeMin = true - result.includeMax = true - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Test disjoint case - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(1, 6, 0), - } - rc2 = rangeConstraint{ - min: newV(2, 0, 0), - max: newV(3, 0, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, None()) { - t.Errorf("Got constraint %q, but expected %q", actual, None()) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, None()) { - t.Errorf("Got constraint %q, but expected %q", actual, None()) - } - - // Test disjoint at gt/lt boundary (non-adjacent) - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(2, 0, 0), - max: newV(3, 0, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, None()) { - t.Errorf("Got constraint %q, but expected %q", actual, None()) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, None()) { - t.Errorf("Got constraint %q, but expected %q", actual, None()) - } - - // Now, just have them touch at a single version - rc1.includeMax = true - rc2.includeMin = true - - vresult := newV(2, 0, 0) - if actual = rc1.Intersect(rc2); !constraintEq(actual, vresult) { - t.Errorf("Got constraint %q, but expected %q", actual, vresult) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, vresult) { - t.Errorf("Got constraint %q, but expected %q", actual, vresult) - } - - // Test excludes in intersection range - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - excl: []Version{ - newV(1, 6, 0), - }, - } - rc2 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(3, 0, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - - // Test excludes not in intersection range - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(3, 0, 0), - excl: []Version{ - newV(1, 1, 0), - }, - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - - // Test min, and greater min - rc1 = rangeConstraint{ - min: newV(1, 0, 0), - max: Version{special: infiniteVersion}, - } - rc2 = rangeConstraint{ - min: newV(1, 5, 0), - max: Version{special: infiniteVersion}, - includeMin: true, - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Test max, and lesser max - rc1 = rangeConstraint{ - max: newV(1, 0, 0), - } - rc2 = rangeConstraint{ - max: newV(1, 5, 0), - } - result = rangeConstraint{ - max: newV(1, 0, 0), - } - - if actual = rc1.Intersect(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Intersect(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Ensure pure excludes come through as they should - rc1 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: Version{special: infiniteVersion}, - excl: []Version{ - newV(1, 6, 0), - }, - } - - rc2 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: Version{special: infiniteVersion}, - excl: []Version{ - newV(1, 6, 0), - newV(1, 7, 0), - }, - } - - if actual = Any().Intersect(rc1); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - if actual = rc1.Intersect(Any()); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - if actual = rc1.Intersect(rc2); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - - // TODO test the pre-release special range stuff -} - -func TestRangeUnion(t *testing.T) { - var actual Constraint - // Test magic cases - rc1 := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - if actual = rc1.Union(Any()); !IsAny(actual) { - t.Errorf("Union of anything with Any should always produce Any; got %q", actual) - } - if actual = rc1.Union(None()); !constraintEq(actual, rc1) { - t.Errorf("Union of anything with None should return self; got %q", actual) - } - - // Test single version cases - - // single v, in range - v1 := newV(1, 5, 0) - - if actual = rc1.Union(v1); !constraintEq(actual, rc1) { - t.Errorf("Union of version with matching range should return the range; got %q", actual) - } - - // now exclude just that version - rc2 := rc1.dup() - rc2.excl = []Version{v1} - if actual = rc2.Union(v1); !constraintEq(actual, rc1) { - t.Errorf("Union of version with range having specific exclude for that version should produce the range without that exclude; got %q", actual) - } - - // and a union if the version is not within the range - v2 := newV(0, 5, 0) - uresult := unionConstraint{v2, rc1} - if actual = rc1.Union(v2); !constraintEq(actual, uresult) { - t.Errorf("Union of version with non-matching range should produce a unionConstraint with those two; got %q", actual) - } - - // union with version at the min should ensure "oreq" - v2 = newV(1, 0, 0) - rc3 := rc1 - rc3.includeMin = true - - if actual = rc1.Union(v2); !constraintEq(actual, rc3) { - t.Errorf("Union of range with version at min end should add includeMin (%q), but got %q", rc3, actual) - } - if actual = v2.Union(rc1); !constraintEq(actual, rc3) { - t.Errorf("Union of range with version at min end should add includeMin (%q), but got %q", rc3, actual) - } - - // same at max end - v2 = newV(2, 0, 0) - rc3.includeMin = false - rc3.includeMax = true - - if actual = rc1.Union(v2); !constraintEq(actual, rc3) { - t.Errorf("Union of range with version at max end should add includeMax (%q), but got %q", rc3, actual) - } - if actual = v2.Union(rc1); !constraintEq(actual, rc3) { - t.Errorf("Union of range with version at max end should add includeMax (%q), but got %q", rc3, actual) - } - - // Test basic overlap case - rc1 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(1, 2, 0), - max: newV(2, 2, 0), - } - result := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 2, 0), - } - - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // And with includes - rc1.includeMin = true - rc1.includeMax = true - rc2.includeMin = true - rc2.includeMax = true - result.includeMin = true - result.includeMax = true - - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Overlaps with nils - rc1 = rangeConstraint{ - min: newV(1, 0, 0), - max: Version{special: infiniteVersion}, - } - rc2 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: newV(2, 2, 0), - } - - if actual = rc1.Union(rc2); !constraintEq(actual, Any()) { - t.Errorf("Got constraint %q, but expected %q", actual, Any()) - } - if actual = rc2.Union(rc1); !constraintEq(actual, Any()) { - t.Errorf("Got constraint %q, but expected %q", actual, Any()) - } - - // Just one nil in overlap - rc1.max = newV(2, 0, 0) - result = rangeConstraint{ - min: Version{special: zeroVersion}, - max: newV(2, 2, 0), - } - - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - rc1.max = Version{special: infiniteVersion} - rc2.min = newV(1, 5, 0) - result = rangeConstraint{ - min: newV(1, 0, 0), - max: Version{special: infiniteVersion}, - } - - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Test superset overlap case - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(3, 0, 0), - } - - if actual = rc1.Union(rc2); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - if actual = rc2.Union(rc1); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - - // Test disjoint case - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(1, 6, 0), - } - rc2 = rangeConstraint{ - min: newV(2, 0, 0), - max: newV(3, 0, 0), - } - uresult = unionConstraint{rc1, rc2} - - if actual = rc1.Union(rc2); !constraintEq(actual, uresult) { - t.Errorf("Got constraint %q, but expected %q", actual, uresult) - } - if actual = rc2.Union(rc1); !constraintEq(actual, uresult) { - t.Errorf("Got constraint %q, but expected %q", actual, uresult) - } - - // Test disjoint at gt/lt boundary (non-adjacent) - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(2, 0, 0), - max: newV(3, 0, 0), - } - uresult = unionConstraint{rc1, rc2} - - if actual = rc1.Union(rc2); !constraintEq(actual, uresult) { - t.Errorf("Got constraint %q, but expected %q", actual, uresult) - } - if actual = rc2.Union(rc1); !constraintEq(actual, uresult) { - t.Errorf("Got constraint %q, but expected %q", actual, uresult) - } - - // Now, just have them touch at a single version - rc1.includeMax = true - rc2.includeMin = true - result = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(3, 0, 0), - } - - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // And top-adjacent at that version - rc2.includeMin = false - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - // And bottom-adjacent at that version - rc1.includeMax = false - rc2.includeMin = true - if actual = rc1.Union(rc2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = rc2.Union(rc1); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - - // Test excludes in overlapping range - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - excl: []Version{ - newV(1, 6, 0), - }, - } - rc2 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(3, 0, 0), - } - - if actual = rc1.Union(rc2); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - if actual = rc2.Union(rc1); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - - // Test excludes not in non-overlapping range - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(2, 0, 0), - } - rc2 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(3, 0, 0), - excl: []Version{ - newV(1, 1, 0), - }, - } - - if actual = rc1.Union(rc2); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - if actual = rc2.Union(rc1); !constraintEq(actual, rc2) { - t.Errorf("Got constraint %q, but expected %q", actual, rc2) - } - - // Ensure pure excludes come through as they should - rc1 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: Version{special: infiniteVersion}, - excl: []Version{ - newV(1, 6, 0), - }, - } - - rc2 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: Version{special: infiniteVersion}, - excl: []Version{ - newV(1, 6, 0), - newV(1, 7, 0), - }, - } - - if actual = rc1.Union(rc2); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - if actual = rc2.Union(rc1); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - - rc1 = rangeConstraint{ - min: Version{special: zeroVersion}, - max: Version{special: infiniteVersion}, - excl: []Version{ - newV(1, 5, 0), - }, - } - - if actual = rc1.Union(rc2); !constraintEq(actual, Any()) { - t.Errorf("Got constraint %q, but expected %q", actual, Any()) - } - if actual = rc2.Union(rc1); !constraintEq(actual, Any()) { - t.Errorf("Got constraint %q, but expected %q", actual, Any()) - } - - // TODO test the pre-release special range stuff -} - -func TestUnionIntersection(t *testing.T) { - var actual Constraint - // magic first - u1 := unionConstraint{ - newV(1, 1, 0), - newV(1, 2, 0), - newV(1, 3, 0), - } - if actual = u1.Intersect(Any()); !constraintEq(actual, u1) { - t.Errorf("Intersection of anything with Any should return self; got %s", actual) - } - if actual = u1.Intersect(None()); !IsNone(actual) { - t.Errorf("Intersection of anything with None should always produce None; got %s", actual) - } - if u1.MatchesAny(None()) { - t.Errorf("Can't match any when intersected with None") - } - - // intersect of unions with single versions - v1 := newV(1, 1, 0) - if actual = u1.Intersect(v1); !constraintEq(actual, v1) { - t.Errorf("Got constraint %q, but expected %q", actual, v1) - } - if actual = v1.Intersect(u1); !constraintEq(actual, v1) { - t.Errorf("Got constraint %q, but expected %q", actual, v1) - } - - // intersect of range with union of versions - u1 = unionConstraint{ - newV(1, 1, 0), - newV(1, 2, 0), - newV(1, 3, 0), - } - rc1 := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - - if actual = u1.Intersect(rc1); !constraintEq(actual, u1) { - t.Errorf("Got constraint %q, but expected %q", actual, u1) - } - if actual = rc1.Intersect(u1); !constraintEq(actual, u1) { - t.Errorf("Got constraint %q, but expected %q", actual, u1) - } - - u2 := unionConstraint{ - newV(1, 1, 0), - newV(1, 2, 0), - } - - if actual = u1.Intersect(u2); !constraintEq(actual, u2) { - t.Errorf("Got constraint %q, but expected %q", actual, u2) - } - - // Overlapping sub/supersets - rc1 = rangeConstraint{ - min: newV(1, 5, 0), - max: newV(1, 6, 0), - } - rc2 := rangeConstraint{ - min: newV(2, 0, 0), - max: newV(3, 0, 0), - } - rc3 = rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - rc4 := rangeConstraint{ - min: newV(2, 5, 0), - max: newV(2, 6, 0), - } - u1 = unionConstraint{rc1, rc2} - u2 = unionConstraint{rc3, rc4} - ur := unionConstraint{rc1, rc4} - - if actual = u1.Intersect(u2); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - if actual = u2.Intersect(u1); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - - // Ensure excludes carry as they should - rc1.excl = []Version{newV(1, 5, 5)} - u1 = unionConstraint{rc1, rc2} - ur = unionConstraint{rc1, rc4} - - if actual = u1.Intersect(u2); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - if actual = u2.Intersect(u1); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } -} - -func TestUnionUnion(t *testing.T) { - var actual Constraint - // magic first - u1 := unionConstraint{ - newV(1, 1, 0), - newV(1, 2, 0), - newV(1, 3, 0), - } - if actual = u1.Union(Any()); !IsAny(actual) { - t.Errorf("Union of anything with Any should always return Any; got %s", actual) - } - if actual = u1.Union(None()); !constraintEq(actual, u1) { - t.Errorf("Union of anything with None should always return self; got %s", actual) - } - - // union of uc with single versions - // already present - v1 := newV(1, 2, 0) - if actual = u1.Union(v1); !constraintEq(actual, u1) { - t.Errorf("Got constraint %q, but expected %q", actual, u1) - } - if actual = v1.Union(u1); !constraintEq(actual, u1) { - t.Errorf("Got constraint %q, but expected %q", actual, u1) - } - - // not present - v2 := newV(1, 4, 0) - ur := append(u1, v2) - if actual = u1.Union(v2); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - if actual = v2.Union(u1); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - - // union of uc with uc, all versions - u2 := unionConstraint{ - newV(1, 3, 0), - newV(1, 4, 0), - newV(1, 5, 0), - } - ur = unionConstraint{ - newV(1, 1, 0), - newV(1, 2, 0), - newV(1, 3, 0), - newV(1, 4, 0), - newV(1, 5, 0), - } - - if actual = u1.Union(u2); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - if actual = u2.Union(u1); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - - // union that should compress versions into range - rc1 := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - - if actual = u1.Union(rc1); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - if actual = rc1.Union(u1); !constraintEq(actual, rc1) { - t.Errorf("Got constraint %q, but expected %q", actual, rc1) - } - - rc1.max = newV(1, 4, 5) - u3 := append(u2, newV(1, 7, 0)) - ur = unionConstraint{ - rc1, - newV(1, 5, 0), - newV(1, 7, 0), - } - - if actual = u3.Union(rc1); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } - if actual = rc1.Union(u3); !constraintEq(actual, ur) { - t.Errorf("Got constraint %q, but expected %q", actual, ur) - } -} - -// Most version stuff got tested by range and/or union b/c most tests were -// repeated bidirectionally (set operations are commutative; testing in pairs -// helps us catch any situation where we fail to maintain that invariant) -func TestVersionSetOps(t *testing.T) { - var actual Constraint - - v1 := newV(1, 0, 0) - - if actual = v1.Intersect(v1); !constraintEq(actual, v1) { - t.Errorf("Version intersected with itself should be itself, got %q", actual) - } - if !v1.MatchesAny(v1) { - t.Errorf("MatchesAny should work with a version against itself") - } - - v2 := newV(2, 0, 0) - if actual = v1.Intersect(v2); !IsNone(actual) { - t.Errorf("Versions should only intersect with themselves, got %q", actual) - } - if v1.MatchesAny(v2) { - t.Errorf("MatchesAny should not work when combined with anything other than itself") - } - - result := unionConstraint{v1, v2} - - if actual = v1.Union(v1); !constraintEq(actual, v1) { - t.Errorf("Version union with itself should return self, got %q", actual) - } - - if actual = v1.Union(v2); !constraintEq(actual, result) { - t.Errorf("Got constraint %q, but expected %q", actual, result) - } - if actual = v1.Union(v2); !constraintEq(actual, result) { - // Duplicate just to make sure ordering works right - t.Errorf("Got constraint %q, but expected %q", actual, result) - } -} - -func TestAreAdjacent(t *testing.T) { - rc1 := rangeConstraint{ - min: newV(1, 0, 0), - max: newV(2, 0, 0), - } - rc2 := rangeConstraint{ - min: newV(1, 2, 0), - max: newV(2, 2, 0), - } - - if areAdjacent(rc1, rc2) { - t.Errorf("Ranges overlap, should not indicate as adjacent") - } - - rc2 = rangeConstraint{ - min: newV(2, 0, 0), - } - - if areAdjacent(rc1, rc2) { - t.Errorf("Ranges are non-overlapping and non-adjacent, but reported as adjacent") - } - - rc2.includeMin = true - - if !areAdjacent(rc1, rc2) { - t.Errorf("Ranges are non-overlapping and adjacent, but reported as non-adjacent") - } - - rc1.includeMax = true - - if areAdjacent(rc1, rc2) { - t.Errorf("Ranges are overlapping at a single version, but reported as adjacent") - } - - rc2.includeMin = false - if !areAdjacent(rc1, rc2) { - t.Errorf("Ranges are non-overlapping and adjacent, but reported as non-adjacent") - } -} diff --git a/vendor/github.com/Masterminds/semver/version_test.go b/vendor/github.com/Masterminds/semver/version_test.go deleted file mode 100644 index 1fae87f526..0000000000 --- a/vendor/github.com/Masterminds/semver/version_test.go +++ /dev/null @@ -1,310 +0,0 @@ -package semver - -import ( - "testing" -) - -func TestNewVersion(t *testing.T) { - tests := []struct { - version string - err bool - }{ - {"1.2.3", false}, - {"v1.2.3", false}, - {"1.0", false}, - {"v1.0", false}, - {"1", false}, - {"v1", false}, - {"1.2.beta", true}, - {"v1.2.beta", true}, - {"foo", true}, - {"1.2-5", false}, - {"v1.2-5", false}, - {"1.2-beta.5", false}, - {"v1.2-beta.5", false}, - {"\n1.2", true}, - {"\nv1.2", true}, - {"1.2.0-x.Y.0+metadata", false}, - {"v1.2.0-x.Y.0+metadata", false}, - {"1.2.0-x.Y.0+metadata-width-hypen", false}, - {"v1.2.0-x.Y.0+metadata-width-hypen", false}, - {"1.2.3-rc1-with-hypen", false}, - {"v1.2.3-rc1-with-hypen", false}, - {"1.2.3.4", true}, - {"v1.2.3.4", true}, - } - - for _, tc := range tests { - _, err := NewVersion(tc.version) - if tc.err && err == nil { - t.Fatalf("expected error for version: %s", tc.version) - } else if !tc.err && err != nil { - t.Fatalf("error for version %s: %s", tc.version, err) - } - } -} - -func TestOriginal(t *testing.T) { - tests := []string{ - "1.2.3", - "v1.2.3", - "1.0", - "v1.0", - "1", - "v1", - "1.2-5", - "v1.2-5", - "1.2-beta.5", - "v1.2-beta.5", - "1.2.0-x.Y.0+metadata", - "v1.2.0-x.Y.0+metadata", - "1.2.0-x.Y.0+metadata-width-hypen", - "v1.2.0-x.Y.0+metadata-width-hypen", - "1.2.3-rc1-with-hypen", - "v1.2.3-rc1-with-hypen", - } - - for _, tc := range tests { - v, err := NewVersion(tc) - if err != nil { - t.Errorf("Error parsing version %s", tc) - } - - o := v.Original() - if o != tc { - t.Errorf("Error retrieving originl. Expected '%s' but got '%s'", tc, v) - } - } -} - -func TestParts(t *testing.T) { - v, err := NewVersion("1.2.3-beta.1+build.123") - if err != nil { - t.Error("Error parsing version 1.2.3-beta.1+build.123") - } - - if v.Major() != 1 { - t.Error("Major() returning wrong value") - } - if v.Minor() != 2 { - t.Error("Minor() returning wrong value") - } - if v.Patch() != 3 { - t.Error("Patch() returning wrong value") - } - if v.Prerelease() != "beta.1" { - t.Error("Prerelease() returning wrong value") - } - if v.Metadata() != "build.123" { - t.Error("Metadata() returning wrong value") - } -} - -func TestString(t *testing.T) { - tests := []struct { - version string - expected string - }{ - {"1.2.3", "1.2.3"}, - {"v1.2.3", "1.2.3"}, - {"1.0", "1.0.0"}, - {"v1.0", "1.0.0"}, - {"1", "1.0.0"}, - {"v1", "1.0.0"}, - {"1.2-5", "1.2.0-5"}, - {"v1.2-5", "1.2.0-5"}, - {"1.2-beta.5", "1.2.0-beta.5"}, - {"v1.2-beta.5", "1.2.0-beta.5"}, - {"1.2.0-x.Y.0+metadata", "1.2.0-x.Y.0+metadata"}, - {"v1.2.0-x.Y.0+metadata", "1.2.0-x.Y.0+metadata"}, - {"1.2.0-x.Y.0+metadata-width-hypen", "1.2.0-x.Y.0+metadata-width-hypen"}, - {"v1.2.0-x.Y.0+metadata-width-hypen", "1.2.0-x.Y.0+metadata-width-hypen"}, - {"1.2.3-rc1-with-hypen", "1.2.3-rc1-with-hypen"}, - {"v1.2.3-rc1-with-hypen", "1.2.3-rc1-with-hypen"}, - } - - for _, tc := range tests { - v, err := NewVersion(tc.version) - if err != nil { - t.Errorf("Error parsing version %s", tc) - } - - s := v.String() - if s != tc.expected { - t.Errorf("Error generating string. Expected '%s' but got '%s'", tc.expected, s) - } - } -} - -func TestCompare(t *testing.T) { - tests := []struct { - v1 string - v2 string - expected int - }{ - {"1.2.3", "1.5.1", -1}, - {"2.2.3", "1.5.1", 1}, - {"2.2.3", "2.2.2", 1}, - {"3.2-beta", "3.2-beta", 0}, - {"1.3", "1.1.4", 1}, - {"4.2", "4.2-beta", 1}, - {"4.2-beta", "4.2", -1}, - {"4.2-alpha", "4.2-beta", -1}, - {"4.2-alpha", "4.2-alpha", 0}, - {"4.2-beta.2", "4.2-beta.1", 1}, - {"4.2-beta2", "4.2-beta1", 1}, - {"4.2-beta", "4.2-beta.2", -1}, - {"4.2-beta", "4.2-beta.foo", 1}, - {"4.2-beta.2", "4.2-beta", 1}, - {"4.2-beta.foo", "4.2-beta", -1}, - {"1.2+bar", "1.2+baz", 0}, - } - - for _, tc := range tests { - v1, err := NewVersion(tc.v1) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - v2, err := NewVersion(tc.v2) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - a := v1.Compare(v2) - e := tc.expected - if a != e { - t.Errorf( - "Comparison of '%s' and '%s' failed. Expected '%d', got '%d'", - tc.v1, tc.v2, e, a, - ) - } - } - - // One-off tests for special version comparisons - zero := Version{special: zeroVersion} - inf := Version{special: infiniteVersion} - - if zero.Compare(inf) != -1 { - t.Error("Zero version should always be less than infinite version") - } - if zero.Compare(zero) != 0 { - t.Error("Zero version should equal itself") - } - if inf.Compare(zero) != 1 { - t.Error("Infinite version should always be greater than zero version") - } - if inf.Compare(inf) != 0 { - t.Error("Infinite version should equal itself") - } - - // Need to work vs. a normal version, too. - v := Version{} - - if zero.Compare(v) != -1 { - t.Error("Zero version should always be less than any normal version") - } - if inf.Compare(v) != 1 { - t.Error("Infinite version should always be greater than any normal version") - } -} - -func TestLessThan(t *testing.T) { - tests := []struct { - v1 string - v2 string - expected bool - }{ - {"1.2.3", "1.5.1", true}, - {"2.2.3", "1.5.1", false}, - {"3.2-beta", "3.2-beta", false}, - } - - for _, tc := range tests { - v1, err := NewVersion(tc.v1) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - v2, err := NewVersion(tc.v2) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - a := v1.LessThan(v2) - e := tc.expected - if a != e { - t.Errorf( - "Comparison of '%s' and '%s' failed. Expected '%t', got '%t'", - tc.v1, tc.v2, e, a, - ) - } - } -} - -func TestGreaterThan(t *testing.T) { - tests := []struct { - v1 string - v2 string - expected bool - }{ - {"1.2.3", "1.5.1", false}, - {"2.2.3", "1.5.1", true}, - {"3.2-beta", "3.2-beta", false}, - } - - for _, tc := range tests { - v1, err := NewVersion(tc.v1) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - v2, err := NewVersion(tc.v2) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - a := v1.GreaterThan(v2) - e := tc.expected - if a != e { - t.Errorf( - "Comparison of '%s' and '%s' failed. Expected '%t', got '%t'", - tc.v1, tc.v2, e, a, - ) - } - } -} - -func TestEqual(t *testing.T) { - tests := []struct { - v1 string - v2 string - expected bool - }{ - {"1.2.3", "1.5.1", false}, - {"2.2.3", "1.5.1", false}, - {"3.2-beta", "3.2-beta", true}, - {"3.2-beta+foo", "3.2-beta+bar", true}, - } - - for _, tc := range tests { - v1, err := NewVersion(tc.v1) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - v2, err := NewVersion(tc.v2) - if err != nil { - t.Errorf("Error parsing version: %s", err) - } - - a := v1.Equal(v2) - e := tc.expected - if a != e { - t.Errorf( - "Comparison of '%s' and '%s' failed. Expected '%t', got '%t'", - tc.v1, tc.v2, e, a, - ) - } - } -} diff --git a/vendor/github.com/Masterminds/vcs/.gitignore b/vendor/github.com/Masterminds/vcs/.gitignore deleted file mode 100644 index daf913b1b3..0000000000 --- a/vendor/github.com/Masterminds/vcs/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/Masterminds/vcs/.travis.yml b/vendor/github.com/Masterminds/vcs/.travis.yml deleted file mode 100644 index 47bd9491e9..0000000000 --- a/vendor/github.com/Masterminds/vcs/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: go - -go: - - 1.6 - - 1.7 - - 1.8 - - tip - -before_script: - - git version - - svn --version - -# Setting sudo access to false will let Travis CI use containers rather than -# VMs to run the tests. For more details see: -# - http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -# - http://docs.travis-ci.com/user/workers/standard-infrastructure/ -sudo: false - -script: - - make setup - - make test - -notifications: - webhooks: - urls: - - https://webhooks.gitter.im/e/06e3328629952dabe3e0 - on_success: change # options: [always|never|change] default: always - on_failure: always # options: [always|never|change] default: always - on_start: never # options: [always|never|change] default: always diff --git a/vendor/github.com/Masterminds/vcs/CHANGELOG.md b/vendor/github.com/Masterminds/vcs/CHANGELOG.md deleted file mode 100644 index bdc6d1f268..0000000000 --- a/vendor/github.com/Masterminds/vcs/CHANGELOG.md +++ /dev/null @@ -1,148 +0,0 @@ -# 1.11.1 (2017-04-28) - -## Fixed -- #76: Fix submodule handling for Windows (thanks @m0j0hn) - -# 1.11.0 (2017-03-23) - -## Added -- #65: Exposed CmdFromDir function (thanks @erizocosmico) - -## Changed -- #69: Updated testing for Go 1.8 - -## Fixed -- #64: Testing fatal error if bzr not installed (thanks @kevinburke) - -# 1.10.2 (2017-01-24) - -## Fixed -- #63: Remove extra quotes in submodule export (thanks @dt) - -# 1.10.1 (2017-01-18) - -## Fixed -- #62: Added windows testing via appveyor and fixed issues under windows. - -# 1.10.0 (2017-01-09) - -## Added -- #60: Handle Git submodules (thanks @sdboyer) -- #61: Add gometalinter to testing - -# 1.9.0 (2016-11-18) - -## Added -- #50: Auto-detect remotes with file:// prefix. -- #59: Testing against Go 1.7 - -## Changed -- Removed auto-detection for Google Code as the service is deprecated -- Added auto-detection of git.openstack.org - -## Fixed -- #53: Git not fetching tags off branch - -# 1.8.0 (2016-06-29) - -## Added -- #43: Detect when tool (e.g., git, svn, etc) not installed -- #49: Detect access denied and not found situations - -## Changed -- #48: Updated Go Report Gard url to new format -- Refactored SVN handling to detect when not in a top level directory -- Updating tagging to v[SemVer] structure for compatibility with other tools. - -## Fixed -- #45: Fixed hg's update method so that it pulls from remote before updates - -# 1.7.0 (2016-05-05) - -- Adds a glide.yaml file with some limited information. -- Implements #37: Ability to export source as a directory. -- Implements #36: Get current version-ish with Current method. This returns - a branch (if on tip) or equivalent tip, a tag if on a tag, or a revision if - on an individual revision. Note, the tip of branch is VCS specific so usage - may require detecting VCS type. - -# 1.6.1 (2016-04-27) - -- Fixed #30: tags from commit should not have ^{} appended (seen in git) -- Fixed #29: isDetachedHead fails with non-english locales (git) -- Fixed #33: Access denied and not found http errors causing xml parsing errors - -# 1.6.0 (2016-04-18) - -- Issue #26: Added Init method to initialize a repo at the local location - (thanks tony). -- Issue #19: Added method to retrieve tags for a commit. -- Issue #24: Reworked errors returned from common methods. Now differing - VCS implementations return the same errors. The original VCS specific error - is available on the error. See the docs for more details. -- Issue #25: Export the function RunFromDir which runs VCS commands from the - root of the local directory. This is useful for those that want to build and - extend on top of the vcs package (thanks tony). -- Issue #22: Added Ping command to test if remote location is present and - accessible. - -# 1.5.1 (2016-03-23) - -- Fixing bug parsing some Git commit dates. - -# 1.5.0 (2016-03-22) - -- Add Travis CI testing for Go 1.6. -- Issue #17: Add CommitInfo method allowing for a common way to get commit - metadata from all VCS. -- Autodetect types that have git@ or hg@ users. -- Autodetect git+ssh, bzr+ssh, git, and svn+ssh scheme urls. -- On Bitbucket for ssh style URLs retrieve the type from the URL. This allows - for private repo type detection. -- Issue #14: Autodetect ssh/scp style urls (thanks chonthu). - -# 1.4.1 (2016-03-07) - -- Fixes #16: some windows situations are unable to create parent directory. - -# 1.4.0 (2016-02-15) - -- Adding support for IBM JazzHub. - -# 1.3.1 (2016-01-27) - -- Issue #12: Failed to checkout Bzr repo when parent directory didn't - exist (thanks cyrilleverrier). - -# 1.3.0 (2015-11-09) - -- Issue #9: Added Date method to get the date/time of latest commit (thanks kamilchm). - -# 1.2.0 (2015-10-29) - -- Adding IsDirty method to detect a checkout with uncommitted changes. - -# 1.1.4 (2015-10-28) - -- Fixed #8: Git IsReference not detecting branches that have not been checked - out yet. - -# 1.1.3 (2015-10-21) - -- Fixing issue where there are multiple go-import statements for go redirects - -# 1.1.2 (2015-10-20) - -- Fixes #7: hg not checking out code when Get is called - -# 1.1.1 (2015-10-20) - -- Issue #6: Allow VCS commands to be run concurrently. - -# 1.1.0 (2015-10-19) - -- #5: Added output of failed command to returned errors. - -# 1.0.0 (2015-10-06) - -- Initial release. diff --git a/vendor/github.com/Masterminds/vcs/Makefile b/vendor/github.com/Masterminds/vcs/Makefile deleted file mode 100644 index 5d722c2f4b..0000000000 --- a/vendor/github.com/Masterminds/vcs/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -.PHONY: setup -setup: - go get -u gopkg.in/alecthomas/gometalinter.v1 - gometalinter.v1 --install - -.PHONY: test -test: validate lint - @echo "==> Running tests" - go test -v - -.PHONY: validate -validate: -# misspell finds the work adresář (used in bzr.go) as a mispelling of -# address. It finds adres. An issue has been filed at -# https://github.com/client9/misspell/issues/99. In the meantime adding -# adres to the ignore list. - @echo "==> Running static validations" - @gometalinter.v1 \ - --disable-all \ - --linter "misspell:misspell -i adres -j 1 {path}/*.go:PATH:LINE:COL:MESSAGE" \ - --enable deadcode \ - --severity deadcode:error \ - --enable gofmt \ - --enable gosimple \ - --enable ineffassign \ - --enable misspell \ - --enable vet \ - --tests \ - --vendor \ - --deadline 60s \ - ./... || exit_code=1 - -.PHONY: lint -lint: - @echo "==> Running linters" - @gometalinter.v1 \ - --disable-all \ - --enable golint \ - --vendor \ - --deadline 60s \ - ./... || : diff --git a/vendor/github.com/Masterminds/vcs/README.md b/vendor/github.com/Masterminds/vcs/README.md deleted file mode 100644 index a11268513b..0000000000 --- a/vendor/github.com/Masterminds/vcs/README.md +++ /dev/null @@ -1,48 +0,0 @@ -# VCS Repository Management for Go - -Manage repos in varying version control systems with ease through a common -interface. - -[![Build Status](https://travis-ci.org/Masterminds/vcs.svg)](https://travis-ci.org/Masterminds/vcs) [![GoDoc](https://godoc.org/github.com/Masterminds/vcs?status.png)](https://godoc.org/github.com/Masterminds/vcs) [![Go Report Card](https://goreportcard.com/badge/github.com/Masterminds/vcs)](https://goreportcard.com/report/github.com/Masterminds/vcs) -[![Build status](https://ci.appveyor.com/api/projects/status/vg3cjc561q2trobm?svg=true&passingText=windows%20build%20passing&failingText=windows%20build%20failing)](https://ci.appveyor.com/project/mattfarina/vcs) - - -## Quick Usage - -Quick usage: - - remote := "https://github.com/Masterminds/vcs" - local, _ := ioutil.TempDir("", "go-vcs") - repo, err := NewRepo(remote, local) - -In this case `NewRepo` will detect the VCS is Git and return a `GitRepo`. All of -the repos implement the `Repo` interface with a common set of features between -them. - -## Supported VCS - -Git, SVN, Bazaar (Bzr), and Mercurial (Hg) are currently supported. They each -have their own type (e.g., `GitRepo`) that follow a simple naming pattern. Each -type implements the `Repo` interface and has a constructor (e.g., `NewGitRepo`). -The constructors have the same signature as `NewRepo`. - -## Features - -- Clone or checkout a repository depending on the version control system. -- Pull updates to a repository. -- Get the currently checked out commit id. -- Checkout a commit id, branch, or tag (depending on the availability in the VCS). -- Get a list of tags and branches in the VCS. -- Check if a string value is a valid reference within the VCS. -- More... - -For more details see [the documentation](https://godoc.org/github.com/Masterminds/vcs). - -## Motivation - -The package `golang.org/x/tools/go/vcs` provides some valuable functionality -for working with packages in repositories in varying source control management -systems. That package, while useful and well tested, is designed with a specific -purpose in mind. Our uses went beyond the scope of that package. To implement -our scope we built a package that went beyond the functionality and scope -of `golang.org/x/tools/go/vcs`. diff --git a/vendor/github.com/Masterminds/vcs/appveyor.yml b/vendor/github.com/Masterminds/vcs/appveyor.yml deleted file mode 100644 index c0c9170fa7..0000000000 --- a/vendor/github.com/Masterminds/vcs/appveyor.yml +++ /dev/null @@ -1,26 +0,0 @@ - -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\Masterminds\vcs -shallow_clone: true - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -install: - - go version - - go env - - choco install -y bzr - - set PATH=C:\Program Files (x86)\Bazaar;%PATH% - - bzr --version - -build_script: - - go install -v ./... - -test_script: - - go test -v - -deploy: off diff --git a/vendor/github.com/Masterminds/vcs/bzr_test.go b/vendor/github.com/Masterminds/vcs/bzr_test.go deleted file mode 100644 index 4b2e50ec60..0000000000 --- a/vendor/github.com/Masterminds/vcs/bzr_test.go +++ /dev/null @@ -1,328 +0,0 @@ -package vcs - -import ( - "io/ioutil" - "path/filepath" - "time" - //"log" - "os" - "testing" -) - -// Canary test to ensure BzrRepo implements the Repo interface. -var _ Repo = &BzrRepo{} - -// To verify bzr is working we perform integration testing -// with a known bzr service. Due to the long time of repeatedly checking out -// repos these tests are structured to work together. - -func TestBzr(t *testing.T) { - - tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewBzrRepo("https://launchpad.net/govcstestbzrrepo", tempDir+"/govcstestbzrrepo") - if err != nil { - t.Fatal(err) - } - - if repo.Vcs() != Bzr { - t.Error("Bzr is detecting the wrong type") - } - - // Check the basic getters. - if repo.Remote() != "https://launchpad.net/govcstestbzrrepo" { - t.Error("Remote not set properly") - } - if repo.LocalPath() != tempDir+"/govcstestbzrrepo" { - t.Error("Local disk location not set properly") - } - - //Logger = log.New(os.Stdout, "", log.LstdFlags) - - // Do an initial clone. - err = repo.Get() - if err != nil { - t.Errorf("Unable to clone Bzr repo. Err was %s", err) - } - - // Verify Bzr repo is a Bzr repo - if !repo.CheckLocal() { - t.Error("Problem checking out repo or Bzr CheckLocal is not working") - } - - // Test internal lookup mechanism used outside of Bzr specific functionality. - ltype, err := DetectVcsFromFS(tempDir + "/govcstestbzrrepo") - if err != nil { - t.Error("detectVcsFromFS unable to Bzr repo") - } - if ltype != Bzr { - t.Errorf("detectVcsFromFS detected %s instead of Bzr type", ltype) - } - - // Test NewRepo on existing checkout. This should simply provide a working - // instance without error based on looking at the local directory. - nrepo, nrerr := NewRepo("https://launchpad.net/govcstestbzrrepo", tempDir+"/govcstestbzrrepo") - if nrerr != nil { - t.Error(nrerr) - } - // Verify the right oject is returned. It will check the local repo type. - if !nrepo.CheckLocal() { - t.Error("Wrong version returned from NewRepo") - } - - v, err := repo.Current() - if err != nil { - t.Errorf("Error trying Bzr Current: %s", err) - } - if v != "-1" { - t.Errorf("Current failed to detect Bzr on tip of branch. Got version: %s", v) - } - - err = repo.UpdateVersion("2") - if err != nil { - t.Errorf("Unable to update Bzr repo version. Err was %s", err) - } - - // Use Version to verify we are on the right version. - v, err = repo.Version() - if v != "2" { - t.Error("Error checking checked out Bzr version") - } - if err != nil { - t.Error(err) - } - - v, err = repo.Current() - if err != nil { - t.Errorf("Error trying Bzr Current: %s", err) - } - if v != "2" { - t.Errorf("Current failed to detect Bzr on rev 2 of branch. Got version: %s", v) - } - - // Use Date to verify we are on the right commit. - d, err := repo.Date() - if d.Format(longForm) != "2015-07-31 09:50:42 -0400" { - t.Error("Error checking checked out Bzr commit date") - } - if err != nil { - t.Error(err) - } - - // Perform an update. - err = repo.Update() - if err != nil { - t.Error(err) - } - - v, err = repo.Version() - if v != "3" { - t.Error("Error checking checked out Bzr version") - } - if err != nil { - t.Error(err) - } - - tags, err := repo.Tags() - if err != nil { - t.Error(err) - } - if tags[0] != "1.0.0" { - t.Error("Bzr tags is not reporting the correct version") - } - - tags, err = repo.TagsFromCommit("2") - if err != nil { - t.Error(err) - } - if len(tags) != 0 { - t.Error("Bzr is incorrectly returning tags for a commit") - } - - tags, err = repo.TagsFromCommit("3") - if err != nil { - t.Error(err) - } - if len(tags) != 1 || tags[0] != "1.0.0" { - t.Error("Bzr is incorrectly returning tags for a commit") - } - - branches, err := repo.Branches() - if err != nil { - t.Error(err) - } - if len(branches) != 0 { - t.Error("Bzr is incorrectly returning branches") - } - - if !repo.IsReference("1.0.0") { - t.Error("Bzr is reporting a reference is not one") - } - - if repo.IsReference("foo") { - t.Error("Bzr is reporting a non-existent reference is one") - } - - if repo.IsDirty() { - t.Error("Bzr incorrectly reporting dirty") - } - - ci, err := repo.CommitInfo("3") - if err != nil { - t.Error(err) - } - if ci.Commit != "3" { - t.Error("Bzr.CommitInfo wrong commit id") - } - if ci.Author != "Matt Farina " { - t.Error("Bzr.CommitInfo wrong author") - } - if ci.Message != "Updated Readme with pointer." { - t.Error("Bzr.CommitInfo wrong message") - } - ti, err := time.Parse(time.RFC1123Z, "Fri, 31 Jul 2015 09:51:37 -0400") - if err != nil { - t.Error(err) - } - if !ti.Equal(ci.Date) { - t.Error("Bzr.CommitInfo wrong date") - } - - _, err = repo.CommitInfo("asdfasdfasdf") - if err != ErrRevisionUnavailable { - t.Error("Bzr didn't return expected ErrRevisionUnavailable") - } - - tempDir2, err := ioutil.TempDir("", "go-vcs-bzr-tests-export") - if err != nil { - t.Fatalf("Error creating temp directory: %s", err) - } - defer func() { - err = os.RemoveAll(tempDir2) - if err != nil { - t.Error(err) - } - }() - - exportDir := filepath.Join(tempDir2, "src") - - err = repo.ExportDir(exportDir) - if err != nil { - t.Errorf("Unable to export Bzr repo. Err was %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, "Readme.md")) - if err != nil { - t.Errorf("Error checking exported file in Bzr: %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) - if err != nil { - if found := os.IsNotExist(err); !found { - t.Errorf("Error checking exported metadata in Bzr: %s", err) - } - } else { - t.Error("Error checking Bzr metadata. It exists.") - } -} - -func TestBzrCheckLocal(t *testing.T) { - // Verify repo.CheckLocal fails for non-Bzr directories. - // TestBzr is already checking on a valid repo - tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, _ := NewBzrRepo("", tempDir) - if repo.CheckLocal() { - t.Error("Bzr CheckLocal does not identify non-Bzr location") - } - - // Test NewRepo when there's no local. This should simply provide a working - // instance without error based on looking at the remote localtion. - _, nrerr := NewRepo("https://launchpad.net/govcstestbzrrepo", tempDir+"/govcstestbzrrepo") - if nrerr != nil { - t.Error(nrerr) - } -} - -func TestBzrPing(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewBzrRepo("https://launchpad.net/govcstestbzrrepo", tempDir) - if err != nil { - t.Error(err) - } - - ping := repo.Ping() - if !ping { - t.Error("Bzr unable to ping working repo") - } - - repo, err = NewBzrRepo("https://launchpad.net/ihopethisneverexistsbecauseitshouldnt", tempDir) - if err != nil { - t.Error(err) - } - - ping = repo.Ping() - if ping { - t.Error("Bzr got a ping response from when it should not have") - } -} - -func TestBzrInit(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-bzr-tests") - repoDir := tempDir + "/repo" - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewBzrRepo(repoDir, repoDir) - if err != nil { - t.Error(err) - } - - err = repo.Init() - if err != nil { - t.Error(err) - } - - v, err := repo.Version() - if err != nil { - t.Error(err) - } - if v != "0" { - t.Errorf("Bzr Init returns wrong version: %s", v) - } -} diff --git a/vendor/github.com/Masterminds/vcs/errors_test.go b/vendor/github.com/Masterminds/vcs/errors_test.go deleted file mode 100644 index 2effd7ccab..0000000000 --- a/vendor/github.com/Masterminds/vcs/errors_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package vcs - -import ( - "errors" - "testing" -) - -func TestNewRemoteError(t *testing.T) { - base := errors.New("Foo error") - out := "This is a test" - msg := "remote error msg" - - e := NewRemoteError(msg, base, out) - - switch e.(type) { - case *RemoteError: - // This is the right error type - default: - t.Error("Wrong error type returned from NewRemoteError") - } -} - -func TestNewLocalError(t *testing.T) { - base := errors.New("Foo error") - out := "This is a test" - msg := "local error msg" - - e := NewLocalError(msg, base, out) - - switch e.(type) { - case *LocalError: - // This is the right error type - default: - t.Error("Wrong error type returned from NewLocalError") - } -} diff --git a/vendor/github.com/Masterminds/vcs/git_test.go b/vendor/github.com/Masterminds/vcs/git_test.go deleted file mode 100644 index b58c2c2efd..0000000000 --- a/vendor/github.com/Masterminds/vcs/git_test.go +++ /dev/null @@ -1,599 +0,0 @@ -package vcs - -import ( - "fmt" - "io/ioutil" - "path/filepath" - "time" - //"log" - "os" - "testing" -) - -// Canary test to ensure GitRepo implements the Repo interface. -var _ Repo = &GitRepo{} - -// To verify git is working we perform integration testing -// with a known git service. - -func TestGit(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-git-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewGitRepo("https://github.com/Masterminds/VCSTestRepo", tempDir+"/VCSTestRepo") - if err != nil { - t.Error(err) - } - - if repo.Vcs() != Git { - t.Error("Git is detecting the wrong type") - } - - // Check the basic getters. - if repo.Remote() != "https://github.com/Masterminds/VCSTestRepo" { - t.Error("Remote not set properly") - } - if repo.LocalPath() != tempDir+"/VCSTestRepo" { - t.Error("Local disk location not set properly") - } - - //Logger = log.New(os.Stdout, "", log.LstdFlags) - - // Do an initial clone. - err = repo.Get() - if err != nil { - t.Errorf("Unable to clone Git repo. Err was %s", err) - } - - // Verify Git repo is a Git repo - if !repo.CheckLocal() { - t.Error("Problem checking out repo or Git CheckLocal is not working") - } - - // Test internal lookup mechanism used outside of Git specific functionality. - ltype, err := DetectVcsFromFS(tempDir + "/VCSTestRepo") - if err != nil { - t.Error("detectVcsFromFS unable to Git repo") - } - if ltype != Git { - t.Errorf("detectVcsFromFS detected %s instead of Git type", ltype) - } - - // Test NewRepo on existing checkout. This should simply provide a working - // instance without error based on looking at the local directory. - nrepo, nrerr := NewRepo("https://github.com/Masterminds/VCSTestRepo", tempDir+"/VCSTestRepo") - if nrerr != nil { - t.Error(nrerr) - } - // Verify the right oject is returned. It will check the local repo type. - if !nrepo.CheckLocal() { - t.Error("Wrong version returned from NewRepo") - } - - // Perform an update. - err = repo.Update() - if err != nil { - t.Error(err) - } - - v, err := repo.Current() - if err != nil { - t.Errorf("Error trying Git Current: %s", err) - } - if v != "master" { - t.Errorf("Current failed to detect Git on tip of master. Got version: %s", v) - } - - // Set the version using the short hash. - err = repo.UpdateVersion("806b07b") - if err != nil { - t.Errorf("Unable to update Git repo version. Err was %s", err) - } - - // Once a ref has been checked out the repo is in a detached head state. - // Trying to pull in an update in this state will cause an error. Update - // should cleanly handle this. Pulling on a branch (tested elsewhere) and - // skipping that here. - err = repo.Update() - if err != nil { - t.Error(err) - } - - // Use Version to verify we are on the right version. - v, err = repo.Version() - if v != "806b07b08faa21cfbdae93027904f80174679402" { - t.Error("Error checking checked out Git version") - } - if err != nil { - t.Error(err) - } - - v, err = repo.Current() - if err != nil { - t.Errorf("Error trying Git Current for ref: %s", err) - } - if v != "806b07b08faa21cfbdae93027904f80174679402" { - t.Errorf("Current failed to detect Git on ref of branch. Got version: %s", v) - } - - // Use Date to verify we are on the right commit. - d, err := repo.Date() - if d.Format(longForm) != "2015-07-29 09:46:39 -0400" { - t.Error("Error checking checked out Git commit date") - } - if err != nil { - t.Error(err) - } - - // Verify that we can set the version something other than short hash - err = repo.UpdateVersion("master") - if err != nil { - t.Errorf("Unable to update Git repo version. Err was %s", err) - } - err = repo.UpdateVersion("806b07b08faa21cfbdae93027904f80174679402") - if err != nil { - t.Errorf("Unable to update Git repo version. Err was %s", err) - } - v, err = repo.Version() - if v != "806b07b08faa21cfbdae93027904f80174679402" { - t.Error("Error checking checked out Git version") - } - if err != nil { - t.Error(err) - } - - tags, err := repo.Tags() - if err != nil { - t.Error(err) - } - - var hasRelTag bool - var hasOffMasterTag bool - - for _, tv := range tags { - if tv == "1.0.0" { - hasRelTag = true - } else if tv == "off-master-tag" { - hasOffMasterTag = true - } - } - - if !hasRelTag { - t.Error("Git tags unable to find release tag on master") - } - if !hasOffMasterTag { - t.Error("Git tags did not fetch tags not on master") - } - - tags, err = repo.TagsFromCommit("74dd547545b7df4aa285bcec1b54e2b76f726395") - if err != nil { - t.Error(err) - } - if len(tags) != 0 { - t.Error("Git is incorrectly returning tags for a commit") - } - - tags, err = repo.TagsFromCommit("30605f6ac35fcb075ad0bfa9296f90a7d891523e") - if err != nil { - t.Error(err) - } - if len(tags) != 1 || tags[0] != "1.0.0" { - t.Error("Git is incorrectly returning tags for a commit") - } - - branches, err := repo.Branches() - if err != nil { - t.Error(err) - } - // The branches should be HEAD, master, other, and test. - if branches[3] != "test" { - t.Error("Git is incorrectly returning branches") - } - - if !repo.IsReference("1.0.0") { - t.Error("Git is reporting a reference is not one") - } - - if repo.IsReference("foo") { - t.Error("Git is reporting a non-existent reference is one") - } - - if repo.IsDirty() { - t.Error("Git incorrectly reporting dirty") - } - - ci, err := repo.CommitInfo("806b07b08faa21cfbdae93027904f80174679402") - if err != nil { - t.Error(err) - } - if ci.Commit != "806b07b08faa21cfbdae93027904f80174679402" { - t.Error("Git.CommitInfo wrong commit id") - } - if ci.Author != "Matt Farina " { - t.Error("Git.CommitInfo wrong author") - } - if ci.Message != "Update README.md" { - t.Error("Git.CommitInfo wrong message") - } - ti, err := time.Parse(time.RFC1123Z, "Wed, 29 Jul 2015 09:46:39 -0400") - if err != nil { - t.Error(err) - } - if !ti.Equal(ci.Date) { - t.Error("Git.CommitInfo wrong date") - } - - _, err = repo.CommitInfo("asdfasdfasdf") - if err != ErrRevisionUnavailable { - t.Error("Git didn't return expected ErrRevisionUnavailable") - } - - tempDir2, err := ioutil.TempDir("", "go-vcs-git-tests-export") - if err != nil { - t.Fatalf("Error creating temp directory: %s", err) - } - defer func() { - err = os.RemoveAll(tempDir2) - if err != nil { - t.Error(err) - } - }() - - exportDir := filepath.Join(tempDir2, "src") - - err = repo.ExportDir(exportDir) - if err != nil { - t.Errorf("Unable to export Git repo. Err was %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, "README.md")) - if err != nil { - t.Errorf("Error checking exported file in Git: %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) - if err != nil { - if found := os.IsNotExist(err); !found { - t.Errorf("Error checking exported metadata in Git: %s", err) - } - } else { - t.Error("Error checking Git metadata. It exists.") - } -} - -func TestGitCheckLocal(t *testing.T) { - // Verify repo.CheckLocal fails for non-Git directories. - // TestGit is already checking on a valid repo - tempDir, err := ioutil.TempDir("", "go-vcs-git-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, _ := NewGitRepo("", tempDir) - if repo.CheckLocal() { - t.Error("Git CheckLocal does not identify non-Git location") - } - - // Test NewRepo when there's no local. This should simply provide a working - // instance without error based on looking at the remote localtion. - _, nrerr := NewRepo("https://github.com/Masterminds/VCSTestRepo", tempDir+"/VCSTestRepo") - if nrerr != nil { - t.Error(nrerr) - } -} - -func TestGitPing(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-git-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewGitRepo("https://github.com/Masterminds/VCSTestRepo", tempDir) - if err != nil { - t.Error(err) - } - - ping := repo.Ping() - if !ping { - t.Error("Git unable to ping working repo") - } - - repo, err = NewGitRepo("https://github.com/Masterminds/ihopethisneverexistsbecauseitshouldnt", tempDir) - if err != nil { - t.Error(err) - } - - ping = repo.Ping() - if ping { - t.Error("Git got a ping response from when it should not have") - } -} - -func TestGitInit(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-git-tests") - repoDir := tempDir + "/repo" - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewGitRepo(repoDir, repoDir) - if err != nil { - t.Error(err) - } - - err = repo.Init() - if err != nil { - t.Error(err) - } - - _, err = repo.RunFromDir("git", "status") - if err != nil { - t.Error(err) - } -} - -func TestGitSubmoduleHandling(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-git-submodule-tests") - if err != nil { - t.Fatal(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - dumplocal := func(err error) string { - if terr, ok := err.(*LocalError); ok { - return fmt.Sprintf("msg: %s\norig: %s\nout: %s", terr.Error(), terr.Original(), terr.Out()) - } - return err.Error() - } - - subdirExists := func(dir ...string) bool { - _, err := os.Stat(filepath.Join(append([]string{tempDir}, dir...)...)) - return err == nil - } - - // Initial clone should get version with two submodules, each of which have - // their own submodule - repo, err := NewGitRepo("https://github.com/sdboyer/subm", tempDir) - if err != nil { - t.Fatal(dumplocal(err)) - } - err = repo.Get() - if err != nil { - t.Fatalf("unable to clone Git repo. Err was %s", dumplocal(err)) - } - - // Verify we are on the right version. - v, err := repo.Version() - if v != "18e3a5f6fc7f6d577e732e7a5ab2caf990efbf8f" { - t.Fatalf("did not start from expected rev, tests could fail - bailing out (got %s)", v) - } - if err != nil { - t.Fatal(dumplocal(err)) - } - - if !subdirExists("subm1", ".git") { - t.Fatal("subm1 submodule does not exist on initial clone/checkout") - } - if !subdirExists("subm1", "dep-test", ".git") { - t.Fatal("dep-test submodule nested under subm1 does not exist on initial clone/checkout") - } - - if !subdirExists("subm-again", ".git") { - t.Fatal("subm-again submodule does not exist on initial clone/checkout") - } - if !subdirExists("subm-again", "dep-test", ".git") { - t.Fatal("dep-test submodule nested under subm-again does not exist on initial clone/checkout") - } - - // Now switch to version with no submodules, make sure they all go away - err = repo.UpdateVersion("e677f82015f72ac1c8fafa66b5463163b3597af2") - if err != nil { - t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) - } - - if subdirExists("subm1") { - t.Fatal("checking out version without submodule did not clean up immediate submodules") - } - if subdirExists("subm1", "dep-test") { - t.Fatal("checking out version without submodule did not clean up nested submodules") - } - if subdirExists("subm-again") { - t.Fatal("checking out version without submodule did not clean up immediate submodules") - } - if subdirExists("subm-again", "dep-test") { - t.Fatal("checking out version without submodule did not clean up nested submodules") - } - - err = repo.UpdateVersion("aaf7aa1bc4c3c682cc530eca8f80417088ee8540") - if err != nil { - t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) - } - - if !subdirExists("subm1", ".git") { - t.Fatal("checking out version with immediate submodule did not set up git subrepo") - } - - err = repo.UpdateVersion("6cc4669af468f3b4f16e7e96275ad01ade5b522f") - if err != nil { - t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) - } - - if !subdirExists("subm1", "dep-test", ".git") { - t.Fatal("checking out version with nested submodule did not set up nested git subrepo") - } - - err = repo.UpdateVersion("aaf7aa1bc4c3c682cc530eca8f80417088ee8540") - if err != nil { - t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) - } - - if subdirExists("subm1", "dep-test") { - t.Fatal("rolling back to version without nested submodule did not clean up the nested submodule") - } - - err = repo.UpdateVersion("18e3a5f6fc7f6d577e732e7a5ab2caf990efbf8f") - if err != nil { - t.Fatalf("checking out needed version failed with err: %s", dumplocal(err)) - } - - if !subdirExists("subm1", ".git") { - t.Fatal("subm1 submodule does not exist after switch from other commit") - } - if !subdirExists("subm1", "dep-test", ".git") { - t.Fatal("dep-test submodule nested under subm1 does not exist after switch from other commit") - } - - if !subdirExists("subm-again", ".git") { - t.Fatal("subm-again submodule does not exist after switch from other commit") - } - if !subdirExists("subm-again", "dep-test", ".git") { - t.Fatal("dep-test submodule nested under subm-again does not exist after switch from other commit") - } - -} - -func TestGitSubmoduleHandling2(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-git-submodule-tests2") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewGitRepo("https://github.com/cloudfoundry/sonde-go", tempDir+"/VCSTestRepo2") - if err != nil { - t.Error(err) - } - - if repo.Vcs() != Git { - t.Error("Git is detecting the wrong type") - } - - // Check the basic getters. - if repo.Remote() != "https://github.com/cloudfoundry/sonde-go" { - t.Error("Remote not set properly") - } - if repo.LocalPath() != tempDir+"/VCSTestRepo2" { - t.Error("Local disk location not set properly") - } - - //Logger = log.New(os.Stdout, "", log.LstdFlags) - - // Do an initial clone. - err = repo.Get() - if err != nil { - t.Errorf("Unable to clone Git repo. Err was %s", err) - } - - // Verify Git repo is a Git repo - if !repo.CheckLocal() { - t.Error("Problem checking out repo or Git CheckLocal is not working") - } - - // Test internal lookup mechanism used outside of Git specific functionality. - ltype, err := DetectVcsFromFS(tempDir + "/VCSTestRepo2") - if err != nil { - t.Error("detectVcsFromFS unable to Git repo") - } - if ltype != Git { - t.Errorf("detectVcsFromFS detected %s instead of Git type", ltype) - } - - // Test NewRepo on existing checkout. This should simply provide a working - // instance without error based on looking at the local directory. - nrepo, nrerr := NewRepo("https://github.com/cloudfoundry/sonde-go", tempDir+"/VCSTestRepo2") - if nrerr != nil { - t.Error(nrerr) - } - // Verify the right oject is returned. It will check the local repo type. - if !nrepo.CheckLocal() { - t.Error("Wrong version returned from NewRepo") - } - - // Perform an update. - err = repo.Update() - if err != nil { - t.Error(err) - } - - v, err := repo.Current() - if err != nil { - t.Errorf("Error trying Git Current: %s", err) - } - if v != "master" { - t.Errorf("Current failed to detect Git on tip of master. Got version: %s", v) - } - - - tempDir2, err := ioutil.TempDir("", "go-vcs-git-tests-export") - if err != nil { - t.Fatalf("Error creating temp directory: %s", err) - } - defer func() { - err = os.RemoveAll(tempDir2) - if err != nil { - t.Error(err) - } - }() - - exportDir := filepath.Join(tempDir2, "src") - - err = repo.ExportDir(exportDir) - if err != nil { - t.Errorf("Unable to export Git repo. Err was %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, "README.md")) - if err != nil { - t.Errorf("Error checking exported file in Git: %s", err) - } - - _, err = os.Stat(filepath.Join( filepath.Join(exportDir, "definitions"), "README.md")) - if err != nil { - t.Errorf("Error checking exported file in Git: %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) - if err != nil { - if found := os.IsNotExist(err); !found { - t.Errorf("Error checking exported metadata in Git: %s", err) - } - } else { - t.Error("Error checking Git metadata. It exists.") - } -} diff --git a/vendor/github.com/Masterminds/vcs/glide.yaml b/vendor/github.com/Masterminds/vcs/glide.yaml deleted file mode 100644 index b96e0bd3e7..0000000000 --- a/vendor/github.com/Masterminds/vcs/glide.yaml +++ /dev/null @@ -1,8 +0,0 @@ -package: github.com/Masterminds/vcs -homepage: https://github.com/Masterminds/vcs -license: MIT -owners: -- name: Matt Farina - email: matt@mattfarina.com - homepage: https://www.mattfarina.com/ -import: [] diff --git a/vendor/github.com/Masterminds/vcs/hg_test.go b/vendor/github.com/Masterminds/vcs/hg_test.go deleted file mode 100644 index 6b19f72809..0000000000 --- a/vendor/github.com/Masterminds/vcs/hg_test.go +++ /dev/null @@ -1,332 +0,0 @@ -package vcs - -import ( - "io/ioutil" - "path/filepath" - "strings" - "time" - //"log" - "os" - "testing" -) - -// Canary test to ensure HgRepo implements the Repo interface. -var _ Repo = &HgRepo{} - -// To verify hg is working we perform integration testing -// with a known hg service. - -func TestHg(t *testing.T) { - - tempDir, err := ioutil.TempDir("", "go-vcs-hg-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewHgRepo("https://bitbucket.org/mattfarina/testhgrepo", tempDir+"/testhgrepo") - if err != nil { - t.Error(err) - } - - if repo.Vcs() != Hg { - t.Error("Hg is detecting the wrong type") - } - - // Check the basic getters. - if repo.Remote() != "https://bitbucket.org/mattfarina/testhgrepo" { - t.Error("Remote not set properly") - } - if repo.LocalPath() != tempDir+"/testhgrepo" { - t.Error("Local disk location not set properly") - } - - //Logger = log.New(os.Stdout, "", log.LstdFlags) - - // Do an initial clone. - err = repo.Get() - if err != nil { - t.Errorf("Unable to clone Hg repo. Err was %s", err) - } - - // Verify Hg repo is a Hg repo - if !repo.CheckLocal() { - t.Error("Problem checking out repo or Hg CheckLocal is not working") - } - - // Test internal lookup mechanism used outside of Hg specific functionality. - ltype, err := DetectVcsFromFS(tempDir + "/testhgrepo") - if err != nil { - t.Error("detectVcsFromFS unable to Hg repo") - } - if ltype != Hg { - t.Errorf("detectVcsFromFS detected %s instead of Hg type", ltype) - } - - // Test NewRepo on existing checkout. This should simply provide a working - // instance without error based on looking at the local directory. - nrepo, nrerr := NewRepo("https://bitbucket.org/mattfarina/testhgrepo", tempDir+"/testhgrepo") - if nrerr != nil { - t.Error(nrerr) - } - // Verify the right oject is returned. It will check the local repo type. - if !nrepo.CheckLocal() { - t.Error("Wrong version returned from NewRepo") - } - - v, err := repo.Current() - if err != nil { - t.Errorf("Error trying Hg Current: %s", err) - } - if v != "default" { - t.Errorf("Current failed to detect Hg on tip of default. Got version: %s", v) - } - - // Set the version using the short hash. - err = repo.UpdateVersion("a5494ba2177f") - if err != nil { - t.Errorf("Unable to update Hg repo version. Err was %s", err) - } - - // Use Version to verify we are on the right version. - v, err = repo.Version() - if v != "a5494ba2177ff9ef26feb3c155dfecc350b1a8ef" { - t.Errorf("Error checking checked out Hg version: %s", v) - } - if err != nil { - t.Error(err) - } - - v, err = repo.Current() - if err != nil { - t.Errorf("Error trying Hg Current for ref: %s", err) - } - if v != "a5494ba2177ff9ef26feb3c155dfecc350b1a8ef" { - t.Errorf("Current failed to detect Hg on ref of branch. Got version: %s", v) - } - - // Use Date to verify we are on the right commit. - d, err := repo.Date() - if err != nil { - t.Error(err) - } - if d.Format(longForm) != "2015-07-30 16:14:08 -0400" { - t.Error("Error checking checked out Hg commit date. Got wrong date:", d) - } - - // Perform an update. - err = repo.Update() - if err != nil { - t.Error(err) - } - - v, err = repo.Version() - if v != "9c6ccbca73e8a1351c834f33f57f1f7a0329ad35" { - t.Errorf("Error checking checked out Hg version: %s", v) - } - if err != nil { - t.Error(err) - } - - tags, err := repo.Tags() - if err != nil { - t.Error(err) - } - if tags[1] != "1.0.0" { - t.Error("Hg tags is not reporting the correct version") - } - - tags, err = repo.TagsFromCommit("a5494ba2177f") - if err != nil { - t.Error(err) - } - if len(tags) != 0 { - t.Error("Hg is incorrectly returning tags for a commit") - } - - tags, err = repo.TagsFromCommit("d680e82228d2") - if err != nil { - t.Error(err) - } - if len(tags) != 1 || tags[0] != "1.0.0" { - t.Error("Hg is incorrectly returning tags for a commit") - } - - branches, err := repo.Branches() - if err != nil { - t.Error(err) - } - // The branches should be HEAD, master, and test. - if branches[0] != "test" { - t.Error("Hg is incorrectly returning branches") - } - - if !repo.IsReference("1.0.0") { - t.Error("Hg is reporting a reference is not one") - } - - if !repo.IsReference("test") { - t.Error("Hg is reporting a reference is not one") - } - - if repo.IsReference("foo") { - t.Error("Hg is reporting a non-existent reference is one") - } - - if repo.IsDirty() { - t.Error("Hg incorrectly reporting dirty") - } - - ci, err := repo.CommitInfo("a5494ba2177f") - if err != nil { - t.Error(err) - } - if ci.Commit != "a5494ba2177ff9ef26feb3c155dfecc350b1a8ef" { - t.Error("Hg.CommitInfo wrong commit id") - } - if ci.Author != "Matt Farina " { - t.Error("Hg.CommitInfo wrong author") - } - if ci.Message != "A commit" { - t.Error("Hg.CommitInfo wrong message") - } - - ti := time.Unix(1438287248, 0) - if !ti.Equal(ci.Date) { - t.Error("Hg.CommitInfo wrong date") - } - - _, err = repo.CommitInfo("asdfasdfasdf") - if err != ErrRevisionUnavailable { - t.Error("Hg didn't return expected ErrRevisionUnavailable") - } - - tempDir2, err := ioutil.TempDir("", "go-vcs-hg-tests-export") - if err != nil { - t.Fatalf("Error creating temp directory: %s", err) - } - defer func() { - err = os.RemoveAll(tempDir2) - if err != nil { - t.Error(err) - } - }() - - exportDir := filepath.Join(tempDir2, "src") - - err = repo.ExportDir(exportDir) - if err != nil { - t.Errorf("Unable to export Hg repo. Err was %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, "Readme.md")) - if err != nil { - t.Errorf("Error checking exported file in Hg: %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) - if err != nil { - if found := os.IsNotExist(err); !found { - t.Errorf("Error checking exported metadata in Hg: %s", err) - } - } else { - t.Error("Error checking Hg metadata. It exists.") - } -} - -func TestHgCheckLocal(t *testing.T) { - // Verify repo.CheckLocal fails for non-Hg directories. - // TestHg is already checking on a valid repo - tempDir, err := ioutil.TempDir("", "go-vcs-hg-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, _ := NewHgRepo("", tempDir) - if repo.CheckLocal() { - t.Error("Hg CheckLocal does not identify non-Hg location") - } - - // Test NewRepo when there's no local. This should simply provide a working - // instance without error based on looking at the remote localtion. - _, nrerr := NewRepo("https://bitbucket.org/mattfarina/testhgrepo", tempDir+"/testhgrepo") - if nrerr != nil { - t.Error(nrerr) - } -} - -func TestHgPing(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-hg-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewHgRepo("https://bitbucket.org/mattfarina/testhgrepo", tempDir) - if err != nil { - t.Error(err) - } - - ping := repo.Ping() - if !ping { - t.Error("Hg unable to ping working repo") - } - - repo, err = NewHgRepo("https://bitbucket.org/mattfarina/ihopethisneverexistsbecauseitshouldnt", tempDir) - if err != nil { - t.Error(err) - } - - ping = repo.Ping() - if ping { - t.Error("Hg got a ping response from when it should not have") - } -} - -func TestHgInit(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-hg-tests") - repoDir := tempDir + "/repo" - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewHgRepo(repoDir, repoDir) - if err != nil { - t.Error(err) - } - - err = repo.Init() - if err != nil { - t.Error(err) - } - - v, err := repo.Version() - if err != nil { - t.Error(err) - } - if !strings.HasPrefix(v, "000000") { - t.Errorf("Hg Init reporting wrong initial version: %s", v) - } -} diff --git a/vendor/github.com/Masterminds/vcs/repo_test.go b/vendor/github.com/Masterminds/vcs/repo_test.go deleted file mode 100644 index 8c083b3fc4..0000000000 --- a/vendor/github.com/Masterminds/vcs/repo_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package vcs - -import ( - "fmt" - "io/ioutil" - "os" - "testing" -) - -func ExampleNewRepo() { - remote := "https://github.com/Masterminds/vcs" - local, _ := ioutil.TempDir("", "go-vcs") - repo, _ := NewRepo(remote, local) - // Returns: instance of GitRepo - - repo.Vcs() - // Returns Git as this is a Git repo - - err := repo.Get() - // Pulls down a repo, or a checkout in the case of SVN, and returns an - // error if that didn't happen successfully. - if err != nil { - fmt.Println(err) - } - - err = repo.UpdateVersion("master") - // Checkouts out a specific version. In most cases this can be a commit id, - // branch, or tag. - if err != nil { - fmt.Println(err) - } -} - -func TestTypeSwitch(t *testing.T) { - - // To test repo type switching we checkout as SVN and then try to get it as - // a git repo afterwards. - tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewSvnRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir+string(os.PathSeparator)+"VCSTestRepo") - if err != nil { - t.Error(err) - } - err = repo.Get() - if err != nil { - t.Errorf("Unable to checkout SVN repo for repo switching tests. Err was %s", err) - } - - _, err = NewRepo("https://github.com/Masterminds/VCSTestRepo", tempDir+string(os.PathSeparator)+"VCSTestRepo") - if err != ErrWrongVCS { - t.Errorf("Not detecting repo switch from SVN to Git") - } -} - -func TestDepInstalled(t *testing.T) { - i := depInstalled("git") - if !i { - t.Error("depInstalled not finding installed dep.") - } - - i = depInstalled("thisreallyisntinstalled") - if i { - t.Error("depInstalled finding not installed dep.") - } -} diff --git a/vendor/github.com/Masterminds/vcs/svn_test.go b/vendor/github.com/Masterminds/vcs/svn_test.go deleted file mode 100644 index 93fc139ab9..0000000000 --- a/vendor/github.com/Masterminds/vcs/svn_test.go +++ /dev/null @@ -1,337 +0,0 @@ -package vcs - -import ( - "io/ioutil" - "path/filepath" - "time" - //"log" - "os" - "testing" -) - -// To verify svn is working we perform integration testing -// with a known svn service. - -// Canary test to ensure SvnRepo implements the Repo interface. -var _ Repo = &SvnRepo{} - -func TestSvn(t *testing.T) { - - tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewSvnRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir+string(os.PathSeparator)+"VCSTestRepo") - if err != nil { - t.Error(err) - } - - if repo.Vcs() != Svn { - t.Error("Svn is detecting the wrong type") - } - - // Check the basic getters. - if repo.Remote() != "https://github.com/Masterminds/VCSTestRepo/trunk" { - t.Error("Remote not set properly") - } - if repo.LocalPath() != tempDir+string(os.PathSeparator)+"VCSTestRepo" { - t.Error("Local disk location not set properly") - } - - //Logger = log.New(os.Stdout, "", log.LstdFlags) - - // Do an initial checkout. - err = repo.Get() - if err != nil { - t.Errorf("Unable to checkout SVN repo. Err was %s", err) - } - - // Verify SVN repo is a SVN repo - if !repo.CheckLocal() { - t.Error("Problem checking out repo or SVN CheckLocal is not working") - } - - // Verify an incorrect remote is caught when NewSvnRepo is used on an existing location - _, nrerr := NewSvnRepo("https://github.com/Masterminds/VCSTestRepo/unknownbranch", tempDir+"/VCSTestRepo") - if nrerr != ErrWrongRemote { - t.Error("ErrWrongRemote was not triggered for SVN") - } - - // Test internal lookup mechanism used outside of Hg specific functionality. - ltype, err := DetectVcsFromFS(tempDir + "/VCSTestRepo") - if err != nil { - t.Error("detectVcsFromFS unable to Svn repo") - } - if ltype != Svn { - t.Errorf("detectVcsFromFS detected %s instead of Svn type", ltype) - } - - // Commenting out auto-detection tests for SVN. NewRepo automatically detects - // GitHub to be a Git repo and that's an issue for this test. Need an - // SVN host that can autodetect from before using this test again. - // - // Test NewRepo on existing checkout. This should simply provide a working - // instance without error based on looking at the local directory. - // nrepo, nrerr := NewRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir+"/VCSTestRepo") - // if nrerr != nil { - // t.Error(nrerr) - // } - // // Verify the right oject is returned. It will check the local repo type. - // if nrepo.CheckLocal() == false { - // t.Error("Wrong version returned from NewRepo") - // } - - v, err := repo.Current() - if err != nil { - t.Errorf("Error trying Svn Current: %s", err) - } - if v != "HEAD" { - t.Errorf("Current failed to detect Svn on HEAD. Got version: %s", v) - } - - // Update the version to a previous version. - err = repo.UpdateVersion("r2") - if err != nil { - t.Errorf("Unable to update SVN repo version. Err was %s", err) - } - - // Use Version to verify we are on the right version. - v, err = repo.Version() - if v != "2" { - t.Error("Error checking checked SVN out version") - } - if err != nil { - t.Error(err) - } - - v, err = repo.Current() - if err != nil { - t.Errorf("Error trying Svn Current for ref: %s", err) - } - if v != "2" { - t.Errorf("Current failed to detect Svn on HEAD. Got version: %s", v) - } - - // Perform an update which should take up back to the latest version. - err = repo.Update() - if err != nil { - t.Error(err) - } - - // Make sure we are on a newer version because of the update. - v, err = repo.Version() - if v == "2" { - t.Error("Error with version. Still on old version. Update failed") - } - if err != nil { - t.Error(err) - } - - // Use Date to verify we are on the right commit. - d, err := repo.Date() - if d.Format(longForm) != "2015-07-29 13:47:03 +0000" { - t.Error("Error checking checked out Svn commit date") - } - if err != nil { - t.Error(err) - } - - tags, err := repo.Tags() - if err != nil { - t.Error(err) - } - if len(tags) != 0 { - t.Error("Svn is incorrectly returning tags") - } - - tags, err = repo.TagsFromCommit("2") - if err != nil { - t.Error(err) - } - if len(tags) != 0 { - t.Error("Svn is incorrectly returning tags for a commit") - } - - branches, err := repo.Branches() - if err != nil { - t.Error(err) - } - if len(branches) != 0 { - t.Error("Svn is incorrectly returning branches") - } - - if !repo.IsReference("r4") { - t.Error("Svn is reporting a reference is not one") - } - - if repo.IsReference("55") { - t.Error("Svn is reporting a non-existent reference is one") - } - - if repo.IsDirty() { - t.Error("Svn incorrectly reporting dirty") - } - - ci, err := repo.CommitInfo("2") - if err != nil { - t.Error(err) - } - if ci.Commit != "2" { - t.Error("Svn.CommitInfo wrong commit id") - } - if ci.Author != "matt.farina" { - t.Error("Svn.CommitInfo wrong author") - } - if ci.Message != "Update README.md" { - t.Error("Svn.CommitInfo wrong message") - } - ti, err := time.Parse(time.RFC3339Nano, "2015-07-29T13:46:20.000000Z") - if err != nil { - t.Error(err) - } - if !ti.Equal(ci.Date) { - t.Error("Svn.CommitInfo wrong date") - } - - _, err = repo.CommitInfo("555555555") - if err != ErrRevisionUnavailable { - t.Error("Svn didn't return expected ErrRevisionUnavailable") - } - - tempDir2, err := ioutil.TempDir("", "go-vcs-svn-tests-export") - if err != nil { - t.Fatalf("Error creating temp directory: %s", err) - } - defer func() { - err = os.RemoveAll(tempDir2) - if err != nil { - t.Error(err) - } - }() - - exportDir := filepath.Join(tempDir2, "src") - - err = repo.ExportDir(exportDir) - if err != nil { - t.Errorf("Unable to export Svn repo. Err was %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, "README.md")) - if err != nil { - t.Errorf("Error checking exported file in Svn: %s", err) - } - - _, err = os.Stat(filepath.Join(exportDir, string(repo.Vcs()))) - if err != nil { - if found := os.IsNotExist(err); !found { - t.Errorf("Error checking exported metadata in Svn: %s", err) - } - } else { - t.Error("Error checking Svn metadata. It exists.") - } -} - -func TestSvnCheckLocal(t *testing.T) { - // Verify repo.CheckLocal fails for non-SVN directories. - // TestSvn is already checking on a valid repo - tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, _ := NewSvnRepo("", tempDir) - if repo.CheckLocal() { - t.Error("SVN CheckLocal does not identify non-SVN location") - } - - // Test NewRepo when there's no local. This should simply provide a working - // instance without error based on looking at the remote localtion. - _, nrerr := NewRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir+"/VCSTestRepo") - if nrerr != nil { - t.Error(nrerr) - } -} - -func TestSvnPing(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewSvnRepo("https://github.com/Masterminds/VCSTestRepo/trunk", tempDir) - if err != nil { - t.Error(err) - } - - ping := repo.Ping() - if !ping { - t.Error("Svn unable to ping working repo") - } - - repo, err = NewSvnRepo("https://github.com/Masterminds/ihopethisneverexistsbecauseitshouldnt", tempDir) - if err != nil { - t.Error(err) - } - - ping = repo.Ping() - if ping { - t.Error("Svn got a ping response from when it should not have") - } -} - -func TestSvnInit(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-svn-tests") - remoteDir := tempDir + string(os.PathSeparator) + "remoteDir" - localDir := tempDir + string(os.PathSeparator) + "localDir" - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - repo, err := NewSvnRepo(remoteDir, localDir) - if err != nil { - t.Error(err) - } - - err = repo.Init() - if err != nil { - t.Error(err) - } - - err = repo.Get() - if err != nil { - t.Error(err) - } - - v, err := repo.Version() - if err != nil { - t.Error(err) - } - if v != "0" { - t.Errorf("Svn Init returns wrong version: %s", v) - } -} diff --git a/vendor/github.com/Masterminds/vcs/vcs_remote_lookup_test.go b/vendor/github.com/Masterminds/vcs/vcs_remote_lookup_test.go deleted file mode 100644 index 938cb0ebc5..0000000000 --- a/vendor/github.com/Masterminds/vcs/vcs_remote_lookup_test.go +++ /dev/null @@ -1,137 +0,0 @@ -package vcs - -import ( - "io/ioutil" - "os" - "os/exec" - "runtime" - "strings" - "testing" -) - -func TestVCSLookup(t *testing.T) { - // TODO: Expand to make sure it detected the right vcs. - urlList := map[string]struct { - work bool - t Type - }{ - "https://github.com/masterminds": {work: false, t: Git}, - "https://github.com/Masterminds/VCSTestRepo": {work: true, t: Git}, - "https://bitbucket.org/mattfarina/testhgrepo": {work: true, t: Hg}, - "https://bitbucket.org/mattfarina/repo-does-not-exist": {work: false, t: Hg}, - "https://bitbucket.org/mattfarina/private-repo-for-vcs-testing": {work: false, t: Hg}, - "https://launchpad.net/govcstestbzrrepo/trunk": {work: true, t: Bzr}, - "https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo": {work: true, t: Bzr}, - "https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo/trunk": {work: true, t: Bzr}, - "https://git.launchpad.net/govcstestgitrepo": {work: true, t: Git}, - "https://git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo": {work: true, t: Git}, - "https://hub.jazz.net/git/user1/pkgname": {work: true, t: Git}, - "https://hub.jazz.net/git/user1/pkgname/subpkg/subpkg/subpkg": {work: true, t: Git}, - "https://hubs.jazz.net/git/user1/pkgname": {work: false, t: Git}, - "https://example.com/foo/bar.git": {work: true, t: Git}, - "https://example.com/foo/bar.svn": {work: true, t: Svn}, - "https://example.com/foo/bar/baz.bzr": {work: true, t: Bzr}, - "https://example.com/foo/bar/baz.hg": {work: true, t: Hg}, - "https://gopkg.in/tomb.v1": {work: true, t: Git}, - "https://golang.org/x/net": {work: true, t: Git}, - "https://speter.net/go/exp/math/dec/inf": {work: true, t: Git}, - "https://git.openstack.org/foo/bar": {work: true, t: Git}, - "git@github.com:Masterminds/vcs.git": {work: true, t: Git}, - "git@example.com:foo.git": {work: true, t: Git}, - "ssh://hg@bitbucket.org/mattfarina/testhgrepo": {work: true, t: Hg}, - "git@bitbucket.org:mattfarina/glide-bitbucket-example.git": {work: true, t: Git}, - "git+ssh://example.com/foo/bar": {work: true, t: Git}, - "git://example.com/foo/bar": {work: true, t: Git}, - "bzr+ssh://example.com/foo/bar": {work: true, t: Bzr}, - "svn+ssh://example.com/foo/bar": {work: true, t: Svn}, - "git@example.com:foo/bar": {work: true, t: Git}, - "hg@example.com:foo/bar": {work: true, t: Hg}, - } - - for u, c := range urlList { - ty, _, err := detectVcsFromRemote(u) - if err == nil && !c.work { - t.Errorf("Error detecting VCS from URL(%s)", u) - } - - if err == ErrCannotDetectVCS && c.work { - t.Errorf("Error detecting VCS from URL(%s)", u) - } - - if err != nil && c.work { - t.Errorf("Error detecting VCS from URL(%s): %s", u, err) - } - - if err != nil && - err != ErrCannotDetectVCS && - !strings.HasSuffix(err.Error(), "Not Found") && - !strings.HasSuffix(err.Error(), "Access Denied") && - !c.work { - t.Errorf("Unexpected error returned (%s): %s", u, err) - } - - if c.work && ty != c.t { - t.Errorf("Incorrect VCS type returned(%s)", u) - } - } -} - -func TestVCSFileLookup(t *testing.T) { - tempDir, err := ioutil.TempDir("", "go-vcs-file-lookup-tests") - if err != nil { - t.Error(err) - } - defer func() { - err = os.RemoveAll(tempDir) - if err != nil { - t.Error(err) - } - }() - - _, err = exec.Command("git", "init", tempDir).CombinedOutput() - if err != nil { - t.Error(err) - } - - // On Windows it should be file:// followed by /C:\for\bar. That / before - // the drive needs to be included in testing. - var pth string - if runtime.GOOS == "windows" { - pth = "file:///" + tempDir - } else { - pth = "file://" + tempDir - } - ty, _, err := detectVcsFromRemote(pth) - - if err != nil { - t.Errorf("Unable to detect file:// path: %s", err) - } - - if ty != Git { - t.Errorf("Detected wrong type from file:// path. Found type %v", ty) - } -} - -func TestNotFound(t *testing.T) { - _, _, err := detectVcsFromRemote("https://mattfarina.com/notfound") - if err == nil || !strings.HasSuffix(err.Error(), " Not Found") { - t.Errorf("Failed to find not found repo") - } - - _, err = NewRepo("https://mattfarina.com/notfound", "") - if err == nil || !strings.HasSuffix(err.Error(), " Not Found") { - t.Errorf("Failed to find not found repo") - } -} - -func TestAccessDenied(t *testing.T) { - _, _, err := detectVcsFromRemote("https://bitbucket.org/mattfarina/private-repo-for-vcs-testing") - if err == nil || err.Error() != "Access Denied" { - t.Errorf("Failed to detect access denied") - } - - _, err = NewRepo("https://bitbucket.org/mattfarina/private-repo-for-vcs-testing", "") - if err == nil || err.Error() != "Access Denied" { - t.Errorf("Failed to detect access denied") - } -} diff --git a/vendor/github.com/armon/go-radix/.gitignore b/vendor/github.com/armon/go-radix/.gitignore deleted file mode 100644 index 00268614f0..0000000000 --- a/vendor/github.com/armon/go-radix/.gitignore +++ /dev/null @@ -1,22 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe diff --git a/vendor/github.com/armon/go-radix/.travis.yml b/vendor/github.com/armon/go-radix/.travis.yml deleted file mode 100644 index 1a0bbea6c7..0000000000 --- a/vendor/github.com/armon/go-radix/.travis.yml +++ /dev/null @@ -1,3 +0,0 @@ -language: go -go: - - tip diff --git a/vendor/github.com/armon/go-radix/README.md b/vendor/github.com/armon/go-radix/README.md deleted file mode 100644 index 26f42a2837..0000000000 --- a/vendor/github.com/armon/go-radix/README.md +++ /dev/null @@ -1,38 +0,0 @@ -go-radix [![Build Status](https://travis-ci.org/armon/go-radix.png)](https://travis-ci.org/armon/go-radix) -========= - -Provides the `radix` package that implements a [radix tree](http://en.wikipedia.org/wiki/Radix_tree). -The package only provides a single `Tree` implementation, optimized for sparse nodes. - -As a radix tree, it provides the following: - * O(k) operations. In many cases, this can be faster than a hash table since - the hash function is an O(k) operation, and hash tables have very poor cache locality. - * Minimum / Maximum value lookups - * Ordered iteration - -For an immutable variant, see [go-immutable-radix](https://github.com/hashicorp/go-immutable-radix). - -Documentation -============= - -The full documentation is available on [Godoc](http://godoc.org/github.com/armon/go-radix). - -Example -======= - -Below is a simple example of usage - -```go -// Create a tree -r := radix.New() -r.Insert("foo", 1) -r.Insert("bar", 2) -r.Insert("foobar", 2) - -// Find the longest prefix match -m, _, _ := r.LongestPrefix("foozip") -if m != "foo" { - panic("should be foo") -} -``` - diff --git a/vendor/github.com/armon/go-radix/radix_test.go b/vendor/github.com/armon/go-radix/radix_test.go deleted file mode 100644 index 300f0d4759..0000000000 --- a/vendor/github.com/armon/go-radix/radix_test.go +++ /dev/null @@ -1,319 +0,0 @@ -package radix - -import ( - crand "crypto/rand" - "fmt" - "reflect" - "sort" - "testing" -) - -func TestRadix(t *testing.T) { - var min, max string - inp := make(map[string]interface{}) - for i := 0; i < 1000; i++ { - gen := generateUUID() - inp[gen] = i - if gen < min || i == 0 { - min = gen - } - if gen > max || i == 0 { - max = gen - } - } - - r := NewFromMap(inp) - if r.Len() != len(inp) { - t.Fatalf("bad length: %v %v", r.Len(), len(inp)) - } - - r.Walk(func(k string, v interface{}) bool { - println(k) - return false - }) - - for k, v := range inp { - out, ok := r.Get(k) - if !ok { - t.Fatalf("missing key: %v", k) - } - if out != v { - t.Fatalf("value mis-match: %v %v", out, v) - } - } - - // Check min and max - outMin, _, _ := r.Minimum() - if outMin != min { - t.Fatalf("bad minimum: %v %v", outMin, min) - } - outMax, _, _ := r.Maximum() - if outMax != max { - t.Fatalf("bad maximum: %v %v", outMax, max) - } - - for k, v := range inp { - out, ok := r.Delete(k) - if !ok { - t.Fatalf("missing key: %v", k) - } - if out != v { - t.Fatalf("value mis-match: %v %v", out, v) - } - } - if r.Len() != 0 { - t.Fatalf("bad length: %v", r.Len()) - } -} - -func TestRoot(t *testing.T) { - r := New() - _, ok := r.Delete("") - if ok { - t.Fatalf("bad") - } - _, ok = r.Insert("", true) - if ok { - t.Fatalf("bad") - } - val, ok := r.Get("") - if !ok || val != true { - t.Fatalf("bad: %v", val) - } - val, ok = r.Delete("") - if !ok || val != true { - t.Fatalf("bad: %v", val) - } -} - -func TestDelete(t *testing.T) { - - r := New() - - s := []string{"", "A", "AB"} - - for _, ss := range s { - r.Insert(ss, true) - } - - for _, ss := range s { - _, ok := r.Delete(ss) - if !ok { - t.Fatalf("bad %q", ss) - } - } -} - -func TestLongestPrefix(t *testing.T) { - r := New() - - keys := []string{ - "", - "foo", - "foobar", - "foobarbaz", - "foobarbazzip", - "foozip", - } - for _, k := range keys { - r.Insert(k, nil) - } - if r.Len() != len(keys) { - t.Fatalf("bad len: %v %v", r.Len(), len(keys)) - } - - type exp struct { - inp string - out string - } - cases := []exp{ - {"a", ""}, - {"abc", ""}, - {"fo", ""}, - {"foo", "foo"}, - {"foob", "foo"}, - {"foobar", "foobar"}, - {"foobarba", "foobar"}, - {"foobarbaz", "foobarbaz"}, - {"foobarbazzi", "foobarbaz"}, - {"foobarbazzip", "foobarbazzip"}, - {"foozi", "foo"}, - {"foozip", "foozip"}, - {"foozipzap", "foozip"}, - } - for _, test := range cases { - m, _, ok := r.LongestPrefix(test.inp) - if !ok { - t.Fatalf("no match: %v", test) - } - if m != test.out { - t.Fatalf("mis-match: %v %v", m, test) - } - } -} - -func TestWalkPrefix(t *testing.T) { - r := New() - - keys := []string{ - "foobar", - "foo/bar/baz", - "foo/baz/bar", - "foo/zip/zap", - "zipzap", - } - for _, k := range keys { - r.Insert(k, nil) - } - if r.Len() != len(keys) { - t.Fatalf("bad len: %v %v", r.Len(), len(keys)) - } - - type exp struct { - inp string - out []string - } - cases := []exp{ - { - "f", - []string{"foobar", "foo/bar/baz", "foo/baz/bar", "foo/zip/zap"}, - }, - { - "foo", - []string{"foobar", "foo/bar/baz", "foo/baz/bar", "foo/zip/zap"}, - }, - { - "foob", - []string{"foobar"}, - }, - { - "foo/", - []string{"foo/bar/baz", "foo/baz/bar", "foo/zip/zap"}, - }, - { - "foo/b", - []string{"foo/bar/baz", "foo/baz/bar"}, - }, - { - "foo/ba", - []string{"foo/bar/baz", "foo/baz/bar"}, - }, - { - "foo/bar", - []string{"foo/bar/baz"}, - }, - { - "foo/bar/baz", - []string{"foo/bar/baz"}, - }, - { - "foo/bar/bazoo", - []string{}, - }, - { - "z", - []string{"zipzap"}, - }, - } - - for _, test := range cases { - out := []string{} - fn := func(s string, v interface{}) bool { - out = append(out, s) - return false - } - r.WalkPrefix(test.inp, fn) - sort.Strings(out) - sort.Strings(test.out) - if !reflect.DeepEqual(out, test.out) { - t.Fatalf("mis-match: %v %v", out, test.out) - } - } -} - -func TestWalkPath(t *testing.T) { - r := New() - - keys := []string{ - "foo", - "foo/bar", - "foo/bar/baz", - "foo/baz/bar", - "foo/zip/zap", - "zipzap", - } - for _, k := range keys { - r.Insert(k, nil) - } - if r.Len() != len(keys) { - t.Fatalf("bad len: %v %v", r.Len(), len(keys)) - } - - type exp struct { - inp string - out []string - } - cases := []exp{ - { - "f", - []string{}, - }, - { - "foo", - []string{"foo"}, - }, - { - "foo/", - []string{"foo"}, - }, - { - "foo/ba", - []string{"foo"}, - }, - { - "foo/bar", - []string{"foo", "foo/bar"}, - }, - { - "foo/bar/baz", - []string{"foo", "foo/bar", "foo/bar/baz"}, - }, - { - "foo/bar/bazoo", - []string{"foo", "foo/bar", "foo/bar/baz"}, - }, - { - "z", - []string{}, - }, - } - - for _, test := range cases { - out := []string{} - fn := func(s string, v interface{}) bool { - out = append(out, s) - return false - } - r.WalkPath(test.inp, fn) - sort.Strings(out) - sort.Strings(test.out) - if !reflect.DeepEqual(out, test.out) { - t.Fatalf("mis-match: %v %v", out, test.out) - } - } -} - -// generateUUID is used to generate a random UUID -func generateUUID() string { - buf := make([]byte, 16) - if _, err := crand.Read(buf); err != nil { - panic(fmt.Errorf("failed to read random bytes: %v", err)) - } - - return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x", - buf[0:4], - buf[4:6], - buf[6:8], - buf[8:10], - buf[10:16]) -} diff --git a/vendor/github.com/go-yaml/yaml/.travis.yml b/vendor/github.com/go-yaml/yaml/.travis.yml deleted file mode 100644 index 004172a2e3..0000000000 --- a/vendor/github.com/go-yaml/yaml/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: go - -go: - - 1.4 - - 1.5 - - 1.6 - - tip - -go_import_path: gopkg.in/yaml.v2 diff --git a/vendor/github.com/go-yaml/yaml/README.md b/vendor/github.com/go-yaml/yaml/README.md deleted file mode 100644 index 1884de6a7d..0000000000 --- a/vendor/github.com/go-yaml/yaml/README.md +++ /dev/null @@ -1,131 +0,0 @@ -# YAML support for the Go language - -Introduction ------------- - -The yaml package enables Go programs to comfortably encode and decode YAML -values. It was developed within [Canonical](https://www.canonical.com) as -part of the [juju](https://juju.ubuntu.com) project, and is based on a -pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) -C library to parse and generate YAML data quickly and reliably. - -Compatibility -------------- - -The yaml package supports most of YAML 1.1 and 1.2, including support for -anchors, tags, map merging, etc. Multi-document unmarshalling is not yet -implemented, and base-60 floats from YAML 1.1 are purposefully not -supported since they're a poor design and are gone in YAML 1.2. - -Installation and usage ----------------------- - -The import path for the package is *gopkg.in/yaml.v2*. - -To install it, run: - - go get gopkg.in/yaml.v2 - -API documentation ------------------ - -If opened in a browser, the import path itself leads to the API documentation: - - * [https://gopkg.in/yaml.v2](https://gopkg.in/yaml.v2) - -API stability -------------- - -The package API for yaml v2 will remain stable as described in [gopkg.in](https://gopkg.in). - - -License -------- - -The yaml package is licensed under the Apache License 2.0. Please see the LICENSE file for details. - - -Example -------- - -```Go -package main - -import ( - "fmt" - "log" - - "gopkg.in/yaml.v2" -) - -var data = ` -a: Easy! -b: - c: 2 - d: [3, 4] -` - -type T struct { - A string - B struct { - RenamedC int `yaml:"c"` - D []int `yaml:",flow"` - } -} - -func main() { - t := T{} - - err := yaml.Unmarshal([]byte(data), &t) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- t:\n%v\n\n", t) - - d, err := yaml.Marshal(&t) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- t dump:\n%s\n\n", string(d)) - - m := make(map[interface{}]interface{}) - - err = yaml.Unmarshal([]byte(data), &m) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- m:\n%v\n\n", m) - - d, err = yaml.Marshal(&m) - if err != nil { - log.Fatalf("error: %v", err) - } - fmt.Printf("--- m dump:\n%s\n\n", string(d)) -} -``` - -This example will generate the following output: - -``` ---- t: -{Easy! {2 [3 4]}} - ---- t dump: -a: Easy! -b: - c: 2 - d: [3, 4] - - ---- m: -map[a:Easy! b:map[c:2 d:[3 4]]] - ---- m dump: -a: Easy! -b: - c: 2 - d: - - 3 - - 4 -``` - diff --git a/vendor/github.com/go-yaml/yaml/decode_test.go b/vendor/github.com/go-yaml/yaml/decode_test.go deleted file mode 100644 index a6fea0f20a..0000000000 --- a/vendor/github.com/go-yaml/yaml/decode_test.go +++ /dev/null @@ -1,998 +0,0 @@ -package yaml_test - -import ( - "errors" - . "gopkg.in/check.v1" - "gopkg.in/yaml.v2" - "math" - "net" - "reflect" - "strings" - "time" -) - -var unmarshalIntTest = 123 - -var unmarshalTests = []struct { - data string - value interface{} -}{ - { - "", - &struct{}{}, - }, { - "{}", &struct{}{}, - }, { - "v: hi", - map[string]string{"v": "hi"}, - }, { - "v: hi", map[string]interface{}{"v": "hi"}, - }, { - "v: true", - map[string]string{"v": "true"}, - }, { - "v: true", - map[string]interface{}{"v": true}, - }, { - "v: 10", - map[string]interface{}{"v": 10}, - }, { - "v: 0b10", - map[string]interface{}{"v": 2}, - }, { - "v: 0xA", - map[string]interface{}{"v": 10}, - }, { - "v: 4294967296", - map[string]int64{"v": 4294967296}, - }, { - "v: 0.1", - map[string]interface{}{"v": 0.1}, - }, { - "v: .1", - map[string]interface{}{"v": 0.1}, - }, { - "v: .Inf", - map[string]interface{}{"v": math.Inf(+1)}, - }, { - "v: -.Inf", - map[string]interface{}{"v": math.Inf(-1)}, - }, { - "v: -10", - map[string]interface{}{"v": -10}, - }, { - "v: -.1", - map[string]interface{}{"v": -0.1}, - }, - - // Simple values. - { - "123", - &unmarshalIntTest, - }, - - // Floats from spec - { - "canonical: 6.8523e+5", - map[string]interface{}{"canonical": 6.8523e+5}, - }, { - "expo: 685.230_15e+03", - map[string]interface{}{"expo": 685.23015e+03}, - }, { - "fixed: 685_230.15", - map[string]interface{}{"fixed": 685230.15}, - }, { - "neginf: -.inf", - map[string]interface{}{"neginf": math.Inf(-1)}, - }, { - "fixed: 685_230.15", - map[string]float64{"fixed": 685230.15}, - }, - //{"sexa: 190:20:30.15", map[string]interface{}{"sexa": 0}}, // Unsupported - //{"notanum: .NaN", map[string]interface{}{"notanum": math.NaN()}}, // Equality of NaN fails. - - // Bools from spec - { - "canonical: y", - map[string]interface{}{"canonical": true}, - }, { - "answer: NO", - map[string]interface{}{"answer": false}, - }, { - "logical: True", - map[string]interface{}{"logical": true}, - }, { - "option: on", - map[string]interface{}{"option": true}, - }, { - "option: on", - map[string]bool{"option": true}, - }, - // Ints from spec - { - "canonical: 685230", - map[string]interface{}{"canonical": 685230}, - }, { - "decimal: +685_230", - map[string]interface{}{"decimal": 685230}, - }, { - "octal: 02472256", - map[string]interface{}{"octal": 685230}, - }, { - "hexa: 0x_0A_74_AE", - map[string]interface{}{"hexa": 685230}, - }, { - "bin: 0b1010_0111_0100_1010_1110", - map[string]interface{}{"bin": 685230}, - }, { - "bin: -0b101010", - map[string]interface{}{"bin": -42}, - }, { - "decimal: +685_230", - map[string]int{"decimal": 685230}, - }, - - //{"sexa: 190:20:30", map[string]interface{}{"sexa": 0}}, // Unsupported - - // Nulls from spec - { - "empty:", - map[string]interface{}{"empty": nil}, - }, { - "canonical: ~", - map[string]interface{}{"canonical": nil}, - }, { - "english: null", - map[string]interface{}{"english": nil}, - }, { - "~: null key", - map[interface{}]string{nil: "null key"}, - }, { - "empty:", - map[string]*bool{"empty": nil}, - }, - - // Flow sequence - { - "seq: [A,B]", - map[string]interface{}{"seq": []interface{}{"A", "B"}}, - }, { - "seq: [A,B,C,]", - map[string][]string{"seq": []string{"A", "B", "C"}}, - }, { - "seq: [A,1,C]", - map[string][]string{"seq": []string{"A", "1", "C"}}, - }, { - "seq: [A,1,C]", - map[string][]int{"seq": []int{1}}, - }, { - "seq: [A,1,C]", - map[string]interface{}{"seq": []interface{}{"A", 1, "C"}}, - }, - // Block sequence - { - "seq:\n - A\n - B", - map[string]interface{}{"seq": []interface{}{"A", "B"}}, - }, { - "seq:\n - A\n - B\n - C", - map[string][]string{"seq": []string{"A", "B", "C"}}, - }, { - "seq:\n - A\n - 1\n - C", - map[string][]string{"seq": []string{"A", "1", "C"}}, - }, { - "seq:\n - A\n - 1\n - C", - map[string][]int{"seq": []int{1}}, - }, { - "seq:\n - A\n - 1\n - C", - map[string]interface{}{"seq": []interface{}{"A", 1, "C"}}, - }, - - // Literal block scalar - { - "scalar: | # Comment\n\n literal\n\n \ttext\n\n", - map[string]string{"scalar": "\nliteral\n\n\ttext\n"}, - }, - - // Folded block scalar - { - "scalar: > # Comment\n\n folded\n line\n \n next\n line\n * one\n * two\n\n last\n line\n\n", - map[string]string{"scalar": "\nfolded line\nnext line\n * one\n * two\n\nlast line\n"}, - }, - - // Map inside interface with no type hints. - { - "a: {b: c}", - map[interface{}]interface{}{"a": map[interface{}]interface{}{"b": "c"}}, - }, - - // Structs and type conversions. - { - "hello: world", - &struct{ Hello string }{"world"}, - }, { - "a: {b: c}", - &struct{ A struct{ B string } }{struct{ B string }{"c"}}, - }, { - "a: {b: c}", - &struct{ A *struct{ B string } }{&struct{ B string }{"c"}}, - }, { - "a: {b: c}", - &struct{ A map[string]string }{map[string]string{"b": "c"}}, - }, { - "a: {b: c}", - &struct{ A *map[string]string }{&map[string]string{"b": "c"}}, - }, { - "a:", - &struct{ A map[string]string }{}, - }, { - "a: 1", - &struct{ A int }{1}, - }, { - "a: 1", - &struct{ A float64 }{1}, - }, { - "a: 1.0", - &struct{ A int }{1}, - }, { - "a: 1.0", - &struct{ A uint }{1}, - }, { - "a: [1, 2]", - &struct{ A []int }{[]int{1, 2}}, - }, { - "a: 1", - &struct{ B int }{0}, - }, { - "a: 1", - &struct { - B int "a" - }{1}, - }, { - "a: y", - &struct{ A bool }{true}, - }, - - // Some cross type conversions - { - "v: 42", - map[string]uint{"v": 42}, - }, { - "v: -42", - map[string]uint{}, - }, { - "v: 4294967296", - map[string]uint64{"v": 4294967296}, - }, { - "v: -4294967296", - map[string]uint64{}, - }, - - // int - { - "int_max: 2147483647", - map[string]int{"int_max": math.MaxInt32}, - }, - { - "int_min: -2147483648", - map[string]int{"int_min": math.MinInt32}, - }, - { - "int_overflow: 9223372036854775808", // math.MaxInt64 + 1 - map[string]int{}, - }, - - // int64 - { - "int64_max: 9223372036854775807", - map[string]int64{"int64_max": math.MaxInt64}, - }, - { - "int64_max_base2: 0b111111111111111111111111111111111111111111111111111111111111111", - map[string]int64{"int64_max_base2": math.MaxInt64}, - }, - { - "int64_min: -9223372036854775808", - map[string]int64{"int64_min": math.MinInt64}, - }, - { - "int64_neg_base2: -0b111111111111111111111111111111111111111111111111111111111111111", - map[string]int64{"int64_neg_base2": -math.MaxInt64}, - }, - { - "int64_overflow: 9223372036854775808", // math.MaxInt64 + 1 - map[string]int64{}, - }, - - // uint - { - "uint_min: 0", - map[string]uint{"uint_min": 0}, - }, - { - "uint_max: 4294967295", - map[string]uint{"uint_max": math.MaxUint32}, - }, - { - "uint_underflow: -1", - map[string]uint{}, - }, - - // uint64 - { - "uint64_min: 0", - map[string]uint{"uint64_min": 0}, - }, - { - "uint64_max: 18446744073709551615", - map[string]uint64{"uint64_max": math.MaxUint64}, - }, - { - "uint64_max_base2: 0b1111111111111111111111111111111111111111111111111111111111111111", - map[string]uint64{"uint64_max_base2": math.MaxUint64}, - }, - { - "uint64_maxint64: 9223372036854775807", - map[string]uint64{"uint64_maxint64": math.MaxInt64}, - }, - { - "uint64_underflow: -1", - map[string]uint64{}, - }, - - // float32 - { - "float32_max: 3.40282346638528859811704183484516925440e+38", - map[string]float32{"float32_max": math.MaxFloat32}, - }, - { - "float32_nonzero: 1.401298464324817070923729583289916131280e-45", - map[string]float32{"float32_nonzero": math.SmallestNonzeroFloat32}, - }, - { - "float32_maxuint64: 18446744073709551615", - map[string]float32{"float32_maxuint64": float32(math.MaxUint64)}, - }, - { - "float32_maxuint64+1: 18446744073709551616", - map[string]float32{"float32_maxuint64+1": float32(math.MaxUint64 + 1)}, - }, - - // float64 - { - "float64_max: 1.797693134862315708145274237317043567981e+308", - map[string]float64{"float64_max": math.MaxFloat64}, - }, - { - "float64_nonzero: 4.940656458412465441765687928682213723651e-324", - map[string]float64{"float64_nonzero": math.SmallestNonzeroFloat64}, - }, - { - "float64_maxuint64: 18446744073709551615", - map[string]float64{"float64_maxuint64": float64(math.MaxUint64)}, - }, - { - "float64_maxuint64+1: 18446744073709551616", - map[string]float64{"float64_maxuint64+1": float64(math.MaxUint64 + 1)}, - }, - - // Overflow cases. - { - "v: 4294967297", - map[string]int32{}, - }, { - "v: 128", - map[string]int8{}, - }, - - // Quoted values. - { - "'1': '\"2\"'", - map[interface{}]interface{}{"1": "\"2\""}, - }, { - "v:\n- A\n- 'B\n\n C'\n", - map[string][]string{"v": []string{"A", "B\nC"}}, - }, - - // Explicit tags. - { - "v: !!float '1.1'", - map[string]interface{}{"v": 1.1}, - }, { - "v: !!null ''", - map[string]interface{}{"v": nil}, - }, { - "%TAG !y! tag:yaml.org,2002:\n---\nv: !y!int '1'", - map[string]interface{}{"v": 1}, - }, - - // Anchors and aliases. - { - "a: &x 1\nb: &y 2\nc: *x\nd: *y\n", - &struct{ A, B, C, D int }{1, 2, 1, 2}, - }, { - "a: &a {c: 1}\nb: *a", - &struct { - A, B struct { - C int - } - }{struct{ C int }{1}, struct{ C int }{1}}, - }, { - "a: &a [1, 2]\nb: *a", - &struct{ B []int }{[]int{1, 2}}, - }, { - "b: *a\na: &a {c: 1}", - &struct { - A, B struct { - C int - } - }{struct{ C int }{1}, struct{ C int }{1}}, - }, - - // Bug #1133337 - { - "foo: ''", - map[string]*string{"foo": new(string)}, - }, { - "foo: null", - map[string]string{"foo": ""}, - }, { - "foo: null", - map[string]interface{}{"foo": nil}, - }, - - // Ignored field - { - "a: 1\nb: 2\n", - &struct { - A int - B int "-" - }{1, 0}, - }, - - // Bug #1191981 - { - "" + - "%YAML 1.1\n" + - "--- !!str\n" + - `"Generic line break (no glyph)\n\` + "\n" + - ` Generic line break (glyphed)\n\` + "\n" + - ` Line separator\u2028\` + "\n" + - ` Paragraph separator\u2029"` + "\n", - "" + - "Generic line break (no glyph)\n" + - "Generic line break (glyphed)\n" + - "Line separator\u2028Paragraph separator\u2029", - }, - - // Struct inlining - { - "a: 1\nb: 2\nc: 3\n", - &struct { - A int - C inlineB `yaml:",inline"` - }{1, inlineB{2, inlineC{3}}}, - }, - - // Map inlining - { - "a: 1\nb: 2\nc: 3\n", - &struct { - A int - C map[string]int `yaml:",inline"` - }{1, map[string]int{"b": 2, "c": 3}}, - }, - - // bug 1243827 - { - "a: -b_c", - map[string]interface{}{"a": "-b_c"}, - }, - { - "a: +b_c", - map[string]interface{}{"a": "+b_c"}, - }, - { - "a: 50cent_of_dollar", - map[string]interface{}{"a": "50cent_of_dollar"}, - }, - - // Duration - { - "a: 3s", - map[string]time.Duration{"a": 3 * time.Second}, - }, - - // Issue #24. - { - "a: ", - map[string]string{"a": ""}, - }, - - // Base 60 floats are obsolete and unsupported. - { - "a: 1:1\n", - map[string]string{"a": "1:1"}, - }, - - // Binary data. - { - "a: !!binary gIGC\n", - map[string]string{"a": "\x80\x81\x82"}, - }, { - "a: !!binary |\n " + strings.Repeat("kJCQ", 17) + "kJ\n CQ\n", - map[string]string{"a": strings.Repeat("\x90", 54)}, - }, { - "a: !!binary |\n " + strings.Repeat("A", 70) + "\n ==\n", - map[string]string{"a": strings.Repeat("\x00", 52)}, - }, - - // Ordered maps. - { - "{b: 2, a: 1, d: 4, c: 3, sub: {e: 5}}", - &yaml.MapSlice{{"b", 2}, {"a", 1}, {"d", 4}, {"c", 3}, {"sub", yaml.MapSlice{{"e", 5}}}}, - }, - - // Issue #39. - { - "a:\n b:\n c: d\n", - map[string]struct{ B interface{} }{"a": {map[interface{}]interface{}{"c": "d"}}}, - }, - - // Custom map type. - { - "a: {b: c}", - M{"a": M{"b": "c"}}, - }, - - // Support encoding.TextUnmarshaler. - { - "a: 1.2.3.4\n", - map[string]net.IP{"a": net.IPv4(1, 2, 3, 4)}, - }, - { - "a: 2015-02-24T18:19:39Z\n", - map[string]time.Time{"a": time.Unix(1424801979, 0).In(time.UTC)}, - }, - - // Encode empty lists as zero-length slices. - { - "a: []", - &struct{ A []int }{[]int{}}, - }, - - // UTF-16-LE - { - "\xff\xfe\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00\n\x00", - M{"ñoño": "very yes"}, - }, - // UTF-16-LE with surrogate. - { - "\xff\xfe\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00 \x00=\xd8\xd4\xdf\n\x00", - M{"ñoño": "very yes 🟔"}, - }, - - // UTF-16-BE - { - "\xfe\xff\x00\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00\n", - M{"ñoño": "very yes"}, - }, - // UTF-16-BE with surrogate. - { - "\xfe\xff\x00\xf1\x00o\x00\xf1\x00o\x00:\x00 \x00v\x00e\x00r\x00y\x00 \x00y\x00e\x00s\x00 \xd8=\xdf\xd4\x00\n", - M{"ñoño": "very yes 🟔"}, - }, - - // YAML Float regex shouldn't match this - { - "a: 123456e1\n", - M{"a": "123456e1"}, - }, { - "a: 123456E1\n", - M{"a": "123456E1"}, - }, -} - -type M map[interface{}]interface{} - -type inlineB struct { - B int - inlineC `yaml:",inline"` -} - -type inlineC struct { - C int -} - -func (s *S) TestUnmarshal(c *C) { - for _, item := range unmarshalTests { - t := reflect.ValueOf(item.value).Type() - var value interface{} - switch t.Kind() { - case reflect.Map: - value = reflect.MakeMap(t).Interface() - case reflect.String: - value = reflect.New(t).Interface() - case reflect.Ptr: - value = reflect.New(t.Elem()).Interface() - default: - c.Fatalf("missing case for %s", t) - } - err := yaml.Unmarshal([]byte(item.data), value) - if _, ok := err.(*yaml.TypeError); !ok { - c.Assert(err, IsNil) - } - if t.Kind() == reflect.String { - c.Assert(*value.(*string), Equals, item.value) - } else { - c.Assert(value, DeepEquals, item.value) - } - } -} - -func (s *S) TestUnmarshalNaN(c *C) { - value := map[string]interface{}{} - err := yaml.Unmarshal([]byte("notanum: .NaN"), &value) - c.Assert(err, IsNil) - c.Assert(math.IsNaN(value["notanum"].(float64)), Equals, true) -} - -var unmarshalErrorTests = []struct { - data, error string -}{ - {"v: !!float 'error'", "yaml: cannot decode !!str `error` as a !!float"}, - {"v: [A,", "yaml: line 1: did not find expected node content"}, - {"v:\n- [A,", "yaml: line 2: did not find expected node content"}, - {"a: *b\n", "yaml: unknown anchor 'b' referenced"}, - {"a: &a\n b: *a\n", "yaml: anchor 'a' value contains itself"}, - {"value: -", "yaml: block sequence entries are not allowed in this context"}, - {"a: !!binary ==", "yaml: !!binary value contains invalid base64 data"}, - {"{[.]}", `yaml: invalid map key: \[\]interface \{\}\{"\."\}`}, - {"{{.}}", `yaml: invalid map key: map\[interface\ \{\}\]interface \{\}\{".":interface \{\}\(nil\)\}`}, -} - -func (s *S) TestUnmarshalErrors(c *C) { - for _, item := range unmarshalErrorTests { - var value interface{} - err := yaml.Unmarshal([]byte(item.data), &value) - c.Assert(err, ErrorMatches, item.error, Commentf("Partial unmarshal: %#v", value)) - } -} - -var unmarshalerTests = []struct { - data, tag string - value interface{} -}{ - {"_: {hi: there}", "!!map", map[interface{}]interface{}{"hi": "there"}}, - {"_: [1,A]", "!!seq", []interface{}{1, "A"}}, - {"_: 10", "!!int", 10}, - {"_: null", "!!null", nil}, - {`_: BAR!`, "!!str", "BAR!"}, - {`_: "BAR!"`, "!!str", "BAR!"}, - {"_: !!foo 'BAR!'", "!!foo", "BAR!"}, - {`_: ""`, "!!str", ""}, -} - -var unmarshalerResult = map[int]error{} - -type unmarshalerType struct { - value interface{} -} - -func (o *unmarshalerType) UnmarshalYAML(unmarshal func(v interface{}) error) error { - if err := unmarshal(&o.value); err != nil { - return err - } - if i, ok := o.value.(int); ok { - if result, ok := unmarshalerResult[i]; ok { - return result - } - } - return nil -} - -type unmarshalerPointer struct { - Field *unmarshalerType "_" -} - -type unmarshalerValue struct { - Field unmarshalerType "_" -} - -func (s *S) TestUnmarshalerPointerField(c *C) { - for _, item := range unmarshalerTests { - obj := &unmarshalerPointer{} - err := yaml.Unmarshal([]byte(item.data), obj) - c.Assert(err, IsNil) - if item.value == nil { - c.Assert(obj.Field, IsNil) - } else { - c.Assert(obj.Field, NotNil, Commentf("Pointer not initialized (%#v)", item.value)) - c.Assert(obj.Field.value, DeepEquals, item.value) - } - } -} - -func (s *S) TestUnmarshalerValueField(c *C) { - for _, item := range unmarshalerTests { - obj := &unmarshalerValue{} - err := yaml.Unmarshal([]byte(item.data), obj) - c.Assert(err, IsNil) - c.Assert(obj.Field, NotNil, Commentf("Pointer not initialized (%#v)", item.value)) - c.Assert(obj.Field.value, DeepEquals, item.value) - } -} - -func (s *S) TestUnmarshalerWholeDocument(c *C) { - obj := &unmarshalerType{} - err := yaml.Unmarshal([]byte(unmarshalerTests[0].data), obj) - c.Assert(err, IsNil) - value, ok := obj.value.(map[interface{}]interface{}) - c.Assert(ok, Equals, true, Commentf("value: %#v", obj.value)) - c.Assert(value["_"], DeepEquals, unmarshalerTests[0].value) -} - -func (s *S) TestUnmarshalerTypeError(c *C) { - unmarshalerResult[2] = &yaml.TypeError{[]string{"foo"}} - unmarshalerResult[4] = &yaml.TypeError{[]string{"bar"}} - defer func() { - delete(unmarshalerResult, 2) - delete(unmarshalerResult, 4) - }() - - type T struct { - Before int - After int - M map[string]*unmarshalerType - } - var v T - data := `{before: A, m: {abc: 1, def: 2, ghi: 3, jkl: 4}, after: B}` - err := yaml.Unmarshal([]byte(data), &v) - c.Assert(err, ErrorMatches, ""+ - "yaml: unmarshal errors:\n"+ - " line 1: cannot unmarshal !!str `A` into int\n"+ - " foo\n"+ - " bar\n"+ - " line 1: cannot unmarshal !!str `B` into int") - c.Assert(v.M["abc"], NotNil) - c.Assert(v.M["def"], IsNil) - c.Assert(v.M["ghi"], NotNil) - c.Assert(v.M["jkl"], IsNil) - - c.Assert(v.M["abc"].value, Equals, 1) - c.Assert(v.M["ghi"].value, Equals, 3) -} - -type proxyTypeError struct{} - -func (v *proxyTypeError) UnmarshalYAML(unmarshal func(interface{}) error) error { - var s string - var a int32 - var b int64 - if err := unmarshal(&s); err != nil { - panic(err) - } - if s == "a" { - if err := unmarshal(&b); err == nil { - panic("should have failed") - } - return unmarshal(&a) - } - if err := unmarshal(&a); err == nil { - panic("should have failed") - } - return unmarshal(&b) -} - -func (s *S) TestUnmarshalerTypeErrorProxying(c *C) { - type T struct { - Before int - After int - M map[string]*proxyTypeError - } - var v T - data := `{before: A, m: {abc: a, def: b}, after: B}` - err := yaml.Unmarshal([]byte(data), &v) - c.Assert(err, ErrorMatches, ""+ - "yaml: unmarshal errors:\n"+ - " line 1: cannot unmarshal !!str `A` into int\n"+ - " line 1: cannot unmarshal !!str `a` into int32\n"+ - " line 1: cannot unmarshal !!str `b` into int64\n"+ - " line 1: cannot unmarshal !!str `B` into int") -} - -type failingUnmarshaler struct{} - -var failingErr = errors.New("failingErr") - -func (ft *failingUnmarshaler) UnmarshalYAML(unmarshal func(interface{}) error) error { - return failingErr -} - -func (s *S) TestUnmarshalerError(c *C) { - err := yaml.Unmarshal([]byte("a: b"), &failingUnmarshaler{}) - c.Assert(err, Equals, failingErr) -} - -type sliceUnmarshaler []int - -func (su *sliceUnmarshaler) UnmarshalYAML(unmarshal func(interface{}) error) error { - var slice []int - err := unmarshal(&slice) - if err == nil { - *su = slice - return nil - } - - var intVal int - err = unmarshal(&intVal) - if err == nil { - *su = []int{intVal} - return nil - } - - return err -} - -func (s *S) TestUnmarshalerRetry(c *C) { - var su sliceUnmarshaler - err := yaml.Unmarshal([]byte("[1, 2, 3]"), &su) - c.Assert(err, IsNil) - c.Assert(su, DeepEquals, sliceUnmarshaler([]int{1, 2, 3})) - - err = yaml.Unmarshal([]byte("1"), &su) - c.Assert(err, IsNil) - c.Assert(su, DeepEquals, sliceUnmarshaler([]int{1})) -} - -// From http://yaml.org/type/merge.html -var mergeTests = ` -anchors: - list: - - &CENTER { "x": 1, "y": 2 } - - &LEFT { "x": 0, "y": 2 } - - &BIG { "r": 10 } - - &SMALL { "r": 1 } - -# All the following maps are equal: - -plain: - # Explicit keys - "x": 1 - "y": 2 - "r": 10 - label: center/big - -mergeOne: - # Merge one map - << : *CENTER - "r": 10 - label: center/big - -mergeMultiple: - # Merge multiple maps - << : [ *CENTER, *BIG ] - label: center/big - -override: - # Override - << : [ *BIG, *LEFT, *SMALL ] - "x": 1 - label: center/big - -shortTag: - # Explicit short merge tag - !!merge "<<" : [ *CENTER, *BIG ] - label: center/big - -longTag: - # Explicit merge long tag - ! "<<" : [ *CENTER, *BIG ] - label: center/big - -inlineMap: - # Inlined map - << : {"x": 1, "y": 2, "r": 10} - label: center/big - -inlineSequenceMap: - # Inlined map in sequence - << : [ *CENTER, {"r": 10} ] - label: center/big -` - -func (s *S) TestMerge(c *C) { - var want = map[interface{}]interface{}{ - "x": 1, - "y": 2, - "r": 10, - "label": "center/big", - } - - var m map[interface{}]interface{} - err := yaml.Unmarshal([]byte(mergeTests), &m) - c.Assert(err, IsNil) - for name, test := range m { - if name == "anchors" { - continue - } - c.Assert(test, DeepEquals, want, Commentf("test %q failed", name)) - } -} - -func (s *S) TestMergeStruct(c *C) { - type Data struct { - X, Y, R int - Label string - } - want := Data{1, 2, 10, "center/big"} - - var m map[string]Data - err := yaml.Unmarshal([]byte(mergeTests), &m) - c.Assert(err, IsNil) - for name, test := range m { - if name == "anchors" { - continue - } - c.Assert(test, Equals, want, Commentf("test %q failed", name)) - } -} - -var unmarshalNullTests = []func() interface{}{ - func() interface{} { var v interface{}; v = "v"; return &v }, - func() interface{} { var s = "s"; return &s }, - func() interface{} { var s = "s"; sptr := &s; return &sptr }, - func() interface{} { var i = 1; return &i }, - func() interface{} { var i = 1; iptr := &i; return &iptr }, - func() interface{} { m := map[string]int{"s": 1}; return &m }, - func() interface{} { m := map[string]int{"s": 1}; return m }, -} - -func (s *S) TestUnmarshalNull(c *C) { - for _, test := range unmarshalNullTests { - item := test() - zero := reflect.Zero(reflect.TypeOf(item).Elem()).Interface() - err := yaml.Unmarshal([]byte("null"), item) - c.Assert(err, IsNil) - if reflect.TypeOf(item).Kind() == reflect.Map { - c.Assert(reflect.ValueOf(item).Interface(), DeepEquals, reflect.MakeMap(reflect.TypeOf(item)).Interface()) - } else { - c.Assert(reflect.ValueOf(item).Elem().Interface(), DeepEquals, zero) - } - } -} - -func (s *S) TestUnmarshalSliceOnPreset(c *C) { - // Issue #48. - v := struct{ A []int }{[]int{1}} - yaml.Unmarshal([]byte("a: [2]"), &v) - c.Assert(v.A, DeepEquals, []int{2}) -} - -//var data []byte -//func init() { -// var err error -// data, err = ioutil.ReadFile("/tmp/file.yaml") -// if err != nil { -// panic(err) -// } -//} -// -//func (s *S) BenchmarkUnmarshal(c *C) { -// var err error -// for i := 0; i < c.N; i++ { -// var v map[string]interface{} -// err = yaml.Unmarshal(data, &v) -// } -// if err != nil { -// panic(err) -// } -//} -// -//func (s *S) BenchmarkMarshal(c *C) { -// var v map[string]interface{} -// yaml.Unmarshal(data, &v) -// c.ResetTimer() -// for i := 0; i < c.N; i++ { -// yaml.Marshal(&v) -// } -//} diff --git a/vendor/github.com/go-yaml/yaml/encode_test.go b/vendor/github.com/go-yaml/yaml/encode_test.go deleted file mode 100644 index 84099bd385..0000000000 --- a/vendor/github.com/go-yaml/yaml/encode_test.go +++ /dev/null @@ -1,501 +0,0 @@ -package yaml_test - -import ( - "fmt" - "math" - "strconv" - "strings" - "time" - - . "gopkg.in/check.v1" - "gopkg.in/yaml.v2" - "net" - "os" -) - -var marshalIntTest = 123 - -var marshalTests = []struct { - value interface{} - data string -}{ - { - nil, - "null\n", - }, { - &struct{}{}, - "{}\n", - }, { - map[string]string{"v": "hi"}, - "v: hi\n", - }, { - map[string]interface{}{"v": "hi"}, - "v: hi\n", - }, { - map[string]string{"v": "true"}, - "v: \"true\"\n", - }, { - map[string]string{"v": "false"}, - "v: \"false\"\n", - }, { - map[string]interface{}{"v": true}, - "v: true\n", - }, { - map[string]interface{}{"v": false}, - "v: false\n", - }, { - map[string]interface{}{"v": 10}, - "v: 10\n", - }, { - map[string]interface{}{"v": -10}, - "v: -10\n", - }, { - map[string]uint{"v": 42}, - "v: 42\n", - }, { - map[string]interface{}{"v": int64(4294967296)}, - "v: 4294967296\n", - }, { - map[string]int64{"v": int64(4294967296)}, - "v: 4294967296\n", - }, { - map[string]uint64{"v": 4294967296}, - "v: 4294967296\n", - }, { - map[string]interface{}{"v": "10"}, - "v: \"10\"\n", - }, { - map[string]interface{}{"v": 0.1}, - "v: 0.1\n", - }, { - map[string]interface{}{"v": float64(0.1)}, - "v: 0.1\n", - }, { - map[string]interface{}{"v": -0.1}, - "v: -0.1\n", - }, { - map[string]interface{}{"v": math.Inf(+1)}, - "v: .inf\n", - }, { - map[string]interface{}{"v": math.Inf(-1)}, - "v: -.inf\n", - }, { - map[string]interface{}{"v": math.NaN()}, - "v: .nan\n", - }, { - map[string]interface{}{"v": nil}, - "v: null\n", - }, { - map[string]interface{}{"v": ""}, - "v: \"\"\n", - }, { - map[string][]string{"v": []string{"A", "B"}}, - "v:\n- A\n- B\n", - }, { - map[string][]string{"v": []string{"A", "B\nC"}}, - "v:\n- A\n- |-\n B\n C\n", - }, { - map[string][]interface{}{"v": []interface{}{"A", 1, map[string][]int{"B": []int{2, 3}}}}, - "v:\n- A\n- 1\n- B:\n - 2\n - 3\n", - }, { - map[string]interface{}{"a": map[interface{}]interface{}{"b": "c"}}, - "a:\n b: c\n", - }, { - map[string]interface{}{"a": "-"}, - "a: '-'\n", - }, - - // Simple values. - { - &marshalIntTest, - "123\n", - }, - - // Structures - { - &struct{ Hello string }{"world"}, - "hello: world\n", - }, { - &struct { - A struct { - B string - } - }{struct{ B string }{"c"}}, - "a:\n b: c\n", - }, { - &struct { - A *struct { - B string - } - }{&struct{ B string }{"c"}}, - "a:\n b: c\n", - }, { - &struct { - A *struct { - B string - } - }{}, - "a: null\n", - }, { - &struct{ A int }{1}, - "a: 1\n", - }, { - &struct{ A []int }{[]int{1, 2}}, - "a:\n- 1\n- 2\n", - }, { - &struct { - B int "a" - }{1}, - "a: 1\n", - }, { - &struct{ A bool }{true}, - "a: true\n", - }, - - // Conditional flag - { - &struct { - A int "a,omitempty" - B int "b,omitempty" - }{1, 0}, - "a: 1\n", - }, { - &struct { - A int "a,omitempty" - B int "b,omitempty" - }{0, 0}, - "{}\n", - }, { - &struct { - A *struct{ X, y int } "a,omitempty,flow" - }{&struct{ X, y int }{1, 2}}, - "a: {x: 1}\n", - }, { - &struct { - A *struct{ X, y int } "a,omitempty,flow" - }{nil}, - "{}\n", - }, { - &struct { - A *struct{ X, y int } "a,omitempty,flow" - }{&struct{ X, y int }{}}, - "a: {x: 0}\n", - }, { - &struct { - A struct{ X, y int } "a,omitempty,flow" - }{struct{ X, y int }{1, 2}}, - "a: {x: 1}\n", - }, { - &struct { - A struct{ X, y int } "a,omitempty,flow" - }{struct{ X, y int }{0, 1}}, - "{}\n", - }, { - &struct { - A float64 "a,omitempty" - B float64 "b,omitempty" - }{1, 0}, - "a: 1\n", - }, - - // Flow flag - { - &struct { - A []int "a,flow" - }{[]int{1, 2}}, - "a: [1, 2]\n", - }, { - &struct { - A map[string]string "a,flow" - }{map[string]string{"b": "c", "d": "e"}}, - "a: {b: c, d: e}\n", - }, { - &struct { - A struct { - B, D string - } "a,flow" - }{struct{ B, D string }{"c", "e"}}, - "a: {b: c, d: e}\n", - }, - - // Unexported field - { - &struct { - u int - A int - }{0, 1}, - "a: 1\n", - }, - - // Ignored field - { - &struct { - A int - B int "-" - }{1, 2}, - "a: 1\n", - }, - - // Struct inlining - { - &struct { - A int - C inlineB `yaml:",inline"` - }{1, inlineB{2, inlineC{3}}}, - "a: 1\nb: 2\nc: 3\n", - }, - - // Map inlining - { - &struct { - A int - C map[string]int `yaml:",inline"` - }{1, map[string]int{"b": 2, "c": 3}}, - "a: 1\nb: 2\nc: 3\n", - }, - - // Duration - { - map[string]time.Duration{"a": 3 * time.Second}, - "a: 3s\n", - }, - - // Issue #24: bug in map merging logic. - { - map[string]string{"a": ""}, - "a: \n", - }, - - // Issue #34: marshal unsupported base 60 floats quoted for compatibility - // with old YAML 1.1 parsers. - { - map[string]string{"a": "1:1"}, - "a: \"1:1\"\n", - }, - - // Binary data. - { - map[string]string{"a": "\x00"}, - "a: \"\\0\"\n", - }, { - map[string]string{"a": "\x80\x81\x82"}, - "a: !!binary gIGC\n", - }, { - map[string]string{"a": strings.Repeat("\x90", 54)}, - "a: !!binary |\n " + strings.Repeat("kJCQ", 17) + "kJ\n CQ\n", - }, - - // Ordered maps. - { - &yaml.MapSlice{{"b", 2}, {"a", 1}, {"d", 4}, {"c", 3}, {"sub", yaml.MapSlice{{"e", 5}}}}, - "b: 2\na: 1\nd: 4\nc: 3\nsub:\n e: 5\n", - }, - - // Encode unicode as utf-8 rather than in escaped form. - { - map[string]string{"a": "你好"}, - "a: 你好\n", - }, - - // Support encoding.TextMarshaler. - { - map[string]net.IP{"a": net.IPv4(1, 2, 3, 4)}, - "a: 1.2.3.4\n", - }, - { - map[string]time.Time{"a": time.Unix(1424801979, 0)}, - "a: 2015-02-24T18:19:39Z\n", - }, - - // Ensure strings containing ": " are quoted (reported as PR #43, but not reproducible). - { - map[string]string{"a": "b: c"}, - "a: 'b: c'\n", - }, - - // Containing hash mark ('#') in string should be quoted - { - map[string]string{"a": "Hello #comment"}, - "a: 'Hello #comment'\n", - }, - { - map[string]string{"a": "你好 #comment"}, - "a: '你好 #comment'\n", - }, -} - -func (s *S) TestMarshal(c *C) { - defer os.Setenv("TZ", os.Getenv("TZ")) - os.Setenv("TZ", "UTC") - for _, item := range marshalTests { - data, err := yaml.Marshal(item.value) - c.Assert(err, IsNil) - c.Assert(string(data), Equals, item.data) - } -} - -var marshalErrorTests = []struct { - value interface{} - error string - panic string -}{{ - value: &struct { - B int - inlineB ",inline" - }{1, inlineB{2, inlineC{3}}}, - panic: `Duplicated key 'b' in struct struct \{ B int; .*`, -}, { - value: &struct { - A int - B map[string]int ",inline" - }{1, map[string]int{"a": 2}}, - panic: `Can't have key "a" in inlined map; conflicts with struct field`, -}} - -func (s *S) TestMarshalErrors(c *C) { - for _, item := range marshalErrorTests { - if item.panic != "" { - c.Assert(func() { yaml.Marshal(item.value) }, PanicMatches, item.panic) - } else { - _, err := yaml.Marshal(item.value) - c.Assert(err, ErrorMatches, item.error) - } - } -} - -func (s *S) TestMarshalTypeCache(c *C) { - var data []byte - var err error - func() { - type T struct{ A int } - data, err = yaml.Marshal(&T{}) - c.Assert(err, IsNil) - }() - func() { - type T struct{ B int } - data, err = yaml.Marshal(&T{}) - c.Assert(err, IsNil) - }() - c.Assert(string(data), Equals, "b: 0\n") -} - -var marshalerTests = []struct { - data string - value interface{} -}{ - {"_:\n hi: there\n", map[interface{}]interface{}{"hi": "there"}}, - {"_:\n- 1\n- A\n", []interface{}{1, "A"}}, - {"_: 10\n", 10}, - {"_: null\n", nil}, - {"_: BAR!\n", "BAR!"}, -} - -type marshalerType struct { - value interface{} -} - -func (o marshalerType) MarshalText() ([]byte, error) { - panic("MarshalText called on type with MarshalYAML") -} - -func (o marshalerType) MarshalYAML() (interface{}, error) { - return o.value, nil -} - -type marshalerValue struct { - Field marshalerType "_" -} - -func (s *S) TestMarshaler(c *C) { - for _, item := range marshalerTests { - obj := &marshalerValue{} - obj.Field.value = item.value - data, err := yaml.Marshal(obj) - c.Assert(err, IsNil) - c.Assert(string(data), Equals, string(item.data)) - } -} - -func (s *S) TestMarshalerWholeDocument(c *C) { - obj := &marshalerType{} - obj.value = map[string]string{"hello": "world!"} - data, err := yaml.Marshal(obj) - c.Assert(err, IsNil) - c.Assert(string(data), Equals, "hello: world!\n") -} - -type failingMarshaler struct{} - -func (ft *failingMarshaler) MarshalYAML() (interface{}, error) { - return nil, failingErr -} - -func (s *S) TestMarshalerError(c *C) { - _, err := yaml.Marshal(&failingMarshaler{}) - c.Assert(err, Equals, failingErr) -} - -func (s *S) TestSortedOutput(c *C) { - order := []interface{}{ - false, - true, - 1, - uint(1), - 1.0, - 1.1, - 1.2, - 2, - uint(2), - 2.0, - 2.1, - "", - ".1", - ".2", - ".a", - "1", - "2", - "a!10", - "a/2", - "a/10", - "a~10", - "ab/1", - "b/1", - "b/01", - "b/2", - "b/02", - "b/3", - "b/03", - "b1", - "b01", - "b3", - "c2.10", - "c10.2", - "d1", - "d12", - "d12a", - } - m := make(map[interface{}]int) - for _, k := range order { - m[k] = 1 - } - data, err := yaml.Marshal(m) - c.Assert(err, IsNil) - out := "\n" + string(data) - last := 0 - for i, k := range order { - repr := fmt.Sprint(k) - if s, ok := k.(string); ok { - if _, err = strconv.ParseFloat(repr, 32); s == "" || err == nil { - repr = `"` + repr + `"` - } - } - index := strings.Index(out, "\n"+repr+":") - if index == -1 { - c.Fatalf("%#v is not in the output: %#v", k, out) - } - if index < last { - c.Fatalf("%#v was generated before %#v: %q", k, order[i-1], out) - } - last = index - } -} diff --git a/vendor/github.com/go-yaml/yaml/suite_test.go b/vendor/github.com/go-yaml/yaml/suite_test.go deleted file mode 100644 index c5cf1ed4f6..0000000000 --- a/vendor/github.com/go-yaml/yaml/suite_test.go +++ /dev/null @@ -1,12 +0,0 @@ -package yaml_test - -import ( - . "gopkg.in/check.v1" - "testing" -) - -func Test(t *testing.T) { TestingT(t) } - -type S struct{} - -var _ = Suite(&S{}) diff --git a/vendor/github.com/nightlyone/lockfile/.gitignore b/vendor/github.com/nightlyone/lockfile/.gitignore deleted file mode 100644 index 5a05665dee..0000000000 --- a/vendor/github.com/nightlyone/lockfile/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# popular temporaries -.err -.out -.diff - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe diff --git a/vendor/github.com/nightlyone/lockfile/.gitmodules b/vendor/github.com/nightlyone/lockfile/.gitmodules deleted file mode 100644 index 6faa9e3469..0000000000 --- a/vendor/github.com/nightlyone/lockfile/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "git-hooks"] - path = git-hooks - url = https://github.com/nightlyone/git-hooks diff --git a/vendor/github.com/nightlyone/lockfile/.travis.yml b/vendor/github.com/nightlyone/lockfile/.travis.yml deleted file mode 100644 index 76e5962bf1..0000000000 --- a/vendor/github.com/nightlyone/lockfile/.travis.yml +++ /dev/null @@ -1,14 +0,0 @@ -language: go -go: - - 1.4.3 - - 1.6.2 - - tip - -# Only test commits to production branch and all pull requests -branches: - only: - - master - -matrix: - allow_failures: - - go: tip diff --git a/vendor/github.com/nightlyone/lockfile/README.md b/vendor/github.com/nightlyone/lockfile/README.md deleted file mode 100644 index c35235cdae..0000000000 --- a/vendor/github.com/nightlyone/lockfile/README.md +++ /dev/null @@ -1,52 +0,0 @@ -lockfile -========= -Handle locking via pid files. - -[![Build Status Unix][1]][2] -[![Build status Windows][3]][4] - -[1]: https://secure.travis-ci.org/nightlyone/lockfile.png -[2]: https://travis-ci.org/nightlyone/lockfile -[3]: https://ci.appveyor.com/api/projects/status/7mojkmauj81uvp8u/branch/master?svg=true -[4]: https://ci.appveyor.com/project/nightlyone/lockfile/branch/master - - - -install -------- -Install [Go 1][5], either [from source][6] or [with a prepackaged binary][7]. -For Windows suport, Go 1.4 or newer is required. - -Then run - - go get github.com/nightlyone/lockfile - -[5]: http://golang.org -[6]: http://golang.org/doc/install/source -[7]: http://golang.org/doc/install - -LICENSE -------- -MIT - -documentation -------------- -[package documentation at godoc.org](http://godoc.org/github.com/nightlyone/lockfile) - -install -------------------- - go get github.com/nightlyone/lockfile - - -contributing -============ - -Contributions are welcome. Please open an issue or send me a pull request for a dedicated branch. -Make sure the git commit hooks show it works. - -git commit hooks ------------------------ -enable commit hooks via - - cd .git ; rm -rf hooks; ln -s ../git-hooks hooks ; cd .. - diff --git a/vendor/github.com/nightlyone/lockfile/appveyor.yml b/vendor/github.com/nightlyone/lockfile/appveyor.yml deleted file mode 100644 index cf72a58b13..0000000000 --- a/vendor/github.com/nightlyone/lockfile/appveyor.yml +++ /dev/null @@ -1,12 +0,0 @@ -clone_folder: c:\gopath\src\github.com\nightlyone\lockfile - -environment: - GOPATH: c:\gopath - -install: - - go version - - go env - - go get -v -t ./... - -build_script: - - go test -v ./... diff --git a/vendor/github.com/nightlyone/lockfile/lockfile_test.go b/vendor/github.com/nightlyone/lockfile/lockfile_test.go deleted file mode 100644 index be2c821e21..0000000000 --- a/vendor/github.com/nightlyone/lockfile/lockfile_test.go +++ /dev/null @@ -1,308 +0,0 @@ -package lockfile - -import ( - "fmt" - "io/ioutil" - "math/rand" - "os" - "path/filepath" - "strconv" - "testing" -) - -func ExampleLockfile() { - lock, err := New(filepath.Join(os.TempDir(), "lock.me.now.lck")) - if err != nil { - fmt.Printf("Cannot init lock. reason: %v", err) - panic(err) // handle properly please! - } - err = lock.TryLock() - - // Error handling is essential, as we only try to get the lock. - if err != nil { - fmt.Printf("Cannot lock %q, reason: %v", lock, err) - panic(err) // handle properly please! - } - - defer lock.Unlock() - - fmt.Println("Do stuff under lock") - // Output: Do stuff under lock -} - -func TestBasicLockUnlock(t *testing.T) { - path, err := filepath.Abs("test_lockfile.pid") - if err != nil { - panic(err) - } - - lf, err := New(path) - if err != nil { - t.Fail() - fmt.Println("Error making lockfile: ", err) - return - } - - err = lf.TryLock() - if err != nil { - t.Fail() - fmt.Println("Error locking lockfile: ", err) - return - } - - err = lf.Unlock() - if err != nil { - t.Fail() - fmt.Println("Error unlocking lockfile: ", err) - return - } -} - -func GetDeadPID() int { - // I have no idea how windows handles large PIDs, or if they even exist. - // So limit it to be less or equal to 4096 to be safe. - - const maxPid = 4095 - - // limited iteration, so we finish one day - seen := map[int]bool{} - for len(seen) < maxPid { - pid := rand.Intn(maxPid + 1) // see https://godoc.org/math/rand#Intn why - if seen[pid] { - continue - } - seen[pid] = true - running, err := isRunning(pid) - if err != nil { - fmt.Println("Error checking PID: ", err) - continue - } - - if !running { - return pid - } - } - panic(fmt.Sprintf("all pids lower %d are used, cannot test this", maxPid)) -} - -func TestBusy(t *testing.T) { - path, err := filepath.Abs("test_lockfile.pid") - if err != nil { - t.Fatal(err) - return - } - - pid := os.Getppid() - - if err := ioutil.WriteFile(path, []byte(strconv.Itoa(pid)+"\n"), 0666); err != nil { - t.Fatal(err) - return - } - defer os.Remove(path) - - lf, err := New(path) - if err != nil { - t.Fatal(err) - return - } - - got := lf.TryLock() - if got != ErrBusy { - t.Fatalf("expected error %q, got %v", ErrBusy, got) - return - } -} - -func TestRogueDeletion(t *testing.T) { - path, err := filepath.Abs("test_lockfile.pid") - if err != nil { - t.Fatal(err) - return - } - lf, err := New(path) - if err != nil { - t.Fatal(err) - return - } - err = lf.TryLock() - if err != nil { - t.Fatal(err) - return - } - err = os.Remove(path) - if err != nil { - t.Fatal(err) - return - } - - got := lf.Unlock() - if got != ErrRogueDeletion { - t.Fatalf("unexpected error: %v", got) - return - } -} - -func TestRogueDeletionDeadPid(t *testing.T) { - path, err := filepath.Abs("test_lockfile.pid") - if err != nil { - t.Fatal(err) - return - } - lf, err := New(path) - if err != nil { - t.Fatal(err) - return - } - err = lf.TryLock() - if err != nil { - t.Fatal(err) - return - } - - pid := GetDeadPID() - if err := ioutil.WriteFile(path, []byte(strconv.Itoa(pid)+"\n"), 0666); err != nil { - t.Fatal(err) - return - } - defer os.Remove(path) - - err = lf.Unlock() - if err != ErrRogueDeletion { - t.Fatalf("unexpected error: %v", err) - return - } - - if _, err := os.Stat(path); os.IsNotExist(err) { - t.Fatal("lockfile should not be deleted by us, if we didn't create it") - } else { - if err != nil { - t.Fatalf("unexpected error %v", err) - } - } -} - -func TestRemovesStaleLockOnDeadOwner(t *testing.T) { - path, err := filepath.Abs("test_lockfile.pid") - if err != nil { - t.Fatal(err) - return - } - lf, err := New(path) - if err != nil { - t.Fatal(err) - return - } - pid := GetDeadPID() - if err := ioutil.WriteFile(path, []byte(strconv.Itoa(pid)+"\n"), 0666); err != nil { - t.Fatal(err) - return - } - err = lf.TryLock() - if err != nil { - t.Fatal(err) - return - } - - if err := lf.Unlock(); err != nil { - t.Fatal(err) - return - } -} - -func TestInvalidPidLeadToReplacedLockfileAndSuccess(t *testing.T) { - path, err := filepath.Abs("test_lockfile.pid") - if err != nil { - t.Fatal(err) - return - } - if err := ioutil.WriteFile(path, []byte("\n"), 0666); err != nil { - t.Fatal(err) - return - } - defer os.Remove(path) - - lf, err := New(path) - if err != nil { - t.Fatal(err) - return - } - - if err := lf.TryLock(); err != nil { - t.Fatalf("unexpected error: %v", err) - return - } - - // now check if file exists and contains the correct content - got, err := ioutil.ReadFile(path) - if err != nil { - t.Fatalf("unexpected error %v", err) - return - } - want := fmt.Sprintf("%d\n", os.Getpid()) - if string(got) != want { - t.Fatalf("got %q, want %q", got, want) - } -} - -func TestScanPidLine(t *testing.T) { - tests := [...]struct { - input []byte - pid int - xfail error - }{ - { - xfail: ErrInvalidPid, - }, - { - input: []byte(""), - xfail: ErrInvalidPid, - }, - { - input: []byte("\n"), - xfail: ErrInvalidPid, - }, - { - input: []byte("-1\n"), - xfail: ErrInvalidPid, - }, - { - input: []byte("0\n"), - xfail: ErrInvalidPid, - }, - { - input: []byte("a\n"), - xfail: ErrInvalidPid, - }, - { - input: []byte("1\n"), - pid: 1, - }, - } - - // test positive cases first - for step, tc := range tests { - if tc.xfail != nil { - continue - } - want := tc.pid - got, err := scanPidLine(tc.input) - if err != nil { - t.Fatalf("%d: unexpected error %v", step, err) - } - if got != want { - t.Errorf("%d: expected pid %d, got %d", step, want, got) - } - } - - // test negative cases now - for step, tc := range tests { - if tc.xfail == nil { - continue - } - want := tc.xfail - _, got := scanPidLine(tc.input) - if got != want { - t.Errorf("%d: expected error %v, got %v", step, want, got) - } - } -} diff --git a/vendor/github.com/pelletier/go-buffruneio/.gitignore b/vendor/github.com/pelletier/go-buffruneio/.gitignore deleted file mode 100644 index c56069fe26..0000000000 --- a/vendor/github.com/pelletier/go-buffruneio/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.test \ No newline at end of file diff --git a/vendor/github.com/pelletier/go-buffruneio/.travis.yml b/vendor/github.com/pelletier/go-buffruneio/.travis.yml deleted file mode 100644 index 9720442cd8..0000000000 --- a/vendor/github.com/pelletier/go-buffruneio/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: go -sudo: false -go: - - 1.3.3 - - 1.4.3 - - 1.5.3 - - tip diff --git a/vendor/github.com/pelletier/go-buffruneio/README.md b/vendor/github.com/pelletier/go-buffruneio/README.md deleted file mode 100644 index ff608b3ab8..0000000000 --- a/vendor/github.com/pelletier/go-buffruneio/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# buffruneio - -[![Tests Status](https://travis-ci.org/pelletier/go-buffruneio.svg?branch=master)](https://travis-ci.org/pelletier/go-buffruneio) -[![GoDoc](https://godoc.org/github.com/pelletier/go-buffruneio?status.svg)](https://godoc.org/github.com/pelletier/go-buffruneio) - -Buffruneio is a wrapper around bufio to provide buffered runes access with -unlimited unreads. - -```go -import "github.com/pelletier/go-buffruneio" -``` - -## Examples - -```go -import ( - "fmt" - "github.com/pelletier/go-buffruneio" - "strings" -) - -reader := buffruneio.NewReader(strings.NewReader("abcd")) -fmt.Println(reader.ReadRune()) // 'a' -fmt.Println(reader.ReadRune()) // 'b' -fmt.Println(reader.ReadRune()) // 'c' -reader.UnreadRune() -reader.UnreadRune() -fmt.Println(reader.ReadRune()) // 'b' -fmt.Println(reader.ReadRune()) // 'c' -``` - -## Documentation - -The documentation and additional examples are available at -[godoc.org](http://godoc.org/github.com/pelletier/go-buffruneio). - -## Contribute - -Feel free to report bugs and patches using GitHub's pull requests system on -[pelletier/go-toml](https://github.com/pelletier/go-buffruneio). Any feedback is -much appreciated! - -## LICENSE - -Copyright (c) 2016 Thomas Pelletier - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/pelletier/go-buffruneio/buffruneio_test.go b/vendor/github.com/pelletier/go-buffruneio/buffruneio_test.go deleted file mode 100644 index 67b0cba9b3..0000000000 --- a/vendor/github.com/pelletier/go-buffruneio/buffruneio_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package buffruneio - -import ( - "runtime/debug" - "strings" - "testing" -) - -func assertNoError(t *testing.T, err error) { - if err != nil { - t.Log("unexpected error", err) - debug.PrintStack() - t.FailNow() - } -} - -func assumeRunesArray(t *testing.T, expected []rune, got []rune) { - if len(expected) != len(got) { - t.Fatal("expected", len(expected), "runes, but got", len(got)) - } - for i := 0; i < len(got); i++ { - if expected[i] != got[i] { - t.Fatal("expected rune", expected[i], "at index", i, "but got", got[i]) - } - } -} - -func assumeRune(t *testing.T, rd *Reader, r rune) { - gotRune, size, err := rd.ReadRune() - assertNoError(t, err) - if gotRune != r { - t.Fatal("got", string(gotRune), - "(", []byte(string(gotRune)), ")", - "expected", string(r), - "(", []byte(string(r)), ")") - t.Fatal("got size", size, - "expected", len([]byte(string(r)))) - } -} - -func TestReadString(t *testing.T) { - s := "hello" - rd := NewReader(strings.NewReader(s)) - - assumeRune(t, rd, 'h') - assumeRune(t, rd, 'e') - assumeRune(t, rd, 'l') - assumeRune(t, rd, 'l') - assumeRune(t, rd, 'o') - assumeRune(t, rd, EOF) -} - -func TestMultipleEOF(t *testing.T) { - s := "" - rd := NewReader(strings.NewReader(s)) - - assumeRune(t, rd, EOF) - assumeRune(t, rd, EOF) -} - -func TestUnread(t *testing.T) { - s := "ab" - rd := NewReader(strings.NewReader(s)) - - assumeRune(t, rd, 'a') - assumeRune(t, rd, 'b') - assertNoError(t, rd.UnreadRune()) - assumeRune(t, rd, 'b') - assumeRune(t, rd, EOF) -} - -func TestUnreadEOF(t *testing.T) { - s := "" - rd := NewReader(strings.NewReader(s)) - - _ = rd.UnreadRune() - assumeRune(t, rd, EOF) - assumeRune(t, rd, EOF) - assertNoError(t, rd.UnreadRune()) - assumeRune(t, rd, EOF) -} - -func TestForget(t *testing.T) { - s := "hello" - rd := NewReader(strings.NewReader(s)) - - assumeRune(t, rd, 'h') - assumeRune(t, rd, 'e') - assumeRune(t, rd, 'l') - assumeRune(t, rd, 'l') - rd.Forget() - if rd.UnreadRune() != ErrNoRuneToUnread { - t.Fatal("no rune should be available") - } -} - -func TestForgetEmpty(t *testing.T) { - s := "" - rd := NewReader(strings.NewReader(s)) - - rd.Forget() - assumeRune(t, rd, EOF) - rd.Forget() -} - -func TestPeekEmpty(t *testing.T) { - s := "" - rd := NewReader(strings.NewReader(s)) - - runes := rd.PeekRunes(1) - if len(runes) != 1 { - t.Fatal("incorrect number of runes", len(runes)) - } - if runes[0] != EOF { - t.Fatal("incorrect rune", runes[0]) - } -} - -func TestPeek(t *testing.T) { - s := "a" - rd := NewReader(strings.NewReader(s)) - - runes := rd.PeekRunes(1) - assumeRunesArray(t, []rune{'a'}, runes) - - runes = rd.PeekRunes(1) - assumeRunesArray(t, []rune{'a'}, runes) - - assumeRune(t, rd, 'a') - runes = rd.PeekRunes(1) - assumeRunesArray(t, []rune{EOF}, runes) - - assumeRune(t, rd, EOF) -} - -func TestPeekLarge(t *testing.T) { - s := "abcdefg" - rd := NewReader(strings.NewReader(s)) - - runes := rd.PeekRunes(100) - if len(runes) != len(s)+1 { - t.Fatal("incorrect number of runes", len(runes)) - } - assumeRunesArray(t, []rune{'a', 'b', 'c', 'd', 'e', 'f', 'g', EOF}, runes) -} diff --git a/vendor/github.com/pelletier/go-toml/.gitignore b/vendor/github.com/pelletier/go-toml/.gitignore deleted file mode 100644 index f1b619018e..0000000000 --- a/vendor/github.com/pelletier/go-toml/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test_program/test_program_bin diff --git a/vendor/github.com/pelletier/go-toml/.travis.yml b/vendor/github.com/pelletier/go-toml/.travis.yml deleted file mode 100644 index 64f03809a1..0000000000 --- a/vendor/github.com/pelletier/go-toml/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -sudo: false -language: go -go: - - 1.6.4 - - 1.7.5 - - 1.8 - - tip -matrix: - allow_failures: - - go: tip - fast_finish: true -script: - - ./test.sh -before_install: - - go get github.com/axw/gocov/gocov - - go get github.com/mattn/goveralls - - if ! go get code.google.com/p/go.tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi -branches: - only: [master] -after_success: - - $HOME/gopath/bin/goveralls -service=travis-ci -coverprofile=coverage.out -repotoken $COVERALLS_TOKEN diff --git a/vendor/github.com/pelletier/go-toml/README.md b/vendor/github.com/pelletier/go-toml/README.md deleted file mode 100644 index b8137e022d..0000000000 --- a/vendor/github.com/pelletier/go-toml/README.md +++ /dev/null @@ -1,120 +0,0 @@ -# go-toml - -Go library for the [TOML](https://github.com/mojombo/toml) format. - -This library supports TOML version -[v0.4.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.4.0.md) - -[![GoDoc](https://godoc.org/github.com/pelletier/go-toml?status.svg)](http://godoc.org/github.com/pelletier/go-toml) -[![license](https://img.shields.io/github/license/pelletier/go-toml.svg)](https://github.com/pelletier/go-toml/blob/master/LICENSE) -[![Build Status](https://travis-ci.org/pelletier/go-toml.svg?branch=master)](https://travis-ci.org/pelletier/go-toml) -[![Coverage Status](https://coveralls.io/repos/github/pelletier/go-toml/badge.svg?branch=master)](https://coveralls.io/github/pelletier/go-toml?branch=master) -[![Go Report Card](https://goreportcard.com/badge/github.com/pelletier/go-toml)](https://goreportcard.com/report/github.com/pelletier/go-toml) - -## Features - -Go-toml provides the following features for using data parsed from TOML documents: - -* Load TOML documents from files and string data -* Easily navigate TOML structure using TomlTree -* Line & column position data for all parsed elements -* Query support similar to JSON-Path -* Syntax errors contain line and column numbers - -Go-toml is designed to help cover use-cases not covered by reflection-based TOML parsing: - -* Semantic evaluation of parsed TOML -* Informing a user of mistakes in the source document, after it has been parsed -* Programatic handling of default values on a case-by-case basis -* Using a TOML document as a flexible data-store - -## Import - - import "github.com/pelletier/go-toml" - -## Usage - -### Example - -Say you have a TOML file that looks like this: - -```toml -[postgres] -user = "pelletier" -password = "mypassword" -``` - -Read the username and password like this: - -```go -import ( - "fmt" - "github.com/pelletier/go-toml" -) - -config, err := toml.LoadFile("config.toml") -if err != nil { - fmt.Println("Error ", err.Error()) -} else { - // retrieve data directly - user := config.Get("postgres.user").(string) - password := config.Get("postgres.password").(string) - - // or using an intermediate object - configTree := config.Get("postgres").(*toml.TomlTree) - user = configTree.Get("user").(string) - password = configTree.Get("password").(string) - fmt.Println("User is ", user, ". Password is ", password) - - // show where elements are in the file - fmt.Println("User position: %v", configTree.GetPosition("user")) - fmt.Println("Password position: %v", configTree.GetPosition("password")) - - // use a query to gather elements without walking the tree - results, _ := config.Query("$..[user,password]") - for ii, item := range results.Values() { - fmt.Println("Query result %d: %v", ii, item) - } -} -``` - -## Documentation - -The documentation and additional examples are available at -[godoc.org](http://godoc.org/github.com/pelletier/go-toml). - -## Tools - -Go-toml provides two handy command line tools: - -* `tomll`: Reads TOML files and lint them. - - ``` - go install github.com/pelletier/go-toml/cmd/tomll - tomll --help - ``` -* `tomljson`: Reads a TOML file and outputs its JSON representation. - - ``` - go install github.com/pelletier/go-toml/cmd/tomljson - tomljson --help - ``` - -## Contribute - -Feel free to report bugs and patches using GitHub's pull requests system on -[pelletier/go-toml](https://github.com/pelletier/go-toml). Any feedback would be -much appreciated! - -### Run tests - -You have to make sure two kind of tests run: - -1. The Go unit tests -2. The TOML examples base - -You can run both of them using `./test.sh`. - -## License - -The MIT License (MIT). Read [LICENSE](LICENSE). diff --git a/vendor/github.com/pelletier/go-toml/clean.sh b/vendor/github.com/pelletier/go-toml/clean.sh deleted file mode 100755 index 44d49d936d..0000000000 --- a/vendor/github.com/pelletier/go-toml/clean.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -# fail out of the script if anything here fails -set -e - -# clear out stuff generated by test.sh -rm -rf src test_program_bin toml-test diff --git a/vendor/github.com/pelletier/go-toml/cmd/tomljson/main_test.go b/vendor/github.com/pelletier/go-toml/cmd/tomljson/main_test.go deleted file mode 100644 index 0b4bdbb11b..0000000000 --- a/vendor/github.com/pelletier/go-toml/cmd/tomljson/main_test.go +++ /dev/null @@ -1,82 +0,0 @@ -package main - -import ( - "bytes" - "io/ioutil" - "os" - "strings" - "testing" -) - -func expectBufferEquality(t *testing.T, name string, buffer *bytes.Buffer, expected string) { - output := buffer.String() - if output != expected { - t.Errorf("incorrect %s:\n%s\n\nexpected %s:\n%s", name, output, name, expected) - t.Log([]rune(output)) - t.Log([]rune(expected)) - } -} - -func expectProcessMainResults(t *testing.T, input string, args []string, exitCode int, expectedOutput string, expectedError string) { - inputReader := strings.NewReader(input) - outputBuffer := new(bytes.Buffer) - errorBuffer := new(bytes.Buffer) - - returnCode := processMain(args, inputReader, outputBuffer, errorBuffer) - - expectBufferEquality(t, "output", outputBuffer, expectedOutput) - expectBufferEquality(t, "error", errorBuffer, expectedError) - - if returnCode != exitCode { - t.Error("incorrect return code:", returnCode, "expected", exitCode) - } -} - -func TestProcessMainReadFromStdin(t *testing.T) { - input := ` - [mytoml] - a = 42` - expectedOutput := `{ - "mytoml": { - "a": 42 - } -} -` - expectedError := `` - expectedExitCode := 0 - - expectProcessMainResults(t, input, []string{}, expectedExitCode, expectedOutput, expectedError) -} - -func TestProcessMainReadFromFile(t *testing.T) { - input := ` - [mytoml] - a = 42` - - tmpfile, err := ioutil.TempFile("", "example.toml") - if err != nil { - t.Fatal(err) - } - if _, err := tmpfile.Write([]byte(input)); err != nil { - t.Fatal(err) - } - - defer os.Remove(tmpfile.Name()) - - expectedOutput := `{ - "mytoml": { - "a": 42 - } -} -` - expectedError := `` - expectedExitCode := 0 - - expectProcessMainResults(t, ``, []string{tmpfile.Name()}, expectedExitCode, expectedOutput, expectedError) -} - -func TestProcessMainReadFromMissingFile(t *testing.T) { - expectedError := `open /this/file/does/not/exist: no such file or directory -` - expectProcessMainResults(t, ``, []string{"/this/file/does/not/exist"}, -1, ``, expectedError) -} diff --git a/vendor/github.com/pelletier/go-toml/doc_test.go b/vendor/github.com/pelletier/go-toml/doc_test.go deleted file mode 100644 index 69452415a2..0000000000 --- a/vendor/github.com/pelletier/go-toml/doc_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// code examples for godoc - -package toml - -import ( - "fmt" -) - -func ExampleNodeFilterFn_filterExample() { - tree, _ := Load(` - [struct_one] - foo = "foo" - bar = "bar" - - [struct_two] - baz = "baz" - gorf = "gorf" - `) - - // create a query that references a user-defined-filter - query, _ := CompileQuery("$[?(bazOnly)]") - - // define the filter, and assign it to the query - query.SetFilter("bazOnly", func(node interface{}) bool { - if tree, ok := node.(*TomlTree); ok { - return tree.Has("baz") - } - return false // reject all other node types - }) - - // results contain only the 'struct_two' TomlTree - query.Execute(tree) -} - -func ExampleQuery_queryExample() { - config, _ := Load(` - [[book]] - title = "The Stand" - author = "Stephen King" - [[book]] - title = "For Whom the Bell Tolls" - author = "Ernest Hemmingway" - [[book]] - title = "Neuromancer" - author = "William Gibson" - `) - - // find and print all the authors in the document - authors, _ := config.Query("$.book.author") - for _, name := range authors.Values() { - fmt.Println(name) - } -} - -func Example_comprehensiveExample() { - config, err := LoadFile("config.toml") - - if err != nil { - fmt.Println("Error ", err.Error()) - } else { - // retrieve data directly - user := config.Get("postgres.user").(string) - password := config.Get("postgres.password").(string) - - // or using an intermediate object - configTree := config.Get("postgres").(*TomlTree) - user = configTree.Get("user").(string) - password = configTree.Get("password").(string) - fmt.Println("User is ", user, ". Password is ", password) - - // show where elements are in the file - fmt.Printf("User position: %v\n", configTree.GetPosition("user")) - fmt.Printf("Password position: %v\n", configTree.GetPosition("password")) - - // use a query to gather elements without walking the tree - results, _ := config.Query("$..[user,password]") - for ii, item := range results.Values() { - fmt.Printf("Query result %d: %v\n", ii, item) - } - } -} diff --git a/vendor/github.com/pelletier/go-toml/example-crlf.toml b/vendor/github.com/pelletier/go-toml/example-crlf.toml deleted file mode 100644 index 12950a163d..0000000000 --- a/vendor/github.com/pelletier/go-toml/example-crlf.toml +++ /dev/null @@ -1,29 +0,0 @@ -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it diff --git a/vendor/github.com/pelletier/go-toml/example.toml b/vendor/github.com/pelletier/go-toml/example.toml deleted file mode 100644 index 3d902f2820..0000000000 --- a/vendor/github.com/pelletier/go-toml/example.toml +++ /dev/null @@ -1,29 +0,0 @@ -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it diff --git a/vendor/github.com/pelletier/go-toml/keysparsing_test.go b/vendor/github.com/pelletier/go-toml/keysparsing_test.go deleted file mode 100644 index 1a9ecccaa9..0000000000 --- a/vendor/github.com/pelletier/go-toml/keysparsing_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package toml - -import ( - "fmt" - "testing" -) - -func testResult(t *testing.T, key string, expected []string) { - parsed, err := parseKey(key) - t.Logf("key=%s expected=%s parsed=%s", key, expected, parsed) - if err != nil { - t.Fatal("Unexpected error:", err) - } - if len(expected) != len(parsed) { - t.Fatal("Expected length", len(expected), "but", len(parsed), "parsed") - } - for index, expectedKey := range expected { - if expectedKey != parsed[index] { - t.Fatal("Expected", expectedKey, "at index", index, "but found", parsed[index]) - } - } -} - -func testError(t *testing.T, key string, expectedError string) { - _, err := parseKey(key) - if fmt.Sprintf("%s", err) != expectedError { - t.Fatalf("Expected error \"%s\", but got \"%s\".", expectedError, err) - } -} - -func TestBareKeyBasic(t *testing.T) { - testResult(t, "test", []string{"test"}) -} - -func TestBareKeyDotted(t *testing.T) { - testResult(t, "this.is.a.key", []string{"this", "is", "a", "key"}) -} - -func TestDottedKeyBasic(t *testing.T) { - testResult(t, "\"a.dotted.key\"", []string{"a.dotted.key"}) -} - -func TestBaseKeyPound(t *testing.T) { - testError(t, "hello#world", "invalid bare character: #") -} - -func TestQuotedKeys(t *testing.T) { - testResult(t, `hello."foo".bar`, []string{"hello", "foo", "bar"}) - testResult(t, `"hello!"`, []string{"hello!"}) -} - -func TestEmptyKey(t *testing.T) { - testError(t, "", "empty key") - testError(t, " ", "empty key") - testResult(t, `""`, []string{""}) -} diff --git a/vendor/github.com/pelletier/go-toml/lexer_test.go b/vendor/github.com/pelletier/go-toml/lexer_test.go deleted file mode 100644 index 6b324ea0e0..0000000000 --- a/vendor/github.com/pelletier/go-toml/lexer_test.go +++ /dev/null @@ -1,750 +0,0 @@ -package toml - -import ( - "strings" - "testing" -) - -func testFlow(t *testing.T, input string, expectedFlow []token) { - ch := lexToml(strings.NewReader(input)) - for _, expected := range expectedFlow { - token := <-ch - if token != expected { - t.Log("While testing: ", input) - t.Log("compared (got)", token, "to (expected)", expected) - t.Log("\tvalue:", token.val, "<->", expected.val) - t.Log("\tvalue as bytes:", []byte(token.val), "<->", []byte(expected.val)) - t.Log("\ttype:", token.typ.String(), "<->", expected.typ.String()) - t.Log("\tline:", token.Line, "<->", expected.Line) - t.Log("\tcolumn:", token.Col, "<->", expected.Col) - t.Log("compared", token, "to", expected) - t.FailNow() - } - } - - tok, ok := <-ch - if ok { - t.Log("channel is not closed!") - t.Log(len(ch)+1, "tokens remaining:") - - t.Log("token ->", tok) - for token := range ch { - t.Log("token ->", token) - } - t.FailNow() - } -} - -func TestValidKeyGroup(t *testing.T) { - testFlow(t, "[hello world]", []token{ - {Position{1, 1}, tokenLeftBracket, "["}, - {Position{1, 2}, tokenKeyGroup, "hello world"}, - {Position{1, 13}, tokenRightBracket, "]"}, - {Position{1, 14}, tokenEOF, ""}, - }) -} - -func TestNestedQuotedUnicodeKeyGroup(t *testing.T) { - testFlow(t, `[ j . "ʞ" . l ]`, []token{ - {Position{1, 1}, tokenLeftBracket, "["}, - {Position{1, 2}, tokenKeyGroup, ` j . "ʞ" . l `}, - {Position{1, 15}, tokenRightBracket, "]"}, - {Position{1, 16}, tokenEOF, ""}, - }) -} - -func TestUnclosedKeyGroup(t *testing.T) { - testFlow(t, "[hello world", []token{ - {Position{1, 1}, tokenLeftBracket, "["}, - {Position{1, 2}, tokenError, "unclosed table key"}, - }) -} - -func TestComment(t *testing.T) { - testFlow(t, "# blahblah", []token{ - {Position{1, 11}, tokenEOF, ""}, - }) -} - -func TestKeyGroupComment(t *testing.T) { - testFlow(t, "[hello world] # blahblah", []token{ - {Position{1, 1}, tokenLeftBracket, "["}, - {Position{1, 2}, tokenKeyGroup, "hello world"}, - {Position{1, 13}, tokenRightBracket, "]"}, - {Position{1, 25}, tokenEOF, ""}, - }) -} - -func TestMultipleKeyGroupsComment(t *testing.T) { - testFlow(t, "[hello world] # blahblah\n[test]", []token{ - {Position{1, 1}, tokenLeftBracket, "["}, - {Position{1, 2}, tokenKeyGroup, "hello world"}, - {Position{1, 13}, tokenRightBracket, "]"}, - {Position{2, 1}, tokenLeftBracket, "["}, - {Position{2, 2}, tokenKeyGroup, "test"}, - {Position{2, 6}, tokenRightBracket, "]"}, - {Position{2, 7}, tokenEOF, ""}, - }) -} - -func TestSimpleWindowsCRLF(t *testing.T) { - testFlow(t, "a=4\r\nb=2", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 2}, tokenEqual, "="}, - {Position{1, 3}, tokenInteger, "4"}, - {Position{2, 1}, tokenKey, "b"}, - {Position{2, 2}, tokenEqual, "="}, - {Position{2, 3}, tokenInteger, "2"}, - {Position{2, 4}, tokenEOF, ""}, - }) -} - -func TestBasicKey(t *testing.T) { - testFlow(t, "hello", []token{ - {Position{1, 1}, tokenKey, "hello"}, - {Position{1, 6}, tokenEOF, ""}, - }) -} - -func TestBasicKeyWithUnderscore(t *testing.T) { - testFlow(t, "hello_hello", []token{ - {Position{1, 1}, tokenKey, "hello_hello"}, - {Position{1, 12}, tokenEOF, ""}, - }) -} - -func TestBasicKeyWithDash(t *testing.T) { - testFlow(t, "hello-world", []token{ - {Position{1, 1}, tokenKey, "hello-world"}, - {Position{1, 12}, tokenEOF, ""}, - }) -} - -func TestBasicKeyWithUppercaseMix(t *testing.T) { - testFlow(t, "helloHELLOHello", []token{ - {Position{1, 1}, tokenKey, "helloHELLOHello"}, - {Position{1, 16}, tokenEOF, ""}, - }) -} - -func TestBasicKeyWithInternationalCharacters(t *testing.T) { - testFlow(t, "héllÖ", []token{ - {Position{1, 1}, tokenKey, "héllÖ"}, - {Position{1, 6}, tokenEOF, ""}, - }) -} - -func TestBasicKeyAndEqual(t *testing.T) { - testFlow(t, "hello =", []token{ - {Position{1, 1}, tokenKey, "hello"}, - {Position{1, 7}, tokenEqual, "="}, - {Position{1, 8}, tokenEOF, ""}, - }) -} - -func TestKeyWithSharpAndEqual(t *testing.T) { - testFlow(t, "key#name = 5", []token{ - {Position{1, 1}, tokenError, "keys cannot contain # character"}, - }) -} - -func TestKeyWithSymbolsAndEqual(t *testing.T) { - testFlow(t, "~!@$^&*()_+-`1234567890[]\\|/?><.,;:' = 5", []token{ - {Position{1, 1}, tokenError, "keys cannot contain ~ character"}, - }) -} - -func TestKeyEqualStringEscape(t *testing.T) { - testFlow(t, `foo = "hello\""`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "hello\""}, - {Position{1, 16}, tokenEOF, ""}, - }) -} - -func TestKeyEqualStringUnfinished(t *testing.T) { - testFlow(t, `foo = "bar`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "unclosed string"}, - }) -} - -func TestKeyEqualString(t *testing.T) { - testFlow(t, `foo = "bar"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "bar"}, - {Position{1, 12}, tokenEOF, ""}, - }) -} - -func TestKeyEqualTrue(t *testing.T) { - testFlow(t, "foo = true", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenTrue, "true"}, - {Position{1, 11}, tokenEOF, ""}, - }) -} - -func TestKeyEqualFalse(t *testing.T) { - testFlow(t, "foo = false", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenFalse, "false"}, - {Position{1, 12}, tokenEOF, ""}, - }) -} - -func TestArrayNestedString(t *testing.T) { - testFlow(t, `a = [ ["hello", "world"] ]`, []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenLeftBracket, "["}, - {Position{1, 7}, tokenLeftBracket, "["}, - {Position{1, 9}, tokenString, "hello"}, - {Position{1, 15}, tokenComma, ","}, - {Position{1, 18}, tokenString, "world"}, - {Position{1, 24}, tokenRightBracket, "]"}, - {Position{1, 26}, tokenRightBracket, "]"}, - {Position{1, 27}, tokenEOF, ""}, - }) -} - -func TestArrayNestedInts(t *testing.T) { - testFlow(t, "a = [ [42, 21], [10] ]", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenLeftBracket, "["}, - {Position{1, 7}, tokenLeftBracket, "["}, - {Position{1, 8}, tokenInteger, "42"}, - {Position{1, 10}, tokenComma, ","}, - {Position{1, 12}, tokenInteger, "21"}, - {Position{1, 14}, tokenRightBracket, "]"}, - {Position{1, 15}, tokenComma, ","}, - {Position{1, 17}, tokenLeftBracket, "["}, - {Position{1, 18}, tokenInteger, "10"}, - {Position{1, 20}, tokenRightBracket, "]"}, - {Position{1, 22}, tokenRightBracket, "]"}, - {Position{1, 23}, tokenEOF, ""}, - }) -} - -func TestArrayInts(t *testing.T) { - testFlow(t, "a = [ 42, 21, 10, ]", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenLeftBracket, "["}, - {Position{1, 7}, tokenInteger, "42"}, - {Position{1, 9}, tokenComma, ","}, - {Position{1, 11}, tokenInteger, "21"}, - {Position{1, 13}, tokenComma, ","}, - {Position{1, 15}, tokenInteger, "10"}, - {Position{1, 17}, tokenComma, ","}, - {Position{1, 19}, tokenRightBracket, "]"}, - {Position{1, 20}, tokenEOF, ""}, - }) -} - -func TestMultilineArrayComments(t *testing.T) { - testFlow(t, "a = [1, # wow\n2, # such items\n3, # so array\n]", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenLeftBracket, "["}, - {Position{1, 6}, tokenInteger, "1"}, - {Position{1, 7}, tokenComma, ","}, - {Position{2, 1}, tokenInteger, "2"}, - {Position{2, 2}, tokenComma, ","}, - {Position{3, 1}, tokenInteger, "3"}, - {Position{3, 2}, tokenComma, ","}, - {Position{4, 1}, tokenRightBracket, "]"}, - {Position{4, 2}, tokenEOF, ""}, - }) -} - -func TestNestedArraysComment(t *testing.T) { - toml := ` -someArray = [ -# does not work -["entry1"] -]` - testFlow(t, toml, []token{ - {Position{2, 1}, tokenKey, "someArray"}, - {Position{2, 11}, tokenEqual, "="}, - {Position{2, 13}, tokenLeftBracket, "["}, - {Position{4, 1}, tokenLeftBracket, "["}, - {Position{4, 3}, tokenString, "entry1"}, - {Position{4, 10}, tokenRightBracket, "]"}, - {Position{5, 1}, tokenRightBracket, "]"}, - {Position{5, 2}, tokenEOF, ""}, - }) -} - -func TestKeyEqualArrayBools(t *testing.T) { - testFlow(t, "foo = [true, false, true]", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenLeftBracket, "["}, - {Position{1, 8}, tokenTrue, "true"}, - {Position{1, 12}, tokenComma, ","}, - {Position{1, 14}, tokenFalse, "false"}, - {Position{1, 19}, tokenComma, ","}, - {Position{1, 21}, tokenTrue, "true"}, - {Position{1, 25}, tokenRightBracket, "]"}, - {Position{1, 26}, tokenEOF, ""}, - }) -} - -func TestKeyEqualArrayBoolsWithComments(t *testing.T) { - testFlow(t, "foo = [true, false, true] # YEAH", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenLeftBracket, "["}, - {Position{1, 8}, tokenTrue, "true"}, - {Position{1, 12}, tokenComma, ","}, - {Position{1, 14}, tokenFalse, "false"}, - {Position{1, 19}, tokenComma, ","}, - {Position{1, 21}, tokenTrue, "true"}, - {Position{1, 25}, tokenRightBracket, "]"}, - {Position{1, 33}, tokenEOF, ""}, - }) -} - -func TestDateRegexp(t *testing.T) { - if dateRegexp.FindString("1979-05-27T07:32:00Z") == "" { - t.Error("basic lexing") - } - if dateRegexp.FindString("1979-05-27T00:32:00-07:00") == "" { - t.Error("offset lexing") - } - if dateRegexp.FindString("1979-05-27T00:32:00.999999-07:00") == "" { - t.Error("nano precision lexing") - } -} - -func TestKeyEqualDate(t *testing.T) { - testFlow(t, "foo = 1979-05-27T07:32:00Z", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenDate, "1979-05-27T07:32:00Z"}, - {Position{1, 27}, tokenEOF, ""}, - }) - testFlow(t, "foo = 1979-05-27T00:32:00-07:00", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenDate, "1979-05-27T00:32:00-07:00"}, - {Position{1, 32}, tokenEOF, ""}, - }) - testFlow(t, "foo = 1979-05-27T00:32:00.999999-07:00", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenDate, "1979-05-27T00:32:00.999999-07:00"}, - {Position{1, 39}, tokenEOF, ""}, - }) -} - -func TestFloatEndingWithDot(t *testing.T) { - testFlow(t, "foo = 42.", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenError, "float cannot end with a dot"}, - }) -} - -func TestFloatWithTwoDots(t *testing.T) { - testFlow(t, "foo = 4.2.", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenError, "cannot have two dots in one float"}, - }) -} - -func TestFloatWithExponent1(t *testing.T) { - testFlow(t, "a = 5e+22", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenFloat, "5e+22"}, - {Position{1, 10}, tokenEOF, ""}, - }) -} - -func TestFloatWithExponent2(t *testing.T) { - testFlow(t, "a = 5E+22", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenFloat, "5E+22"}, - {Position{1, 10}, tokenEOF, ""}, - }) -} - -func TestFloatWithExponent3(t *testing.T) { - testFlow(t, "a = -5e+22", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenFloat, "-5e+22"}, - {Position{1, 11}, tokenEOF, ""}, - }) -} - -func TestFloatWithExponent4(t *testing.T) { - testFlow(t, "a = -5e-22", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenFloat, "-5e-22"}, - {Position{1, 11}, tokenEOF, ""}, - }) -} - -func TestFloatWithExponent5(t *testing.T) { - testFlow(t, "a = 6.626e-34", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenFloat, "6.626e-34"}, - {Position{1, 14}, tokenEOF, ""}, - }) -} - -func TestInvalidEsquapeSequence(t *testing.T) { - testFlow(t, `foo = "\x"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "invalid escape sequence: \\x"}, - }) -} - -func TestNestedArrays(t *testing.T) { - testFlow(t, "foo = [[[]]]", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenLeftBracket, "["}, - {Position{1, 8}, tokenLeftBracket, "["}, - {Position{1, 9}, tokenLeftBracket, "["}, - {Position{1, 10}, tokenRightBracket, "]"}, - {Position{1, 11}, tokenRightBracket, "]"}, - {Position{1, 12}, tokenRightBracket, "]"}, - {Position{1, 13}, tokenEOF, ""}, - }) -} - -func TestKeyEqualNumber(t *testing.T) { - testFlow(t, "foo = 42", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "42"}, - {Position{1, 9}, tokenEOF, ""}, - }) - - testFlow(t, "foo = +42", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "+42"}, - {Position{1, 10}, tokenEOF, ""}, - }) - - testFlow(t, "foo = -42", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "-42"}, - {Position{1, 10}, tokenEOF, ""}, - }) - - testFlow(t, "foo = 4.2", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenFloat, "4.2"}, - {Position{1, 10}, tokenEOF, ""}, - }) - - testFlow(t, "foo = +4.2", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenFloat, "+4.2"}, - {Position{1, 11}, tokenEOF, ""}, - }) - - testFlow(t, "foo = -4.2", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenFloat, "-4.2"}, - {Position{1, 11}, tokenEOF, ""}, - }) - - testFlow(t, "foo = 1_000", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "1_000"}, - {Position{1, 12}, tokenEOF, ""}, - }) - - testFlow(t, "foo = 5_349_221", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "5_349_221"}, - {Position{1, 16}, tokenEOF, ""}, - }) - - testFlow(t, "foo = 1_2_3_4_5", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "1_2_3_4_5"}, - {Position{1, 16}, tokenEOF, ""}, - }) - - testFlow(t, "flt8 = 9_224_617.445_991_228_313", []token{ - {Position{1, 1}, tokenKey, "flt8"}, - {Position{1, 6}, tokenEqual, "="}, - {Position{1, 8}, tokenFloat, "9_224_617.445_991_228_313"}, - {Position{1, 33}, tokenEOF, ""}, - }) - - testFlow(t, "foo = +", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenError, "no digit in that number"}, - }) -} - -func TestMultiline(t *testing.T) { - testFlow(t, "foo = 42\nbar=21", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 7}, tokenInteger, "42"}, - {Position{2, 1}, tokenKey, "bar"}, - {Position{2, 4}, tokenEqual, "="}, - {Position{2, 5}, tokenInteger, "21"}, - {Position{2, 7}, tokenEOF, ""}, - }) -} - -func TestKeyEqualStringUnicodeEscape(t *testing.T) { - testFlow(t, `foo = "hello \u2665"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "hello ♥"}, - {Position{1, 21}, tokenEOF, ""}, - }) - testFlow(t, `foo = "hello \U000003B4"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "hello δ"}, - {Position{1, 25}, tokenEOF, ""}, - }) - testFlow(t, `foo = "\uabcd"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "\uabcd"}, - {Position{1, 15}, tokenEOF, ""}, - }) - testFlow(t, `foo = "\uABCD"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "\uABCD"}, - {Position{1, 15}, tokenEOF, ""}, - }) - testFlow(t, `foo = "\U000bcdef"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "\U000bcdef"}, - {Position{1, 19}, tokenEOF, ""}, - }) - testFlow(t, `foo = "\U000BCDEF"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "\U000BCDEF"}, - {Position{1, 19}, tokenEOF, ""}, - }) - testFlow(t, `foo = "\u2"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "unfinished unicode escape"}, - }) - testFlow(t, `foo = "\U2"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "unfinished unicode escape"}, - }) -} - -func TestKeyEqualStringNoEscape(t *testing.T) { - testFlow(t, "foo = \"hello \u0002\"", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "unescaped control character U+0002"}, - }) - testFlow(t, "foo = \"hello \u001F\"", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "unescaped control character U+001F"}, - }) -} - -func TestLiteralString(t *testing.T) { - testFlow(t, `foo = 'C:\Users\nodejs\templates'`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, `C:\Users\nodejs\templates`}, - {Position{1, 34}, tokenEOF, ""}, - }) - testFlow(t, `foo = '\\ServerX\admin$\system32\'`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, `\\ServerX\admin$\system32\`}, - {Position{1, 35}, tokenEOF, ""}, - }) - testFlow(t, `foo = 'Tom "Dubs" Preston-Werner'`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, `Tom "Dubs" Preston-Werner`}, - {Position{1, 34}, tokenEOF, ""}, - }) - testFlow(t, `foo = '<\i\c*\s*>'`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, `<\i\c*\s*>`}, - {Position{1, 19}, tokenEOF, ""}, - }) - testFlow(t, `foo = 'C:\Users\nodejs\unfinis`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenError, "unclosed string"}, - }) -} - -func TestMultilineLiteralString(t *testing.T) { - testFlow(t, `foo = '''hello 'literal' world'''`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 10}, tokenString, `hello 'literal' world`}, - {Position{1, 34}, tokenEOF, ""}, - }) - - testFlow(t, "foo = '''\nhello\n'literal'\nworld'''", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{2, 1}, tokenString, "hello\n'literal'\nworld"}, - {Position{4, 9}, tokenEOF, ""}, - }) - testFlow(t, "foo = '''\r\nhello\r\n'literal'\r\nworld'''", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{2, 1}, tokenString, "hello\r\n'literal'\r\nworld"}, - {Position{4, 9}, tokenEOF, ""}, - }) -} - -func TestMultilineString(t *testing.T) { - testFlow(t, `foo = """hello "literal" world"""`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 10}, tokenString, `hello "literal" world`}, - {Position{1, 34}, tokenEOF, ""}, - }) - - testFlow(t, "foo = \"\"\"\r\nhello\\\r\n\"literal\"\\\nworld\"\"\"", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{2, 1}, tokenString, "hello\"literal\"world"}, - {Position{4, 9}, tokenEOF, ""}, - }) - - testFlow(t, "foo = \"\"\"\\\n \\\n \\\n hello\\\nmultiline\\\nworld\"\"\"", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 10}, tokenString, "hellomultilineworld"}, - {Position{6, 9}, tokenEOF, ""}, - }) - - testFlow(t, "key2 = \"\"\"\nThe quick brown \\\n\n\n fox jumps over \\\n the lazy dog.\"\"\"", []token{ - {Position{1, 1}, tokenKey, "key2"}, - {Position{1, 6}, tokenEqual, "="}, - {Position{2, 1}, tokenString, "The quick brown fox jumps over the lazy dog."}, - {Position{6, 21}, tokenEOF, ""}, - }) - - testFlow(t, "key2 = \"\"\"\\\n The quick brown \\\n fox jumps over \\\n the lazy dog.\\\n \"\"\"", []token{ - {Position{1, 1}, tokenKey, "key2"}, - {Position{1, 6}, tokenEqual, "="}, - {Position{1, 11}, tokenString, "The quick brown fox jumps over the lazy dog."}, - {Position{5, 11}, tokenEOF, ""}, - }) - - testFlow(t, `key2 = "Roses are red\nViolets are blue"`, []token{ - {Position{1, 1}, tokenKey, "key2"}, - {Position{1, 6}, tokenEqual, "="}, - {Position{1, 9}, tokenString, "Roses are red\nViolets are blue"}, - {Position{1, 41}, tokenEOF, ""}, - }) - - testFlow(t, "key2 = \"\"\"\nRoses are red\nViolets are blue\"\"\"", []token{ - {Position{1, 1}, tokenKey, "key2"}, - {Position{1, 6}, tokenEqual, "="}, - {Position{2, 1}, tokenString, "Roses are red\nViolets are blue"}, - {Position{3, 20}, tokenEOF, ""}, - }) -} - -func TestUnicodeString(t *testing.T) { - testFlow(t, `foo = "hello ♥ world"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "hello ♥ world"}, - {Position{1, 22}, tokenEOF, ""}, - }) -} -func TestEscapeInString(t *testing.T) { - testFlow(t, `foo = "\b\f\/"`, []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenEqual, "="}, - {Position{1, 8}, tokenString, "\b\f/"}, - {Position{1, 15}, tokenEOF, ""}, - }) -} - -func TestKeyGroupArray(t *testing.T) { - testFlow(t, "[[foo]]", []token{ - {Position{1, 1}, tokenDoubleLeftBracket, "[["}, - {Position{1, 3}, tokenKeyGroupArray, "foo"}, - {Position{1, 6}, tokenDoubleRightBracket, "]]"}, - {Position{1, 8}, tokenEOF, ""}, - }) -} - -func TestQuotedKey(t *testing.T) { - testFlow(t, "\"a b\" = 42", []token{ - {Position{1, 1}, tokenKey, "\"a b\""}, - {Position{1, 7}, tokenEqual, "="}, - {Position{1, 9}, tokenInteger, "42"}, - {Position{1, 11}, tokenEOF, ""}, - }) -} - -func TestKeyNewline(t *testing.T) { - testFlow(t, "a\n= 4", []token{ - {Position{1, 1}, tokenError, "keys cannot contain new lines"}, - }) -} - -func TestInvalidFloat(t *testing.T) { - testFlow(t, "a=7e1_", []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 2}, tokenEqual, "="}, - {Position{1, 3}, tokenFloat, "7e1_"}, - {Position{1, 7}, tokenEOF, ""}, - }) -} - -func TestLexUnknownRvalue(t *testing.T) { - testFlow(t, `a = !b`, []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenError, "no value can start with !"}, - }) - - testFlow(t, `a = \b`, []token{ - {Position{1, 1}, tokenKey, "a"}, - {Position{1, 3}, tokenEqual, "="}, - {Position{1, 5}, tokenError, `no value can start with \`}, - }) -} diff --git a/vendor/github.com/pelletier/go-toml/marshal_test.go b/vendor/github.com/pelletier/go-toml/marshal_test.go deleted file mode 100644 index 891222e9b1..0000000000 --- a/vendor/github.com/pelletier/go-toml/marshal_test.go +++ /dev/null @@ -1,583 +0,0 @@ -package toml - -import ( - "bytes" - "encoding/json" - "fmt" - "io/ioutil" - "reflect" - "testing" - "time" -) - -type basicMarshalTestStruct struct { - String string `toml:"string"` - StringList []string `toml:"strlist"` - Sub basicMarshalTestSubStruct `toml:"subdoc"` - SubList []basicMarshalTestSubStruct `toml:"sublist"` -} - -type basicMarshalTestSubStruct struct { - String2 string -} - -var basicTestData = basicMarshalTestStruct{ - String: "Hello", - StringList: []string{"Howdy", "Hey There"}, - Sub: basicMarshalTestSubStruct{"One"}, - SubList: []basicMarshalTestSubStruct{{"Two"}, {"Three"}}, -} - -var basicTestToml = []byte(`string = "Hello" -strlist = ["Howdy","Hey There"] - -[subdoc] - String2 = "One" - -[[sublist]] - String2 = "Two" - -[[sublist]] - String2 = "Three" -`) - -func TestBasicMarshal(t *testing.T) { - result, err := Marshal(basicTestData) - if err != nil { - t.Fatal(err) - } - expected := basicTestToml - if !bytes.Equal(result, expected) { - t.Errorf("Bad marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestBasicUnmarshal(t *testing.T) { - result := basicMarshalTestStruct{} - err := Unmarshal(basicTestToml, &result) - expected := basicTestData - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - t.Errorf("Bad unmarshal: expected %v, got %v", expected, result) - } -} - -type testDoc struct { - Title string `toml:"title"` - Basics testDocBasics `toml:"basic"` - BasicLists testDocBasicLists `toml:"basic_lists"` - BasicMap map[string]string `toml:"basic_map"` - Subdocs testDocSubs `toml:"subdoc"` - SubDocList []testSubDoc `toml:"subdoclist"` - SubDocPtrs []*testSubDoc `toml:"subdocptrs"` - err int `toml:"shouldntBeHere"` - unexported int `toml:"shouldntBeHere"` - Unexported2 int `toml:"-"` -} - -type testDocBasics struct { - Bool bool `toml:"bool"` - Date time.Time `toml:"date"` - Float float32 `toml:"float"` - Int int `toml:"int"` - Uint uint `toml:"uint"` - String *string `toml:"string"` - unexported int `toml:"shouldntBeHere"` -} - -type testDocBasicLists struct { - Bools []bool `toml:"bools"` - Dates []time.Time `toml:"dates"` - Floats []*float32 `toml:"floats"` - Ints []int `toml:"ints"` - Strings []string `toml:"strings"` - UInts []uint `toml:"uints"` -} - -type testDocSubs struct { - First testSubDoc `toml:"first"` - Second *testSubDoc `toml:"second"` -} - -type testSubDoc struct { - Name string `toml:"name"` - unexported int `toml:"shouldntBeHere"` -} - -var biteMe = "Bite me" -var float1 float32 = 12.3 -var float2 float32 = 45.6 -var float3 float32 = 78.9 -var subdoc = testSubDoc{"Second", 0} - -var docData = testDoc{ - Title: "TOML Marshal Testing", - unexported: 0, - Unexported2: 0, - Basics: testDocBasics{ - Bool: true, - Date: time.Date(1979, 5, 27, 7, 32, 0, 0, time.UTC), - Float: 123.4, - Int: 5000, - Uint: 5001, - String: &biteMe, - unexported: 0, - }, - BasicLists: testDocBasicLists{ - Bools: []bool{true, false, true}, - Dates: []time.Time{ - time.Date(1979, 5, 27, 7, 32, 0, 0, time.UTC), - time.Date(1980, 5, 27, 7, 32, 0, 0, time.UTC), - }, - Floats: []*float32{&float1, &float2, &float3}, - Ints: []int{8001, 8001, 8002}, - Strings: []string{"One", "Two", "Three"}, - UInts: []uint{5002, 5003}, - }, - BasicMap: map[string]string{ - "one": "one", - "two": "two", - }, - Subdocs: testDocSubs{ - First: testSubDoc{"First", 0}, - Second: &subdoc, - }, - SubDocList: []testSubDoc{ - testSubDoc{"List.First", 0}, - testSubDoc{"List.Second", 0}, - }, - SubDocPtrs: []*testSubDoc{&subdoc}, -} - -func TestDocMarshal(t *testing.T) { - result, err := Marshal(docData) - if err != nil { - t.Fatal(err) - } - expected, _ := ioutil.ReadFile("marshal_test.toml") - if !bytes.Equal(result, expected) { - t.Errorf("Bad marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestDocUnmarshal(t *testing.T) { - result := testDoc{} - tomlData, _ := ioutil.ReadFile("marshal_test.toml") - err := Unmarshal(tomlData, &result) - expected := docData - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - resStr, _ := json.MarshalIndent(result, "", " ") - expStr, _ := json.MarshalIndent(expected, "", " ") - t.Errorf("Bad unmarshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expStr, resStr) - } -} - -type tomlTypeCheckTest struct { - name string - item interface{} - typ int //0=primitive, 1=otherslice, 2=treeslice, 3=tree -} - -func TestTypeChecks(t *testing.T) { - tests := []tomlTypeCheckTest{ - {"integer", 2, 0}, - {"time", time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC), 0}, - {"stringlist", []string{"hello", "hi"}, 1}, - {"timelist", []time.Time{time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)}, 1}, - {"objectlist", []tomlTypeCheckTest{}, 2}, - {"object", tomlTypeCheckTest{}, 3}, - } - - for _, test := range tests { - expected := []bool{false, false, false, false} - expected[test.typ] = true - result := []bool{ - isPrimitive(reflect.TypeOf(test.item)), - isOtherSlice(reflect.TypeOf(test.item)), - isTreeSlice(reflect.TypeOf(test.item)), - isTree(reflect.TypeOf(test.item)), - } - if !reflect.DeepEqual(expected, result) { - t.Errorf("Bad type check on %q: expected %v, got %v", test.name, expected, result) - } - } -} - -type unexportedMarshalTestStruct struct { - String string `toml:"string"` - StringList []string `toml:"strlist"` - Sub basicMarshalTestSubStruct `toml:"subdoc"` - SubList []basicMarshalTestSubStruct `toml:"sublist"` - unexported int `toml:"shouldntBeHere"` - Unexported2 int `toml:"-"` -} - -var unexportedTestData = unexportedMarshalTestStruct{ - String: "Hello", - StringList: []string{"Howdy", "Hey There"}, - Sub: basicMarshalTestSubStruct{"One"}, - SubList: []basicMarshalTestSubStruct{{"Two"}, {"Three"}}, - unexported: 0, - Unexported2: 0, -} - -var unexportedTestToml = []byte(`string = "Hello" -strlist = ["Howdy","Hey There"] -unexported = 1 -shouldntBeHere = 2 - -[subdoc] - String2 = "One" - -[[sublist]] - String2 = "Two" - -[[sublist]] - String2 = "Three" -`) - -func TestUnexportedUnmarshal(t *testing.T) { - result := unexportedMarshalTestStruct{} - err := Unmarshal(unexportedTestToml, &result) - expected := unexportedTestData - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - t.Errorf("Bad unexported unmarshal: expected %v, got %v", expected, result) - } -} - -type errStruct struct { - Bool bool `toml:"bool"` - Date time.Time `toml:"date"` - Float float64 `toml:"float"` - Int int16 `toml:"int"` - String *string `toml:"string"` -} - -var errTomls = []string{ - "bool = truly\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = 5000\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:3200Z\nfloat = 123.4\nint = 5000\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:32:00Z\nfloat = 123a4\nint = 5000\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = j000\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = 5000\nstring = Bite me", - "bool = true\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = 5000\nstring = Bite me", - "bool = 1\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = 5000\nstring = \"Bite me\"", - "bool = true\ndate = 1\nfloat = 123.4\nint = 5000\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:32:00Z\n\"sorry\"\nint = 5000\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = \"sorry\"\nstring = \"Bite me\"", - "bool = true\ndate = 1979-05-27T07:32:00Z\nfloat = 123.4\nint = 5000\nstring = 1", -} - -type mapErr struct { - Vals map[string]float64 -} - -type intErr struct { - Int1 int - Int2 int8 - Int3 int16 - Int4 int32 - Int5 int64 - UInt1 uint - UInt2 uint8 - UInt3 uint16 - UInt4 uint32 - UInt5 uint64 - Flt1 float32 - Flt2 float64 -} - -var intErrTomls = []string{ - "Int1 = []\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = []\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = []\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = []\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = []\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = []\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = []\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = []\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = []\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = []\nFlt1 = 1.0\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = []\nFlt2 = 2.0", - "Int1 = 1\nInt2 = 2\nInt3 = 3\nInt4 = 4\nInt5 = 5\nUInt1 = 1\nUInt2 = 2\nUInt3 = 3\nUInt4 = 4\nUInt5 = 5\nFlt1 = 1.0\nFlt2 = []", -} - -func TestErrUnmarshal(t *testing.T) { - for ind, toml := range errTomls { - result := errStruct{} - err := Unmarshal([]byte(toml), &result) - if err == nil { - t.Errorf("Expected err from case %d\n", ind) - } - } - result2 := mapErr{} - err := Unmarshal([]byte("[Vals]\nfred=\"1.2\""), &result2) - if err == nil { - t.Errorf("Expected err from map") - } - for ind, toml := range intErrTomls { - result3 := intErr{} - err := Unmarshal([]byte(toml), &result3) - if err == nil { - t.Errorf("Expected int err from case %d\n", ind) - } - } -} - -type emptyMarshalTestStruct struct { - Title string `toml:"title"` - Bool bool `toml:"bool"` - Int int `toml:"int"` - String string `toml:"string"` - StringList []string `toml:"stringlist"` - Ptr *basicMarshalTestStruct `toml:"ptr"` - Map map[string]string `toml:"map"` -} - -var emptyTestData = emptyMarshalTestStruct{ - Title: "Placeholder", - Bool: false, - Int: 0, - String: "", - StringList: []string{}, - Ptr: nil, - Map: map[string]string{}, -} - -var emptyTestToml = []byte(`bool = false -int = 0 -string = "" -stringlist = [] -title = "Placeholder" - -[map] -`) - -type emptyMarshalTestStruct2 struct { - Title string `toml:"title"` - Bool bool `toml:"bool,omitempty"` - Int int `toml:"int, omitempty"` - String string `toml:"string,omitempty "` - StringList []string `toml:"stringlist,omitempty"` - Ptr *basicMarshalTestStruct `toml:"ptr,omitempty"` - Map map[string]string `toml:"map,omitempty"` -} - -var emptyTestData2 = emptyMarshalTestStruct2{ - Title: "Placeholder", - Bool: false, - Int: 0, - String: "", - StringList: []string{}, - Ptr: nil, - Map: map[string]string{}, -} - -var emptyTestToml2 = []byte(`title = "Placeholder" -`) - -func TestEmptyMarshal(t *testing.T) { - result, err := Marshal(emptyTestData) - if err != nil { - t.Fatal(err) - } - expected := emptyTestToml - if !bytes.Equal(result, expected) { - t.Errorf("Bad empty marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestEmptyMarshalOmit(t *testing.T) { - result, err := Marshal(emptyTestData2) - if err != nil { - t.Fatal(err) - } - expected := emptyTestToml2 - if !bytes.Equal(result, expected) { - t.Errorf("Bad empty omit marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestEmptyUnmarshal(t *testing.T) { - result := emptyMarshalTestStruct{} - err := Unmarshal(emptyTestToml, &result) - expected := emptyTestData - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - t.Errorf("Bad empty unmarshal: expected %v, got %v", expected, result) - } -} - -func TestEmptyUnmarshalOmit(t *testing.T) { - result := emptyMarshalTestStruct2{} - err := Unmarshal(emptyTestToml, &result) - expected := emptyTestData2 - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - t.Errorf("Bad empty omit unmarshal: expected %v, got %v", expected, result) - } -} - -type pointerMarshalTestStruct struct { - Str *string - List *[]string - ListPtr *[]*string - Map *map[string]string - MapPtr *map[string]*string - EmptyStr *string - EmptyList *[]string - EmptyMap *map[string]string - DblPtr *[]*[]*string -} - -var pointerStr = "Hello" -var pointerList = []string{"Hello back"} -var pointerListPtr = []*string{&pointerStr} -var pointerMap = map[string]string{"response": "Goodbye"} -var pointerMapPtr = map[string]*string{"alternate": &pointerStr} -var pointerTestData = pointerMarshalTestStruct{ - Str: &pointerStr, - List: &pointerList, - ListPtr: &pointerListPtr, - Map: &pointerMap, - MapPtr: &pointerMapPtr, - EmptyStr: nil, - EmptyList: nil, - EmptyMap: nil, -} - -var pointerTestToml = []byte(`List = ["Hello back"] -ListPtr = ["Hello"] -Str = "Hello" - -[Map] - response = "Goodbye" - -[MapPtr] - alternate = "Hello" -`) - -func TestPointerMarshal(t *testing.T) { - result, err := Marshal(pointerTestData) - if err != nil { - t.Fatal(err) - } - expected := pointerTestToml - if !bytes.Equal(result, expected) { - t.Errorf("Bad pointer marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestPointerUnmarshal(t *testing.T) { - result := pointerMarshalTestStruct{} - err := Unmarshal(pointerTestToml, &result) - expected := pointerTestData - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - t.Errorf("Bad pointer unmarshal: expected %v, got %v", expected, result) - } -} - -type nestedMarshalTestStruct struct { - String [][]string - //Struct [][]basicMarshalTestSubStruct - StringPtr *[]*[]*string - // StructPtr *[]*[]*basicMarshalTestSubStruct -} - -var str1 = "Three" -var str2 = "Four" -var strPtr = []*string{&str1, &str2} -var strPtr2 = []*[]*string{&strPtr} - -var nestedTestData = nestedMarshalTestStruct{ - String: [][]string{[]string{"Five", "Six"}, []string{"One", "Two"}}, - StringPtr: &strPtr2, -} - -var nestedTestToml = []byte(`String = [["Five","Six"],["One","Two"]] -StringPtr = [["Three","Four"]] -`) - -func TestNestedMarshal(t *testing.T) { - result, err := Marshal(nestedTestData) - if err != nil { - t.Fatal(err) - } - expected := nestedTestToml - if !bytes.Equal(result, expected) { - t.Errorf("Bad nested marshal: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestNestedUnmarshal(t *testing.T) { - result := nestedMarshalTestStruct{} - err := Unmarshal(nestedTestToml, &result) - expected := nestedTestData - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(result, expected) { - t.Errorf("Bad nested unmarshal: expected %v, got %v", expected, result) - } -} - -type customMarshalerParent struct { - Self customMarshaler `toml:"me"` - Friends []customMarshaler `toml:"friends"` -} - -type customMarshaler struct { - FirsName string - LastName string -} - -func (c customMarshaler) MarshalTOML() ([]byte, error) { - fullName := fmt.Sprintf("%s %s", c.FirsName, c.LastName) - return []byte(fullName), nil -} - -var customMarshalerData = customMarshaler{FirsName: "Sally", LastName: "Fields"} -var customMarshalerToml = []byte(`Sally Fields`) -var nestedCustomMarshalerData = customMarshalerParent{ - Self: customMarshaler{FirsName: "Maiku", LastName: "Suteda"}, - Friends: []customMarshaler{customMarshalerData}, -} -var nestedCustomMarshalerToml = []byte(`friends = ["Sally Fields"] -me = "Maiku Suteda" -`) - -func TestCustomMarshaler(t *testing.T) { - result, err := Marshal(customMarshalerData) - if err != nil { - t.Fatal(err) - } - expected := customMarshalerToml - if !bytes.Equal(result, expected) { - t.Errorf("Bad custom marshaler: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} - -func TestNestedCustomMarshaler(t *testing.T) { - result, err := Marshal(nestedCustomMarshalerData) - if err != nil { - t.Fatal(err) - } - expected := nestedCustomMarshalerToml - if !bytes.Equal(result, expected) { - t.Errorf("Bad nested custom marshaler: expected\n-----\n%s\n-----\ngot\n-----\n%s\n-----\n", expected, result) - } -} diff --git a/vendor/github.com/pelletier/go-toml/marshal_test.toml b/vendor/github.com/pelletier/go-toml/marshal_test.toml deleted file mode 100644 index 1c5f98e7a8..0000000000 --- a/vendor/github.com/pelletier/go-toml/marshal_test.toml +++ /dev/null @@ -1,38 +0,0 @@ -title = "TOML Marshal Testing" - -[basic] - bool = true - date = 1979-05-27T07:32:00Z - float = 123.4 - int = 5000 - string = "Bite me" - uint = 5001 - -[basic_lists] - bools = [true,false,true] - dates = [1979-05-27T07:32:00Z,1980-05-27T07:32:00Z] - floats = [12.3,45.6,78.9] - ints = [8001,8001,8002] - strings = ["One","Two","Three"] - uints = [5002,5003] - -[basic_map] - one = "one" - two = "two" - -[subdoc] - - [subdoc.first] - name = "First" - - [subdoc.second] - name = "Second" - -[[subdoclist]] - name = "List.First" - -[[subdoclist]] - name = "List.Second" - -[[subdocptrs]] - name = "Second" diff --git a/vendor/github.com/pelletier/go-toml/match_test.go b/vendor/github.com/pelletier/go-toml/match_test.go deleted file mode 100644 index b63654ad2f..0000000000 --- a/vendor/github.com/pelletier/go-toml/match_test.go +++ /dev/null @@ -1,201 +0,0 @@ -package toml - -import ( - "fmt" - "testing" -) - -// dump path tree to a string -func pathString(root pathFn) string { - result := fmt.Sprintf("%T:", root) - switch fn := root.(type) { - case *terminatingFn: - result += "{}" - case *matchKeyFn: - result += fmt.Sprintf("{%s}", fn.Name) - result += pathString(fn.next) - case *matchIndexFn: - result += fmt.Sprintf("{%d}", fn.Idx) - result += pathString(fn.next) - case *matchSliceFn: - result += fmt.Sprintf("{%d:%d:%d}", - fn.Start, fn.End, fn.Step) - result += pathString(fn.next) - case *matchAnyFn: - result += "{}" - result += pathString(fn.next) - case *matchUnionFn: - result += "{[" - for _, v := range fn.Union { - result += pathString(v) + ", " - } - result += "]}" - case *matchRecursiveFn: - result += "{}" - result += pathString(fn.next) - case *matchFilterFn: - result += fmt.Sprintf("{%s}", fn.Name) - result += pathString(fn.next) - } - return result -} - -func assertPathMatch(t *testing.T, path, ref *Query) bool { - pathStr := pathString(path.root) - refStr := pathString(ref.root) - if pathStr != refStr { - t.Errorf("paths do not match") - t.Log("test:", pathStr) - t.Log("ref: ", refStr) - return false - } - return true -} - -func assertPath(t *testing.T, query string, ref *Query) { - path, _ := parseQuery(lexQuery(query)) - assertPathMatch(t, path, ref) -} - -func buildPath(parts ...pathFn) *Query { - query := newQuery() - for _, v := range parts { - query.appendPath(v) - } - return query -} - -func TestPathRoot(t *testing.T) { - assertPath(t, - "$", - buildPath( - // empty - )) -} - -func TestPathKey(t *testing.T) { - assertPath(t, - "$.foo", - buildPath( - newMatchKeyFn("foo"), - )) -} - -func TestPathBracketKey(t *testing.T) { - assertPath(t, - "$[foo]", - buildPath( - newMatchKeyFn("foo"), - )) -} - -func TestPathBracketStringKey(t *testing.T) { - assertPath(t, - "$['foo']", - buildPath( - newMatchKeyFn("foo"), - )) -} - -func TestPathIndex(t *testing.T) { - assertPath(t, - "$[123]", - buildPath( - newMatchIndexFn(123), - )) -} - -func TestPathSliceStart(t *testing.T) { - assertPath(t, - "$[123:]", - buildPath( - newMatchSliceFn(123, maxInt, 1), - )) -} - -func TestPathSliceStartEnd(t *testing.T) { - assertPath(t, - "$[123:456]", - buildPath( - newMatchSliceFn(123, 456, 1), - )) -} - -func TestPathSliceStartEndColon(t *testing.T) { - assertPath(t, - "$[123:456:]", - buildPath( - newMatchSliceFn(123, 456, 1), - )) -} - -func TestPathSliceStartStep(t *testing.T) { - assertPath(t, - "$[123::7]", - buildPath( - newMatchSliceFn(123, maxInt, 7), - )) -} - -func TestPathSliceEndStep(t *testing.T) { - assertPath(t, - "$[:456:7]", - buildPath( - newMatchSliceFn(0, 456, 7), - )) -} - -func TestPathSliceStep(t *testing.T) { - assertPath(t, - "$[::7]", - buildPath( - newMatchSliceFn(0, maxInt, 7), - )) -} - -func TestPathSliceAll(t *testing.T) { - assertPath(t, - "$[123:456:7]", - buildPath( - newMatchSliceFn(123, 456, 7), - )) -} - -func TestPathAny(t *testing.T) { - assertPath(t, - "$.*", - buildPath( - newMatchAnyFn(), - )) -} - -func TestPathUnion(t *testing.T) { - assertPath(t, - "$[foo, bar, baz]", - buildPath( - &matchUnionFn{[]pathFn{ - newMatchKeyFn("foo"), - newMatchKeyFn("bar"), - newMatchKeyFn("baz"), - }}, - )) -} - -func TestPathRecurse(t *testing.T) { - assertPath(t, - "$..*", - buildPath( - newMatchRecursiveFn(), - )) -} - -func TestPathFilterExpr(t *testing.T) { - assertPath(t, - "$[?('foo'),?(bar)]", - buildPath( - &matchUnionFn{[]pathFn{ - newMatchFilterFn("foo", Position{}), - newMatchFilterFn("bar", Position{}), - }}, - )) -} diff --git a/vendor/github.com/pelletier/go-toml/parser_test.go b/vendor/github.com/pelletier/go-toml/parser_test.go deleted file mode 100644 index 58aae203a6..0000000000 --- a/vendor/github.com/pelletier/go-toml/parser_test.go +++ /dev/null @@ -1,785 +0,0 @@ -package toml - -import ( - "fmt" - "reflect" - "testing" - "time" - - "github.com/davecgh/go-spew/spew" -) - -func assertSubTree(t *testing.T, path []string, tree *TomlTree, err error, ref map[string]interface{}) { - if err != nil { - t.Error("Non-nil error:", err.Error()) - return - } - for k, v := range ref { - nextPath := append(path, k) - t.Log("asserting path", nextPath) - // NOTE: directly access key instead of resolve by path - // NOTE: see TestSpecialKV - switch node := tree.GetPath([]string{k}).(type) { - case []*TomlTree: - t.Log("\tcomparing key", nextPath, "by array iteration") - for idx, item := range node { - assertSubTree(t, nextPath, item, err, v.([]map[string]interface{})[idx]) - } - case *TomlTree: - t.Log("\tcomparing key", nextPath, "by subtree assestion") - assertSubTree(t, nextPath, node, err, v.(map[string]interface{})) - default: - t.Log("\tcomparing key", nextPath, "by string representation because it's of type", reflect.TypeOf(node)) - if fmt.Sprintf("%v", node) != fmt.Sprintf("%v", v) { - t.Errorf("was expecting %v at %v but got %v", v, k, node) - } - } - } -} - -func assertTree(t *testing.T, tree *TomlTree, err error, ref map[string]interface{}) { - t.Log("Asserting tree:\n", spew.Sdump(tree)) - assertSubTree(t, []string{}, tree, err, ref) - t.Log("Finished tree assertion.") -} - -func TestCreateSubTree(t *testing.T) { - tree := newTomlTree() - tree.createSubTree([]string{"a", "b", "c"}, Position{}) - tree.Set("a.b.c", 42) - if tree.Get("a.b.c") != 42 { - t.Fail() - } -} - -func TestSimpleKV(t *testing.T) { - tree, err := Load("a = 42") - assertTree(t, tree, err, map[string]interface{}{ - "a": int64(42), - }) - - tree, _ = Load("a = 42\nb = 21") - assertTree(t, tree, err, map[string]interface{}{ - "a": int64(42), - "b": int64(21), - }) -} - -func TestNumberInKey(t *testing.T) { - tree, err := Load("hello2 = 42") - assertTree(t, tree, err, map[string]interface{}{ - "hello2": int64(42), - }) -} - -func TestSimpleNumbers(t *testing.T) { - tree, err := Load("a = +42\nb = -21\nc = +4.2\nd = -2.1") - assertTree(t, tree, err, map[string]interface{}{ - "a": int64(42), - "b": int64(-21), - "c": float64(4.2), - "d": float64(-2.1), - }) -} - -func TestNumbersWithUnderscores(t *testing.T) { - tree, err := Load("a = 1_000") - assertTree(t, tree, err, map[string]interface{}{ - "a": int64(1000), - }) - - tree, err = Load("a = 5_349_221") - assertTree(t, tree, err, map[string]interface{}{ - "a": int64(5349221), - }) - - tree, err = Load("a = 1_2_3_4_5") - assertTree(t, tree, err, map[string]interface{}{ - "a": int64(12345), - }) - - tree, err = Load("flt8 = 9_224_617.445_991_228_313") - assertTree(t, tree, err, map[string]interface{}{ - "flt8": float64(9224617.445991228313), - }) - - tree, err = Load("flt9 = 1e1_00") - assertTree(t, tree, err, map[string]interface{}{ - "flt9": float64(1e100), - }) -} - -func TestFloatsWithExponents(t *testing.T) { - tree, err := Load("a = 5e+22\nb = 5E+22\nc = -5e+22\nd = -5e-22\ne = 6.626e-34") - assertTree(t, tree, err, map[string]interface{}{ - "a": float64(5e+22), - "b": float64(5E+22), - "c": float64(-5e+22), - "d": float64(-5e-22), - "e": float64(6.626e-34), - }) -} - -func TestSimpleDate(t *testing.T) { - tree, err := Load("a = 1979-05-27T07:32:00Z") - assertTree(t, tree, err, map[string]interface{}{ - "a": time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), - }) -} - -func TestDateOffset(t *testing.T) { - tree, err := Load("a = 1979-05-27T00:32:00-07:00") - assertTree(t, tree, err, map[string]interface{}{ - "a": time.Date(1979, time.May, 27, 0, 32, 0, 0, time.FixedZone("", -7*60*60)), - }) -} - -func TestDateNano(t *testing.T) { - tree, err := Load("a = 1979-05-27T00:32:00.999999999-07:00") - assertTree(t, tree, err, map[string]interface{}{ - "a": time.Date(1979, time.May, 27, 0, 32, 0, 999999999, time.FixedZone("", -7*60*60)), - }) -} - -func TestSimpleString(t *testing.T) { - tree, err := Load("a = \"hello world\"") - assertTree(t, tree, err, map[string]interface{}{ - "a": "hello world", - }) -} - -func TestSpaceKey(t *testing.T) { - tree, err := Load("\"a b\" = \"hello world\"") - assertTree(t, tree, err, map[string]interface{}{ - "a b": "hello world", - }) -} - -func TestStringEscapables(t *testing.T) { - tree, err := Load("a = \"a \\n b\"") - assertTree(t, tree, err, map[string]interface{}{ - "a": "a \n b", - }) - - tree, err = Load("a = \"a \\t b\"") - assertTree(t, tree, err, map[string]interface{}{ - "a": "a \t b", - }) - - tree, err = Load("a = \"a \\r b\"") - assertTree(t, tree, err, map[string]interface{}{ - "a": "a \r b", - }) - - tree, err = Load("a = \"a \\\\ b\"") - assertTree(t, tree, err, map[string]interface{}{ - "a": "a \\ b", - }) -} - -func TestEmptyQuotedString(t *testing.T) { - tree, err := Load(`[""] -"" = 1`) - assertTree(t, tree, err, map[string]interface{}{ - "": map[string]interface{}{ - "": int64(1), - }, - }) -} - -func TestBools(t *testing.T) { - tree, err := Load("a = true\nb = false") - assertTree(t, tree, err, map[string]interface{}{ - "a": true, - "b": false, - }) -} - -func TestNestedKeys(t *testing.T) { - tree, err := Load("[a.b.c]\nd = 42") - assertTree(t, tree, err, map[string]interface{}{ - "a": map[string]interface{}{ - "b": map[string]interface{}{ - "c": map[string]interface{}{ - "d": int64(42), - }, - }, - }, - }) -} - -func TestNestedQuotedUnicodeKeys(t *testing.T) { - tree, err := Load("[ j . \"ʞ\" . l ]\nd = 42") - assertTree(t, tree, err, map[string]interface{}{ - "j": map[string]interface{}{ - "ʞ": map[string]interface{}{ - "l": map[string]interface{}{ - "d": int64(42), - }, - }, - }, - }) - - tree, err = Load("[ g . h . i ]\nd = 42") - assertTree(t, tree, err, map[string]interface{}{ - "g": map[string]interface{}{ - "h": map[string]interface{}{ - "i": map[string]interface{}{ - "d": int64(42), - }, - }, - }, - }) - - tree, err = Load("[ d.e.f ]\nk = 42") - assertTree(t, tree, err, map[string]interface{}{ - "d": map[string]interface{}{ - "e": map[string]interface{}{ - "f": map[string]interface{}{ - "k": int64(42), - }, - }, - }, - }) -} - -func TestArrayOne(t *testing.T) { - tree, err := Load("a = [1]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(1)}, - }) -} - -func TestArrayZero(t *testing.T) { - tree, err := Load("a = []") - assertTree(t, tree, err, map[string]interface{}{ - "a": []interface{}{}, - }) -} - -func TestArraySimple(t *testing.T) { - tree, err := Load("a = [42, 21, 10]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(42), int64(21), int64(10)}, - }) - - tree, _ = Load("a = [42, 21, 10,]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(42), int64(21), int64(10)}, - }) -} - -func TestArrayMultiline(t *testing.T) { - tree, err := Load("a = [42,\n21, 10,]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(42), int64(21), int64(10)}, - }) -} - -func TestArrayNested(t *testing.T) { - tree, err := Load("a = [[42, 21], [10]]") - assertTree(t, tree, err, map[string]interface{}{ - "a": [][]int64{{int64(42), int64(21)}, {int64(10)}}, - }) -} - -func TestNestedArrayComment(t *testing.T) { - tree, err := Load(` -someArray = [ -# does not work -["entry1"] -]`) - assertTree(t, tree, err, map[string]interface{}{ - "someArray": [][]string{{"entry1"}}, - }) -} - -func TestNestedEmptyArrays(t *testing.T) { - tree, err := Load("a = [[[]]]") - assertTree(t, tree, err, map[string]interface{}{ - "a": [][][]interface{}{{{}}}, - }) -} - -func TestArrayMixedTypes(t *testing.T) { - _, err := Load("a = [42, 16.0]") - if err.Error() != "(1, 10): mixed types in array" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a = [42, \"hello\"]") - if err.Error() != "(1, 11): mixed types in array" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestArrayNestedStrings(t *testing.T) { - tree, err := Load("data = [ [\"gamma\", \"delta\"], [\"Foo\"] ]") - assertTree(t, tree, err, map[string]interface{}{ - "data": [][]string{{"gamma", "delta"}, {"Foo"}}, - }) -} - -func TestParseUnknownRvalue(t *testing.T) { - _, err := Load("a = !bssss") - if err == nil { - t.Error("Expecting a parse error") - } - - _, err = Load("a = /b") - if err == nil { - t.Error("Expecting a parse error") - } -} - -func TestMissingValue(t *testing.T) { - _, err := Load("a = ") - if err.Error() != "(1, 5): expecting a value" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestUnterminatedArray(t *testing.T) { - _, err := Load("a = [1,") - if err.Error() != "(1, 8): unterminated array" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a = [1") - if err.Error() != "(1, 7): unterminated array" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a = [1 2") - if err.Error() != "(1, 8): missing comma" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestNewlinesInArrays(t *testing.T) { - tree, err := Load("a = [1,\n2,\n3]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(1), int64(2), int64(3)}, - }) -} - -func TestArrayWithExtraComma(t *testing.T) { - tree, err := Load("a = [1,\n2,\n3,\n]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(1), int64(2), int64(3)}, - }) -} - -func TestArrayWithExtraCommaComment(t *testing.T) { - tree, err := Load("a = [1, # wow\n2, # such items\n3, # so array\n]") - assertTree(t, tree, err, map[string]interface{}{ - "a": []int64{int64(1), int64(2), int64(3)}, - }) -} - -func TestSimpleInlineGroup(t *testing.T) { - tree, err := Load("key = {a = 42}") - assertTree(t, tree, err, map[string]interface{}{ - "key": map[string]interface{}{ - "a": int64(42), - }, - }) -} - -func TestDoubleInlineGroup(t *testing.T) { - tree, err := Load("key = {a = 42, b = \"foo\"}") - assertTree(t, tree, err, map[string]interface{}{ - "key": map[string]interface{}{ - "a": int64(42), - "b": "foo", - }, - }) -} - -func TestExampleInlineGroup(t *testing.T) { - tree, err := Load(`name = { first = "Tom", last = "Preston-Werner" } -point = { x = 1, y = 2 }`) - assertTree(t, tree, err, map[string]interface{}{ - "name": map[string]interface{}{ - "first": "Tom", - "last": "Preston-Werner", - }, - "point": map[string]interface{}{ - "x": int64(1), - "y": int64(2), - }, - }) -} - -func TestExampleInlineGroupInArray(t *testing.T) { - tree, err := Load(`points = [{ x = 1, y = 2 }]`) - assertTree(t, tree, err, map[string]interface{}{ - "points": []map[string]interface{}{ - { - "x": int64(1), - "y": int64(2), - }, - }, - }) -} - -func TestInlineTableUnterminated(t *testing.T) { - _, err := Load("foo = {") - if err.Error() != "(1, 8): unterminated inline table" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestInlineTableCommaExpected(t *testing.T) { - _, err := Load("foo = {hello = 53 test = foo}") - if err.Error() != "(1, 19): comma expected between fields in inline table" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestInlineTableCommaStart(t *testing.T) { - _, err := Load("foo = {, hello = 53}") - if err.Error() != "(1, 8): inline table cannot start with a comma" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestInlineTableDoubleComma(t *testing.T) { - _, err := Load("foo = {hello = 53,, foo = 17}") - if err.Error() != "(1, 19): need field between two commas in inline table" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestDuplicateGroups(t *testing.T) { - _, err := Load("[foo]\na=2\n[foo]b=3") - if err.Error() != "(3, 2): duplicated tables" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestDuplicateKeys(t *testing.T) { - _, err := Load("foo = 2\nfoo = 3") - if err.Error() != "(2, 1): The following key was defined twice: foo" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestEmptyIntermediateTable(t *testing.T) { - _, err := Load("[foo..bar]") - if err.Error() != "(1, 2): invalid table array key: empty table key" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestImplicitDeclarationBefore(t *testing.T) { - tree, err := Load("[a.b.c]\nanswer = 42\n[a]\nbetter = 43") - assertTree(t, tree, err, map[string]interface{}{ - "a": map[string]interface{}{ - "b": map[string]interface{}{ - "c": map[string]interface{}{ - "answer": int64(42), - }, - }, - "better": int64(43), - }, - }) -} - -func TestFloatsWithoutLeadingZeros(t *testing.T) { - _, err := Load("a = .42") - if err.Error() != "(1, 5): cannot start float with a dot" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a = -.42") - if err.Error() != "(1, 5): cannot start float with a dot" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestMissingFile(t *testing.T) { - _, err := LoadFile("foo.toml") - if err.Error() != "open foo.toml: no such file or directory" && - err.Error() != "open foo.toml: The system cannot find the file specified." { - t.Error("Bad error message:", err.Error()) - } -} - -func TestParseFile(t *testing.T) { - tree, err := LoadFile("example.toml") - - assertTree(t, tree, err, map[string]interface{}{ - "title": "TOML Example", - "owner": map[string]interface{}{ - "name": "Tom Preston-Werner", - "organization": "GitHub", - "bio": "GitHub Cofounder & CEO\nLikes tater tots and beer.", - "dob": time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), - }, - "database": map[string]interface{}{ - "server": "192.168.1.1", - "ports": []int64{8001, 8001, 8002}, - "connection_max": 5000, - "enabled": true, - }, - "servers": map[string]interface{}{ - "alpha": map[string]interface{}{ - "ip": "10.0.0.1", - "dc": "eqdc10", - }, - "beta": map[string]interface{}{ - "ip": "10.0.0.2", - "dc": "eqdc10", - }, - }, - "clients": map[string]interface{}{ - "data": []interface{}{ - []string{"gamma", "delta"}, - []int64{1, 2}, - }, - }, - }) -} - -func TestParseFileCRLF(t *testing.T) { - tree, err := LoadFile("example-crlf.toml") - - assertTree(t, tree, err, map[string]interface{}{ - "title": "TOML Example", - "owner": map[string]interface{}{ - "name": "Tom Preston-Werner", - "organization": "GitHub", - "bio": "GitHub Cofounder & CEO\nLikes tater tots and beer.", - "dob": time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), - }, - "database": map[string]interface{}{ - "server": "192.168.1.1", - "ports": []int64{8001, 8001, 8002}, - "connection_max": 5000, - "enabled": true, - }, - "servers": map[string]interface{}{ - "alpha": map[string]interface{}{ - "ip": "10.0.0.1", - "dc": "eqdc10", - }, - "beta": map[string]interface{}{ - "ip": "10.0.0.2", - "dc": "eqdc10", - }, - }, - "clients": map[string]interface{}{ - "data": []interface{}{ - []string{"gamma", "delta"}, - []int64{1, 2}, - }, - }, - }) -} - -func TestParseKeyGroupArray(t *testing.T) { - tree, err := Load("[[foo.bar]] a = 42\n[[foo.bar]] a = 69") - assertTree(t, tree, err, map[string]interface{}{ - "foo": map[string]interface{}{ - "bar": []map[string]interface{}{ - {"a": int64(42)}, - {"a": int64(69)}, - }, - }, - }) -} - -func TestParseKeyGroupArrayUnfinished(t *testing.T) { - _, err := Load("[[foo.bar]\na = 42") - if err.Error() != "(1, 10): was expecting token [[, but got unclosed table array key instead" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("[[foo.[bar]\na = 42") - if err.Error() != "(1, 3): unexpected token table array key cannot contain ']', was expecting a table array key" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestParseKeyGroupArrayQueryExample(t *testing.T) { - tree, err := Load(` - [[book]] - title = "The Stand" - author = "Stephen King" - [[book]] - title = "For Whom the Bell Tolls" - author = "Ernest Hemmingway" - [[book]] - title = "Neuromancer" - author = "William Gibson" - `) - - assertTree(t, tree, err, map[string]interface{}{ - "book": []map[string]interface{}{ - {"title": "The Stand", "author": "Stephen King"}, - {"title": "For Whom the Bell Tolls", "author": "Ernest Hemmingway"}, - {"title": "Neuromancer", "author": "William Gibson"}, - }, - }) -} - -func TestParseKeyGroupArraySpec(t *testing.T) { - tree, err := Load("[[fruit]]\n name=\"apple\"\n [fruit.physical]\n color=\"red\"\n shape=\"round\"\n [[fruit]]\n name=\"banana\"") - assertTree(t, tree, err, map[string]interface{}{ - "fruit": []map[string]interface{}{ - {"name": "apple", "physical": map[string]interface{}{"color": "red", "shape": "round"}}, - {"name": "banana"}, - }, - }) -} - -func TestTomlValueStringRepresentation(t *testing.T) { - for idx, item := range []struct { - Value interface{} - Expect string - }{ - {int64(12345), "12345"}, - {uint64(50), "50"}, - {float64(123.45), "123.45"}, - {bool(true), "true"}, - {"hello world", "\"hello world\""}, - {"\b\t\n\f\r\"\\", "\"\\b\\t\\n\\f\\r\\\"\\\\\""}, - {"\x05", "\"\\u0005\""}, - {time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), - "1979-05-27T07:32:00Z"}, - {[]interface{}{"gamma", "delta"}, - "[\"gamma\",\"delta\"]"}, - {nil, ""}, - } { - result, err := tomlValueStringRepresentation(item.Value) - if err != nil { - t.Errorf("Test %d - unexpected error: %s", idx, err) - } - if result != item.Expect { - t.Errorf("Test %d - got '%s', expected '%s'", idx, result, item.Expect) - } - } -} - -func TestToStringMapStringString(t *testing.T) { - tree, err := TreeFromMap(map[string]interface{}{"m": map[string]interface{}{"v": "abc"}}) - if err != nil { - t.Fatalf("unexpected error: %s", err) - } - want := "\n[m]\n v = \"abc\"\n" - got := tree.String() - - if got != want { - t.Errorf("want:\n%q\ngot:\n%q", want, got) - } -} - -func assertPosition(t *testing.T, text string, ref map[string]Position) { - tree, err := Load(text) - if err != nil { - t.Errorf("Error loading document text: `%v`", text) - t.Errorf("Error: %v", err) - } - for path, pos := range ref { - testPos := tree.GetPosition(path) - if testPos.Invalid() { - t.Errorf("Failed to query tree path or path has invalid position: %s", path) - } else if pos != testPos { - t.Errorf("Expected position %v, got %v instead", pos, testPos) - } - } -} - -func TestDocumentPositions(t *testing.T) { - assertPosition(t, - "[foo]\nbar=42\nbaz=69", - map[string]Position{ - "": {1, 1}, - "foo": {1, 1}, - "foo.bar": {2, 1}, - "foo.baz": {3, 1}, - }) -} - -func TestDocumentPositionsWithSpaces(t *testing.T) { - assertPosition(t, - " [foo]\n bar=42\n baz=69", - map[string]Position{ - "": {1, 1}, - "foo": {1, 3}, - "foo.bar": {2, 3}, - "foo.baz": {3, 3}, - }) -} - -func TestDocumentPositionsWithGroupArray(t *testing.T) { - assertPosition(t, - "[[foo]]\nbar=42\nbaz=69", - map[string]Position{ - "": {1, 1}, - "foo": {1, 1}, - "foo.bar": {2, 1}, - "foo.baz": {3, 1}, - }) -} - -func TestNestedTreePosition(t *testing.T) { - assertPosition(t, - "[foo.bar]\na=42\nb=69", - map[string]Position{ - "": {1, 1}, - "foo": {1, 1}, - "foo.bar": {1, 1}, - "foo.bar.a": {2, 1}, - "foo.bar.b": {3, 1}, - }) -} - -func TestInvalidGroupArray(t *testing.T) { - _, err := Load("[table#key]\nanswer = 42") - if err == nil { - t.Error("Should error") - } - - _, err = Load("[foo.[bar]\na = 42") - if err.Error() != "(1, 2): unexpected token table key cannot contain ']', was expecting a table key" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestDoubleEqual(t *testing.T) { - _, err := Load("foo= = 2") - if err.Error() != "(1, 6): cannot have multiple equals for the same key" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestGroupArrayReassign(t *testing.T) { - _, err := Load("[hello]\n[[hello]]") - if err.Error() != "(2, 3): key \"hello\" is already assigned and not of type table array" { - t.Error("Bad error message:", err.Error()) - } -} - -func TestInvalidFloatParsing(t *testing.T) { - _, err := Load("a=1e_2") - if err.Error() != "(1, 3): invalid use of _ in number" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a=1e2_") - if err.Error() != "(1, 3): invalid use of _ in number" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a=1__2") - if err.Error() != "(1, 3): invalid use of _ in number" { - t.Error("Bad error message:", err.Error()) - } - - _, err = Load("a=_1_2") - if err.Error() != "(1, 3): cannot start number with underscore" { - t.Error("Bad error message:", err.Error()) - } -} diff --git a/vendor/github.com/pelletier/go-toml/position_test.go b/vendor/github.com/pelletier/go-toml/position_test.go deleted file mode 100644 index 63ad1afc86..0000000000 --- a/vendor/github.com/pelletier/go-toml/position_test.go +++ /dev/null @@ -1,29 +0,0 @@ -// Testing support for go-toml - -package toml - -import ( - "testing" -) - -func TestPositionString(t *testing.T) { - p := Position{123, 456} - expected := "(123, 456)" - value := p.String() - - if value != expected { - t.Errorf("Expected %v, got %v instead", expected, value) - } -} - -func TestInvalid(t *testing.T) { - for i, v := range []Position{ - {0, 1234}, - {1234, 0}, - {0, 0}, - } { - if !v.Invalid() { - t.Errorf("Position at %v is valid: %v", i, v) - } - } -} diff --git a/vendor/github.com/pelletier/go-toml/query_test.go b/vendor/github.com/pelletier/go-toml/query_test.go deleted file mode 100644 index 0d9f3832b9..0000000000 --- a/vendor/github.com/pelletier/go-toml/query_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package toml - -import ( - "testing" -) - -func assertArrayContainsInAnyOrder(t *testing.T, array []interface{}, objects ...interface{}) { - if len(array) != len(objects) { - t.Fatalf("array contains %d objects but %d are expected", len(array), len(objects)) - } - - for _, o := range objects { - found := false - for _, a := range array { - if a == o { - found = true - break - } - } - if !found { - t.Fatal(o, "not found in array", array) - } - } -} - -func TestQueryExample(t *testing.T) { - config, _ := Load(` - [[book]] - title = "The Stand" - author = "Stephen King" - [[book]] - title = "For Whom the Bell Tolls" - author = "Ernest Hemmingway" - [[book]] - title = "Neuromancer" - author = "William Gibson" - `) - - authors, _ := config.Query("$.book.author") - names := authors.Values() - if len(names) != 3 { - t.Fatalf("query should return 3 names but returned %d", len(names)) - } - assertArrayContainsInAnyOrder(t, names, "Stephen King", "Ernest Hemmingway", "William Gibson") -} - -func TestQueryReadmeExample(t *testing.T) { - config, _ := Load(` -[postgres] -user = "pelletier" -password = "mypassword" -`) - results, _ := config.Query("$..[user,password]") - values := results.Values() - if len(values) != 2 { - t.Fatalf("query should return 2 values but returned %d", len(values)) - } - assertArrayContainsInAnyOrder(t, values, "pelletier", "mypassword") -} - -func TestQueryPathNotPresent(t *testing.T) { - config, _ := Load(`a = "hello"`) - results, err := config.Query("$.foo.bar") - if err != nil { - t.Fatalf("err should be nil. got %s instead", err) - } - if len(results.items) != 0 { - t.Fatalf("no items should be matched. %d matched instead", len(results.items)) - } -} diff --git a/vendor/github.com/pelletier/go-toml/querylexer_test.go b/vendor/github.com/pelletier/go-toml/querylexer_test.go deleted file mode 100644 index 2d0803ff70..0000000000 --- a/vendor/github.com/pelletier/go-toml/querylexer_test.go +++ /dev/null @@ -1,178 +0,0 @@ -package toml - -import ( - "testing" -) - -func testQLFlow(t *testing.T, input string, expectedFlow []token) { - ch := lexQuery(input) - for idx, expected := range expectedFlow { - token := <-ch - if token != expected { - t.Log("While testing #", idx, ":", input) - t.Log("compared (got)", token, "to (expected)", expected) - t.Log("\tvalue:", token.val, "<->", expected.val) - t.Log("\tvalue as bytes:", []byte(token.val), "<->", []byte(expected.val)) - t.Log("\ttype:", token.typ.String(), "<->", expected.typ.String()) - t.Log("\tline:", token.Line, "<->", expected.Line) - t.Log("\tcolumn:", token.Col, "<->", expected.Col) - t.Log("compared", token, "to", expected) - t.FailNow() - } - } - - tok, ok := <-ch - if ok { - t.Log("channel is not closed!") - t.Log(len(ch)+1, "tokens remaining:") - - t.Log("token ->", tok) - for token := range ch { - t.Log("token ->", token) - } - t.FailNow() - } -} - -func TestLexSpecialChars(t *testing.T) { - testQLFlow(t, " .$[]..()?*", []token{ - {Position{1, 2}, tokenDot, "."}, - {Position{1, 3}, tokenDollar, "$"}, - {Position{1, 4}, tokenLeftBracket, "["}, - {Position{1, 5}, tokenRightBracket, "]"}, - {Position{1, 6}, tokenDotDot, ".."}, - {Position{1, 8}, tokenLeftParen, "("}, - {Position{1, 9}, tokenRightParen, ")"}, - {Position{1, 10}, tokenQuestion, "?"}, - {Position{1, 11}, tokenStar, "*"}, - {Position{1, 12}, tokenEOF, ""}, - }) -} - -func TestLexString(t *testing.T) { - testQLFlow(t, "'foo\n'", []token{ - {Position{1, 2}, tokenString, "foo\n"}, - {Position{2, 2}, tokenEOF, ""}, - }) -} - -func TestLexDoubleString(t *testing.T) { - testQLFlow(t, `"bar"`, []token{ - {Position{1, 2}, tokenString, "bar"}, - {Position{1, 6}, tokenEOF, ""}, - }) -} - -func TestLexStringEscapes(t *testing.T) { - testQLFlow(t, `"foo \" \' \b \f \/ \t \r \\ \u03A9 \U00012345 \n bar"`, []token{ - {Position{1, 2}, tokenString, "foo \" ' \b \f / \t \r \\ \u03A9 \U00012345 \n bar"}, - {Position{1, 55}, tokenEOF, ""}, - }) -} - -func TestLexStringUnfinishedUnicode4(t *testing.T) { - testQLFlow(t, `"\u000"`, []token{ - {Position{1, 2}, tokenError, "unfinished unicode escape"}, - }) -} - -func TestLexStringUnfinishedUnicode8(t *testing.T) { - testQLFlow(t, `"\U0000"`, []token{ - {Position{1, 2}, tokenError, "unfinished unicode escape"}, - }) -} - -func TestLexStringInvalidEscape(t *testing.T) { - testQLFlow(t, `"\x"`, []token{ - {Position{1, 2}, tokenError, "invalid escape sequence: \\x"}, - }) -} - -func TestLexStringUnfinished(t *testing.T) { - testQLFlow(t, `"bar`, []token{ - {Position{1, 2}, tokenError, "unclosed string"}, - }) -} - -func TestLexKey(t *testing.T) { - testQLFlow(t, "foo", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 4}, tokenEOF, ""}, - }) -} - -func TestLexRecurse(t *testing.T) { - testQLFlow(t, "$..*", []token{ - {Position{1, 1}, tokenDollar, "$"}, - {Position{1, 2}, tokenDotDot, ".."}, - {Position{1, 4}, tokenStar, "*"}, - {Position{1, 5}, tokenEOF, ""}, - }) -} - -func TestLexBracketKey(t *testing.T) { - testQLFlow(t, "$[foo]", []token{ - {Position{1, 1}, tokenDollar, "$"}, - {Position{1, 2}, tokenLeftBracket, "["}, - {Position{1, 3}, tokenKey, "foo"}, - {Position{1, 6}, tokenRightBracket, "]"}, - {Position{1, 7}, tokenEOF, ""}, - }) -} - -func TestLexSpace(t *testing.T) { - testQLFlow(t, "foo bar baz", []token{ - {Position{1, 1}, tokenKey, "foo"}, - {Position{1, 5}, tokenKey, "bar"}, - {Position{1, 9}, tokenKey, "baz"}, - {Position{1, 12}, tokenEOF, ""}, - }) -} - -func TestLexInteger(t *testing.T) { - testQLFlow(t, "100 +200 -300", []token{ - {Position{1, 1}, tokenInteger, "100"}, - {Position{1, 5}, tokenInteger, "+200"}, - {Position{1, 10}, tokenInteger, "-300"}, - {Position{1, 14}, tokenEOF, ""}, - }) -} - -func TestLexFloat(t *testing.T) { - testQLFlow(t, "100.0 +200.0 -300.0", []token{ - {Position{1, 1}, tokenFloat, "100.0"}, - {Position{1, 7}, tokenFloat, "+200.0"}, - {Position{1, 14}, tokenFloat, "-300.0"}, - {Position{1, 20}, tokenEOF, ""}, - }) -} - -func TestLexFloatWithMultipleDots(t *testing.T) { - testQLFlow(t, "4.2.", []token{ - {Position{1, 1}, tokenError, "cannot have two dots in one float"}, - }) -} - -func TestLexFloatLeadingDot(t *testing.T) { - testQLFlow(t, "+.1", []token{ - {Position{1, 1}, tokenError, "cannot start float with a dot"}, - }) -} - -func TestLexFloatWithTrailingDot(t *testing.T) { - testQLFlow(t, "42.", []token{ - {Position{1, 1}, tokenError, "float cannot end with a dot"}, - }) -} - -func TestLexNumberWithoutDigit(t *testing.T) { - testQLFlow(t, "+", []token{ - {Position{1, 1}, tokenError, "no digit in that number"}, - }) -} - -func TestLexUnknown(t *testing.T) { - testQLFlow(t, "^", []token{ - {Position{1, 1}, tokenError, "unexpected char: '94'"}, - }) -} diff --git a/vendor/github.com/pelletier/go-toml/queryparser_test.go b/vendor/github.com/pelletier/go-toml/queryparser_test.go deleted file mode 100644 index b2b85cefdc..0000000000 --- a/vendor/github.com/pelletier/go-toml/queryparser_test.go +++ /dev/null @@ -1,483 +0,0 @@ -package toml - -import ( - "fmt" - "io/ioutil" - "sort" - "strings" - "testing" - "time" -) - -type queryTestNode struct { - value interface{} - position Position -} - -func valueString(root interface{}) string { - result := "" //fmt.Sprintf("%T:", root) - switch node := root.(type) { - case *tomlValue: - return valueString(node.value) - case *QueryResult: - items := []string{} - for i, v := range node.Values() { - items = append(items, fmt.Sprintf("%s:%s", - node.Positions()[i].String(), valueString(v))) - } - sort.Strings(items) - result = "[" + strings.Join(items, ", ") + "]" - case queryTestNode: - result = fmt.Sprintf("%s:%s", - node.position.String(), valueString(node.value)) - case []interface{}: - items := []string{} - for _, v := range node { - items = append(items, valueString(v)) - } - sort.Strings(items) - result = "[" + strings.Join(items, ", ") + "]" - case *TomlTree: - // workaround for unreliable map key ordering - items := []string{} - for _, k := range node.Keys() { - v := node.GetPath([]string{k}) - items = append(items, k+":"+valueString(v)) - } - sort.Strings(items) - result = "{" + strings.Join(items, ", ") + "}" - case map[string]interface{}: - // workaround for unreliable map key ordering - items := []string{} - for k, v := range node { - items = append(items, k+":"+valueString(v)) - } - sort.Strings(items) - result = "{" + strings.Join(items, ", ") + "}" - case int64: - result += fmt.Sprintf("%d", node) - case string: - result += "'" + node + "'" - case float64: - result += fmt.Sprintf("%f", node) - case bool: - result += fmt.Sprintf("%t", node) - case time.Time: - result += fmt.Sprintf("'%v'", node) - } - return result -} - -func assertValue(t *testing.T, result, ref interface{}) { - pathStr := valueString(result) - refStr := valueString(ref) - if pathStr != refStr { - t.Errorf("values do not match") - t.Log("test:", pathStr) - t.Log("ref: ", refStr) - } -} - -func assertQueryPositions(t *testing.T, toml, query string, ref []interface{}) { - tree, err := Load(toml) - if err != nil { - t.Errorf("Non-nil toml parse error: %v", err) - return - } - q, err := CompileQuery(query) - if err != nil { - t.Error(err) - return - } - results := q.Execute(tree) - assertValue(t, results, ref) -} - -func TestQueryRoot(t *testing.T) { - assertQueryPositions(t, - "a = 42", - "$", - []interface{}{ - queryTestNode{ - map[string]interface{}{ - "a": int64(42), - }, Position{1, 1}, - }, - }) -} - -func TestQueryKey(t *testing.T) { - assertQueryPositions(t, - "[foo]\na = 42", - "$.foo.a", - []interface{}{ - queryTestNode{ - int64(42), Position{2, 1}, - }, - }) -} - -func TestQueryKeyString(t *testing.T) { - assertQueryPositions(t, - "[foo]\na = 42", - "$.foo['a']", - []interface{}{ - queryTestNode{ - int64(42), Position{2, 1}, - }, - }) -} - -func TestQueryIndex(t *testing.T) { - assertQueryPositions(t, - "[foo]\na = [1,2,3,4,5,6,7,8,9,0]", - "$.foo.a[5]", - []interface{}{ - queryTestNode{ - int64(6), Position{2, 1}, - }, - }) -} - -func TestQuerySliceRange(t *testing.T) { - assertQueryPositions(t, - "[foo]\na = [1,2,3,4,5,6,7,8,9,0]", - "$.foo.a[0:5]", - []interface{}{ - queryTestNode{ - int64(1), Position{2, 1}, - }, - queryTestNode{ - int64(2), Position{2, 1}, - }, - queryTestNode{ - int64(3), Position{2, 1}, - }, - queryTestNode{ - int64(4), Position{2, 1}, - }, - queryTestNode{ - int64(5), Position{2, 1}, - }, - }) -} - -func TestQuerySliceStep(t *testing.T) { - assertQueryPositions(t, - "[foo]\na = [1,2,3,4,5,6,7,8,9,0]", - "$.foo.a[0:5:2]", - []interface{}{ - queryTestNode{ - int64(1), Position{2, 1}, - }, - queryTestNode{ - int64(3), Position{2, 1}, - }, - queryTestNode{ - int64(5), Position{2, 1}, - }, - }) -} - -func TestQueryAny(t *testing.T) { - assertQueryPositions(t, - "[foo.bar]\na=1\nb=2\n[foo.baz]\na=3\nb=4", - "$.foo.*", - []interface{}{ - queryTestNode{ - map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, Position{1, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(3), - "b": int64(4), - }, Position{4, 1}, - }, - }) -} -func TestQueryUnionSimple(t *testing.T) { - assertQueryPositions(t, - "[foo.bar]\na=1\nb=2\n[baz.foo]\na=3\nb=4\n[gorf.foo]\na=5\nb=6", - "$.*[bar,foo]", - []interface{}{ - queryTestNode{ - map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, Position{1, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(3), - "b": int64(4), - }, Position{4, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(5), - "b": int64(6), - }, Position{7, 1}, - }, - }) -} - -func TestQueryRecursionAll(t *testing.T) { - assertQueryPositions(t, - "[foo.bar]\na=1\nb=2\n[baz.foo]\na=3\nb=4\n[gorf.foo]\na=5\nb=6", - "$..*", - []interface{}{ - queryTestNode{ - map[string]interface{}{ - "foo": map[string]interface{}{ - "bar": map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, - }, - "baz": map[string]interface{}{ - "foo": map[string]interface{}{ - "a": int64(3), - "b": int64(4), - }, - }, - "gorf": map[string]interface{}{ - "foo": map[string]interface{}{ - "a": int64(5), - "b": int64(6), - }, - }, - }, Position{1, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "bar": map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, - }, Position{1, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, Position{1, 1}, - }, - queryTestNode{ - int64(1), Position{2, 1}, - }, - queryTestNode{ - int64(2), Position{3, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "foo": map[string]interface{}{ - "a": int64(3), - "b": int64(4), - }, - }, Position{4, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(3), - "b": int64(4), - }, Position{4, 1}, - }, - queryTestNode{ - int64(3), Position{5, 1}, - }, - queryTestNode{ - int64(4), Position{6, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "foo": map[string]interface{}{ - "a": int64(5), - "b": int64(6), - }, - }, Position{7, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(5), - "b": int64(6), - }, Position{7, 1}, - }, - queryTestNode{ - int64(5), Position{8, 1}, - }, - queryTestNode{ - int64(6), Position{9, 1}, - }, - }) -} - -func TestQueryRecursionUnionSimple(t *testing.T) { - assertQueryPositions(t, - "[foo.bar]\na=1\nb=2\n[baz.foo]\na=3\nb=4\n[gorf.foo]\na=5\nb=6", - "$..['foo','bar']", - []interface{}{ - queryTestNode{ - map[string]interface{}{ - "bar": map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, - }, Position{1, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(3), - "b": int64(4), - }, Position{4, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(1), - "b": int64(2), - }, Position{1, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "a": int64(5), - "b": int64(6), - }, Position{7, 1}, - }, - }) -} - -func TestQueryFilterFn(t *testing.T) { - buff, err := ioutil.ReadFile("example.toml") - if err != nil { - t.Error(err) - return - } - - assertQueryPositions(t, string(buff), - "$..[?(int)]", - []interface{}{ - queryTestNode{ - int64(8001), Position{13, 1}, - }, - queryTestNode{ - int64(8001), Position{13, 1}, - }, - queryTestNode{ - int64(8002), Position{13, 1}, - }, - queryTestNode{ - int64(5000), Position{14, 1}, - }, - }) - - assertQueryPositions(t, string(buff), - "$..[?(string)]", - []interface{}{ - queryTestNode{ - "TOML Example", Position{3, 1}, - }, - queryTestNode{ - "Tom Preston-Werner", Position{6, 1}, - }, - queryTestNode{ - "GitHub", Position{7, 1}, - }, - queryTestNode{ - "GitHub Cofounder & CEO\nLikes tater tots and beer.", - Position{8, 1}, - }, - queryTestNode{ - "192.168.1.1", Position{12, 1}, - }, - queryTestNode{ - "10.0.0.1", Position{21, 3}, - }, - queryTestNode{ - "eqdc10", Position{22, 3}, - }, - queryTestNode{ - "10.0.0.2", Position{25, 3}, - }, - queryTestNode{ - "eqdc10", Position{26, 3}, - }, - }) - - assertQueryPositions(t, string(buff), - "$..[?(float)]", - []interface{}{ - // no float values in document - }) - - tv, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z") - assertQueryPositions(t, string(buff), - "$..[?(tree)]", - []interface{}{ - queryTestNode{ - map[string]interface{}{ - "name": "Tom Preston-Werner", - "organization": "GitHub", - "bio": "GitHub Cofounder & CEO\nLikes tater tots and beer.", - "dob": tv, - }, Position{5, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "server": "192.168.1.1", - "ports": []interface{}{int64(8001), int64(8001), int64(8002)}, - "connection_max": int64(5000), - "enabled": true, - }, Position{11, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "alpha": map[string]interface{}{ - "ip": "10.0.0.1", - "dc": "eqdc10", - }, - "beta": map[string]interface{}{ - "ip": "10.0.0.2", - "dc": "eqdc10", - }, - }, Position{17, 1}, - }, - queryTestNode{ - map[string]interface{}{ - "ip": "10.0.0.1", - "dc": "eqdc10", - }, Position{20, 3}, - }, - queryTestNode{ - map[string]interface{}{ - "ip": "10.0.0.2", - "dc": "eqdc10", - }, Position{24, 3}, - }, - queryTestNode{ - map[string]interface{}{ - "data": []interface{}{ - []interface{}{"gamma", "delta"}, - []interface{}{int64(1), int64(2)}, - }, - }, Position{28, 1}, - }, - }) - - assertQueryPositions(t, string(buff), - "$..[?(time)]", - []interface{}{ - queryTestNode{ - tv, Position{9, 1}, - }, - }) - - assertQueryPositions(t, string(buff), - "$..[?(bool)]", - []interface{}{ - queryTestNode{ - true, Position{15, 1}, - }, - }) -} diff --git a/vendor/github.com/pelletier/go-toml/test.sh b/vendor/github.com/pelletier/go-toml/test.sh deleted file mode 100755 index 436d2fb6ca..0000000000 --- a/vendor/github.com/pelletier/go-toml/test.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash -# fail out of the script if anything here fails -set -e - -# set the path to the present working directory -export GOPATH=`pwd` - -function git_clone() { - path=$1 - branch=$2 - version=$3 - if [ ! -d "src/$path" ]; then - mkdir -p src/$path - git clone https://$path.git src/$path - fi - pushd src/$path - git checkout "$branch" - git reset --hard "$version" - popd -} - -# Run go vet -go vet ./... - -go get github.com/pelletier/go-buffruneio -go get github.com/davecgh/go-spew/spew - -# get code for BurntSushi TOML validation -# pinning all to 'HEAD' for version 0.3.x work (TODO: pin to commit hash when tests stabilize) -git_clone github.com/BurntSushi/toml master HEAD -git_clone github.com/BurntSushi/toml-test master HEAD #was: 0.2.0 HEAD - -# build the BurntSushi test application -go build -o toml-test github.com/BurntSushi/toml-test - -# vendorize the current lib for testing -# NOTE: this basically mocks an install without having to go back out to github for code -mkdir -p src/github.com/pelletier/go-toml/cmd -cp *.go *.toml src/github.com/pelletier/go-toml -cp -R cmd/* src/github.com/pelletier/go-toml/cmd -go build -o test_program_bin src/github.com/pelletier/go-toml/cmd/test_program.go - -# Run basic unit tests -go test github.com/pelletier/go-toml -v -covermode=count -coverprofile=coverage.out -go test github.com/pelletier/go-toml/cmd/tomljson - -# run the entire BurntSushi test suite -if [[ $# -eq 0 ]] ; then - echo "Running all BurntSushi tests" - ./toml-test ./test_program_bin | tee test_out -else - # run a specific test - test=$1 - test_path='src/github.com/BurntSushi/toml-test/tests' - valid_test="$test_path/valid/$test" - invalid_test="$test_path/invalid/$test" - - if [ -e "$valid_test.toml" ]; then - echo "Valid Test TOML for $test:" - echo "====" - cat "$valid_test.toml" - - echo "Valid Test JSON for $test:" - echo "====" - cat "$valid_test.json" - - echo "Go-TOML Output for $test:" - echo "====" - cat "$valid_test.toml" | ./test_program_bin - fi - - if [ -e "$invalid_test.toml" ]; then - echo "Invalid Test TOML for $test:" - echo "====" - cat "$invalid_test.toml" - - echo "Go-TOML Output for $test:" - echo "====" - echo "go-toml Output:" - cat "$invalid_test.toml" | ./test_program_bin - fi -fi diff --git a/vendor/github.com/pelletier/go-toml/token_test.go b/vendor/github.com/pelletier/go-toml/token_test.go deleted file mode 100644 index 20b560d510..0000000000 --- a/vendor/github.com/pelletier/go-toml/token_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package toml - -import "testing" - -func TestTokenStringer(t *testing.T) { - var tests = []struct { - tt tokenType - expect string - }{ - {tokenError, "Error"}, - {tokenEOF, "EOF"}, - {tokenComment, "Comment"}, - {tokenKey, "Key"}, - {tokenString, "String"}, - {tokenInteger, "Integer"}, - {tokenTrue, "True"}, - {tokenFalse, "False"}, - {tokenFloat, "Float"}, - {tokenEqual, "="}, - {tokenLeftBracket, "["}, - {tokenRightBracket, "]"}, - {tokenLeftCurlyBrace, "{"}, - {tokenRightCurlyBrace, "}"}, - {tokenLeftParen, "("}, - {tokenRightParen, ")"}, - {tokenDoubleLeftBracket, "]]"}, - {tokenDoubleRightBracket, "[["}, - {tokenDate, "Date"}, - {tokenKeyGroup, "KeyGroup"}, - {tokenKeyGroupArray, "KeyGroupArray"}, - {tokenComma, ","}, - {tokenColon, ":"}, - {tokenDollar, "$"}, - {tokenStar, "*"}, - {tokenQuestion, "?"}, - {tokenDot, "."}, - {tokenDotDot, ".."}, - {tokenEOL, "EOL"}, - {tokenEOL + 1, "Unknown"}, - } - - for i, test := range tests { - got := test.tt.String() - if got != test.expect { - t.Errorf("[%d] invalid string of token type; got %q, expected %q", i, got, test.expect) - } - } -} - -func TestTokenString(t *testing.T) { - var tests = []struct { - tok token - expect string - }{ - {token{Position{1, 1}, tokenEOF, ""}, "EOF"}, - {token{Position{1, 1}, tokenError, "Δt"}, "Δt"}, - {token{Position{1, 1}, tokenString, "bar"}, `"bar"`}, - {token{Position{1, 1}, tokenString, "123456789012345"}, `"123456789012345"`}, - } - - for i, test := range tests { - got := test.tok.String() - if got != test.expect { - t.Errorf("[%d] invalid of string token; got %q, expected %q", i, got, test.expect) - } - } -} diff --git a/vendor/github.com/pelletier/go-toml/toml_test.go b/vendor/github.com/pelletier/go-toml/toml_test.go deleted file mode 100644 index 7c7f9eff95..0000000000 --- a/vendor/github.com/pelletier/go-toml/toml_test.go +++ /dev/null @@ -1,131 +0,0 @@ -// Testing support for go-toml - -package toml - -import ( - "testing" -) - -func TestTomlHas(t *testing.T) { - tree, _ := Load(` - [test] - key = "value" - `) - - if !tree.Has("test.key") { - t.Errorf("Has - expected test.key to exists") - } - - if tree.Has("") { - t.Errorf("Should return false if the key is not provided") - } -} - -func TestTomlGet(t *testing.T) { - tree, _ := Load(` - [test] - key = "value" - `) - - if tree.Get("") != tree { - t.Errorf("Get should return the tree itself when given an empty path") - } - - if tree.Get("test.key") != "value" { - t.Errorf("Get should return the value") - } - if tree.Get(`\`) != nil { - t.Errorf("should return nil when the key is malformed") - } -} - -func TestTomlGetDefault(t *testing.T) { - tree, _ := Load(` - [test] - key = "value" - `) - - if tree.GetDefault("", "hello") != tree { - t.Error("GetDefault should return the tree itself when given an empty path") - } - - if tree.GetDefault("test.key", "hello") != "value" { - t.Error("Get should return the value") - } - - if tree.GetDefault("whatever", "hello") != "hello" { - t.Error("GetDefault should return the default value if the key does not exist") - } -} - -func TestTomlHasPath(t *testing.T) { - tree, _ := Load(` - [test] - key = "value" - `) - - if !tree.HasPath([]string{"test", "key"}) { - t.Errorf("HasPath - expected test.key to exists") - } -} - -func TestTomlGetPath(t *testing.T) { - node := newTomlTree() - //TODO: set other node data - - for idx, item := range []struct { - Path []string - Expected *TomlTree - }{ - { // empty path test - []string{}, - node, - }, - } { - result := node.GetPath(item.Path) - if result != item.Expected { - t.Errorf("GetPath[%d] %v - expected %v, got %v instead.", idx, item.Path, item.Expected, result) - } - } - - tree, _ := Load("[foo.bar]\na=1\nb=2\n[baz.foo]\na=3\nb=4\n[gorf.foo]\na=5\nb=6") - if tree.GetPath([]string{"whatever"}) != nil { - t.Error("GetPath should return nil when the key does not exist") - } -} - -func TestTomlQuery(t *testing.T) { - tree, err := Load("[foo.bar]\na=1\nb=2\n[baz.foo]\na=3\nb=4\n[gorf.foo]\na=5\nb=6") - if err != nil { - t.Error(err) - return - } - result, err := tree.Query("$.foo.bar") - if err != nil { - t.Error(err) - return - } - values := result.Values() - if len(values) != 1 { - t.Errorf("Expected resultset of 1, got %d instead: %v", len(values), values) - } - - if tt, ok := values[0].(*TomlTree); !ok { - t.Errorf("Expected type of TomlTree: %T", values[0]) - } else if tt.Get("a") != int64(1) { - t.Errorf("Expected 'a' with a value 1: %v", tt.Get("a")) - } else if tt.Get("b") != int64(2) { - t.Errorf("Expected 'b' with a value 2: %v", tt.Get("b")) - } -} - -func TestTomlFromMap(t *testing.T) { - simpleMap := map[string]interface{}{"hello": 42} - tree, err := TreeFromMap(simpleMap) - if err != nil { - t.Fatal("unexpected error:", err) - } - if tree.Get("hello") != int64(42) { - t.Fatal("hello should be 42, not", tree.Get("hello")) - } -} diff --git a/vendor/github.com/pelletier/go-toml/tomltree_create_test.go b/vendor/github.com/pelletier/go-toml/tomltree_create_test.go deleted file mode 100644 index 6c1496835e..0000000000 --- a/vendor/github.com/pelletier/go-toml/tomltree_create_test.go +++ /dev/null @@ -1,126 +0,0 @@ -package toml - -import ( - "testing" - "time" - "strconv" -) - -type customString string - -type stringer struct{} - -func (s stringer) String() string { - return "stringer" -} - -func validate(t *testing.T, path string, object interface{}) { - switch o := object.(type) { - case *TomlTree: - for key, tree := range o.values { - validate(t, path+"."+key, tree) - } - case []*TomlTree: - for index, tree := range o { - validate(t, path+"."+strconv.Itoa(index), tree) - } - case *tomlValue: - switch o.value.(type) { - case int64, uint64, bool, string, float64, time.Time, - []int64, []uint64, []bool, []string, []float64, []time.Time: - default: - t.Fatalf("tomlValue at key %s containing incorrect type %T", path, o.value) - } - default: - t.Fatalf("value at key %s is of incorrect type %T", path, object) - } - t.Logf("validation ok %s as %T", path, object) -} - -func validateTree(t *testing.T, tree *TomlTree) { - validate(t, "", tree) -} - -func TestTomlTreeCreateToTree(t *testing.T) { - data := map[string]interface{}{ - "a_string": "bar", - "an_int": 42, - "time": time.Now(), - "int8": int8(2), - "int16": int16(2), - "int32": int32(2), - "uint8": uint8(2), - "uint16": uint16(2), - "uint32": uint32(2), - "float32": float32(2), - "a_bool": false, - "stringer": stringer{}, - "nested": map[string]interface{}{ - "foo": "bar", - }, - "array": []string{"a", "b", "c"}, - "array_uint": []uint{uint(1), uint(2)}, - "array_table": []map[string]interface{}{map[string]interface{}{"sub_map": 52}}, - "array_times": []time.Time{time.Now(), time.Now()}, - "map_times": map[string]time.Time{"now": time.Now()}, - "custom_string_map_key": map[customString]interface{}{customString("custom"): "custom"}, - } - tree, err := TreeFromMap(data) - if err != nil { - t.Fatal("unexpected error:", err) - } - validateTree(t, tree) -} - -func TestTomlTreeCreateToTreeInvalidLeafType(t *testing.T) { - _, err := TreeFromMap(map[string]interface{}{"foo": t}) - expected := "cannot convert type *testing.T to TomlTree" - if err.Error() != expected { - t.Fatalf("expected error %s, got %s", expected, err.Error()) - } -} - -func TestTomlTreeCreateToTreeInvalidMapKeyType(t *testing.T) { - _, err := TreeFromMap(map[string]interface{}{"foo": map[int]interface{}{2: 1}}) - expected := "map key needs to be a string, not int (int)" - if err.Error() != expected { - t.Fatalf("expected error %s, got %s", expected, err.Error()) - } -} - -func TestTomlTreeCreateToTreeInvalidArrayMemberType(t *testing.T) { - _, err := TreeFromMap(map[string]interface{}{"foo": []*testing.T{t}}) - expected := "cannot convert type *testing.T to TomlTree" - if err.Error() != expected { - t.Fatalf("expected error %s, got %s", expected, err.Error()) - } -} - -func TestTomlTreeCreateToTreeInvalidTableGroupType(t *testing.T) { - _, err := TreeFromMap(map[string]interface{}{"foo": []map[string]interface{}{map[string]interface{}{"hello": t}}}) - expected := "cannot convert type *testing.T to TomlTree" - if err.Error() != expected { - t.Fatalf("expected error %s, got %s", expected, err.Error()) - } -} - -func TestRoundTripArrayOfTables(t *testing.T) { - orig := "\n[[stuff]]\n name = \"foo\"\n things = [\"a\",\"b\"]\n" - tree, err := Load(orig) - if err != nil { - t.Fatalf("unexpected error: %s", err) - } - - m := tree.ToMap() - - tree, err = TreeFromMap(m) - if err != nil { - t.Fatalf("unexpected error: %s", err) - } - want := orig - got := tree.String() - - if got != want { - t.Errorf("want:\n%s\ngot:\n%s", want, got) - } -} diff --git a/vendor/github.com/pelletier/go-toml/tomltree_write_test.go b/vendor/github.com/pelletier/go-toml/tomltree_write_test.go deleted file mode 100644 index b5ad8db7c0..0000000000 --- a/vendor/github.com/pelletier/go-toml/tomltree_write_test.go +++ /dev/null @@ -1,271 +0,0 @@ -package toml - -import ( - "bytes" - "errors" - "fmt" - "reflect" - "strings" - "testing" - "time" -) - -type failingWriter struct { - failAt int - written int - buffer bytes.Buffer -} - -func (f failingWriter) Write(p []byte) (n int, err error) { - count := len(p) - toWrite := f.failAt - count + f.written - if toWrite < 0 { - toWrite = 0 - } - if toWrite > count { - f.written += count - f.buffer.WriteString(string(p)) - return count, nil - } - - f.buffer.WriteString(string(p[:toWrite])) - f.written = f.failAt - return f.written, fmt.Errorf("failingWriter failed after writting %d bytes", f.written) -} - -func assertErrorString(t *testing.T, expected string, err error) { - expectedErr := errors.New(expected) - if err.Error() != expectedErr.Error() { - t.Errorf("expecting error %s, but got %s instead", expected, err) - } -} - -func TestTomlTreeWriteToTomlString(t *testing.T) { - toml, err := Load(`name = { first = "Tom", last = "Preston-Werner" } -points = { x = 1, y = 2 }`) - - if err != nil { - t.Fatal("Unexpected error:", err) - } - - tomlString, _ := toml.ToTomlString() - reparsedTree, err := Load(tomlString) - - assertTree(t, reparsedTree, err, map[string]interface{}{ - "name": map[string]interface{}{ - "first": "Tom", - "last": "Preston-Werner", - }, - "points": map[string]interface{}{ - "x": int64(1), - "y": int64(2), - }, - }) -} - -func TestTomlTreeWriteToTomlStringSimple(t *testing.T) { - tree, err := Load("[foo]\n\n[[foo.bar]]\na = 42\n\n[[foo.bar]]\na = 69\n") - if err != nil { - t.Errorf("Test failed to parse: %v", err) - return - } - result, err := tree.ToTomlString() - if err != nil { - t.Errorf("Unexpected error: %s", err) - } - expected := "\n[foo]\n\n [[foo.bar]]\n a = 42\n\n [[foo.bar]]\n a = 69\n" - if result != expected { - t.Errorf("Expected got '%s', expected '%s'", result, expected) - } -} - -func TestTomlTreeWriteToTomlStringKeysOrders(t *testing.T) { - for i := 0; i < 100; i++ { - tree, _ := Load(` - foobar = true - bar = "baz" - foo = 1 - [qux] - foo = 1 - bar = "baz2"`) - - stringRepr, _ := tree.ToTomlString() - - t.Log("Intermediate string representation:") - t.Log(stringRepr) - - r := strings.NewReader(stringRepr) - toml, err := LoadReader(r) - - if err != nil { - t.Fatal("Unexpected error:", err) - } - - assertTree(t, toml, err, map[string]interface{}{ - "foobar": true, - "bar": "baz", - "foo": 1, - "qux": map[string]interface{}{ - "foo": 1, - "bar": "baz2", - }, - }) - } -} - -func testMaps(t *testing.T, actual, expected map[string]interface{}) { - if !reflect.DeepEqual(actual, expected) { - t.Fatal("trees aren't equal.\n", "Expected:\n", expected, "\nActual:\n", actual) - } -} - -func TestTomlTreeWriteToMapSimple(t *testing.T) { - tree, _ := Load("a = 42\nb = 17") - - expected := map[string]interface{}{ - "a": int64(42), - "b": int64(17), - } - - testMaps(t, tree.ToMap(), expected) -} - -func TestTomlTreeWriteToInvalidTreeSimpleValue(t *testing.T) { - tree := TomlTree{values: map[string]interface{}{"foo": int8(1)}} - _, err := tree.ToTomlString() - assertErrorString(t, "invalid value type at foo: int8", err) -} - -func TestTomlTreeWriteToInvalidTreeTomlValue(t *testing.T) { - tree := TomlTree{values: map[string]interface{}{"foo": &tomlValue{int8(1), Position{}}}} - _, err := tree.ToTomlString() - assertErrorString(t, "unsupported value type int8: 1", err) -} - -func TestTomlTreeWriteToInvalidTreeTomlValueArray(t *testing.T) { - tree := TomlTree{values: map[string]interface{}{"foo": &tomlValue{[]interface{}{int8(1)}, Position{}}}} - _, err := tree.ToTomlString() - assertErrorString(t, "unsupported value type int8: 1", err) -} - -func TestTomlTreeWriteToFailingWriterInSimpleValue(t *testing.T) { - toml, _ := Load(`a = 2`) - writer := failingWriter{failAt: 0, written: 0} - _, err := toml.WriteTo(writer) - assertErrorString(t, "failingWriter failed after writting 0 bytes", err) -} - -func TestTomlTreeWriteToFailingWriterInTable(t *testing.T) { - toml, _ := Load(` -[b] -a = 2`) - writer := failingWriter{failAt: 2, written: 0} - _, err := toml.WriteTo(writer) - assertErrorString(t, "failingWriter failed after writting 2 bytes", err) - - writer = failingWriter{failAt: 13, written: 0} - _, err = toml.WriteTo(writer) - assertErrorString(t, "failingWriter failed after writting 13 bytes", err) -} - -func TestTomlTreeWriteToFailingWriterInArray(t *testing.T) { - toml, _ := Load(` -[[b]] -a = 2`) - writer := failingWriter{failAt: 2, written: 0} - _, err := toml.WriteTo(writer) - assertErrorString(t, "failingWriter failed after writting 2 bytes", err) - - writer = failingWriter{failAt: 15, written: 0} - _, err = toml.WriteTo(writer) - assertErrorString(t, "failingWriter failed after writting 15 bytes", err) -} - -func TestTomlTreeWriteToMapExampleFile(t *testing.T) { - tree, _ := LoadFile("example.toml") - expected := map[string]interface{}{ - "title": "TOML Example", - "owner": map[string]interface{}{ - "name": "Tom Preston-Werner", - "organization": "GitHub", - "bio": "GitHub Cofounder & CEO\nLikes tater tots and beer.", - "dob": time.Date(1979, time.May, 27, 7, 32, 0, 0, time.UTC), - }, - "database": map[string]interface{}{ - "server": "192.168.1.1", - "ports": []interface{}{int64(8001), int64(8001), int64(8002)}, - "connection_max": int64(5000), - "enabled": true, - }, - "servers": map[string]interface{}{ - "alpha": map[string]interface{}{ - "ip": "10.0.0.1", - "dc": "eqdc10", - }, - "beta": map[string]interface{}{ - "ip": "10.0.0.2", - "dc": "eqdc10", - }, - }, - "clients": map[string]interface{}{ - "data": []interface{}{ - []interface{}{"gamma", "delta"}, - []interface{}{int64(1), int64(2)}, - }, - }, - } - testMaps(t, tree.ToMap(), expected) -} - -func TestTomlTreeWriteToMapWithTablesInMultipleChunks(t *testing.T) { - tree, _ := Load(` - [[menu.main]] - a = "menu 1" - b = "menu 2" - [[menu.main]] - c = "menu 3" - d = "menu 4"`) - expected := map[string]interface{}{ - "menu": map[string]interface{}{ - "main": []interface{}{ - map[string]interface{}{"a": "menu 1", "b": "menu 2"}, - map[string]interface{}{"c": "menu 3", "d": "menu 4"}, - }, - }, - } - treeMap := tree.ToMap() - - testMaps(t, treeMap, expected) -} - -func TestTomlTreeWriteToMapWithArrayOfInlineTables(t *testing.T) { - tree, _ := Load(` - [params] - language_tabs = [ - { key = "shell", name = "Shell" }, - { key = "ruby", name = "Ruby" }, - { key = "python", name = "Python" } - ]`) - - expected := map[string]interface{}{ - "params": map[string]interface{}{ - "language_tabs": []interface{}{ - map[string]interface{}{ - "key": "shell", - "name": "Shell", - }, - map[string]interface{}{ - "key": "ruby", - "name": "Ruby", - }, - map[string]interface{}{ - "key": "python", - "name": "Python", - }, - }, - }, - } - - treeMap := tree.ToMap() - testMaps(t, treeMap, expected) -} diff --git a/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore deleted file mode 100644 index daf913b1b3..0000000000 --- a/vendor/github.com/pkg/errors/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml deleted file mode 100644 index 588ceca183..0000000000 --- a/vendor/github.com/pkg/errors/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: go -go_import_path: github.com/pkg/errors -go: - - 1.4.3 - - 1.5.4 - - 1.6.2 - - 1.7.1 - - tip - -script: - - go test -v ./... diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md deleted file mode 100644 index 273db3c98a..0000000000 --- a/vendor/github.com/pkg/errors/README.md +++ /dev/null @@ -1,52 +0,0 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) - -Package errors provides simple error handling primitives. - -`go get github.com/pkg/errors` - -The traditional error handling idiom in Go is roughly akin to -```go -if err != nil { - return err -} -``` -which applied recursively up the call stack results in error reports without context or debugging information. The errors package allows programmers to add context to the failure path in their code in a way that does not destroy the original value of the error. - -## Adding context to an error - -The errors.Wrap function returns a new error that adds context to the original error. For example -```go -_, err := ioutil.ReadAll(r) -if err != nil { - return errors.Wrap(err, "read failed") -} -``` -## Retrieving the cause of an error - -Using `errors.Wrap` constructs a stack of errors, adding context to the preceding error. Depending on the nature of the error it may be necessary to reverse the operation of errors.Wrap to retrieve the original error for inspection. Any error value which implements this interface can be inspected by `errors.Cause`. -```go -type causer interface { - Cause() error -} -``` -`errors.Cause` will recursively retrieve the topmost error which does not implement `causer`, which is assumed to be the original cause. For example: -```go -switch err := errors.Cause(err).(type) { -case *MyError: - // handle specifically -default: - // unknown error -} -``` - -[Read the package documentation for more information](https://godoc.org/github.com/pkg/errors). - -## Contributing - -We welcome pull requests, bug fixes and issue reports. With that said, the bar for adding new symbols to this package is intentionally set high. - -Before proposing a change, please discuss your change by raising an issue. - -## Licence - -BSD-2-Clause diff --git a/vendor/github.com/pkg/errors/appveyor.yml b/vendor/github.com/pkg/errors/appveyor.yml deleted file mode 100644 index a932eade02..0000000000 --- a/vendor/github.com/pkg/errors/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: build-{build}.{branch} - -clone_folder: C:\gopath\src\github.com\pkg\errors -shallow_clone: true # for startup speed - -environment: - GOPATH: C:\gopath - -platform: - - x64 - -# http://www.appveyor.com/docs/installed-software -install: - # some helpful output for debugging builds - - go version - - go env - # pre-installed MinGW at C:\MinGW is 32bit only - # but MSYS2 at C:\msys64 has mingw64 - - set PATH=C:\msys64\mingw64\bin;%PATH% - - gcc --version - - g++ --version - -build_script: - - go install -v ./... - -test_script: - - set PATH=C:\gopath\bin;%PATH% - - go test -v ./... - -#artifacts: -# - path: '%GOPATH%\bin\*.exe' -deploy: off diff --git a/vendor/github.com/pkg/errors/bench_test.go b/vendor/github.com/pkg/errors/bench_test.go deleted file mode 100644 index 0416a3cbb8..0000000000 --- a/vendor/github.com/pkg/errors/bench_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// +build go1.7 - -package errors - -import ( - "fmt" - "testing" - - stderrors "errors" -) - -func noErrors(at, depth int) error { - if at >= depth { - return stderrors.New("no error") - } - return noErrors(at+1, depth) -} -func yesErrors(at, depth int) error { - if at >= depth { - return New("ye error") - } - return yesErrors(at+1, depth) -} - -func BenchmarkErrors(b *testing.B) { - var toperr error - type run struct { - stack int - std bool - } - runs := []run{ - {10, false}, - {10, true}, - {100, false}, - {100, true}, - {1000, false}, - {1000, true}, - } - for _, r := range runs { - part := "pkg/errors" - if r.std { - part = "errors" - } - name := fmt.Sprintf("%s-stack-%d", part, r.stack) - b.Run(name, func(b *testing.B) { - var err error - f := yesErrors - if r.std { - f = noErrors - } - b.ReportAllocs() - for i := 0; i < b.N; i++ { - err = f(0, r.stack) - } - b.StopTimer() - toperr = err - }) - } -} diff --git a/vendor/github.com/pkg/errors/errors_test.go b/vendor/github.com/pkg/errors/errors_test.go deleted file mode 100644 index 1d8c635586..0000000000 --- a/vendor/github.com/pkg/errors/errors_test.go +++ /dev/null @@ -1,226 +0,0 @@ -package errors - -import ( - "errors" - "fmt" - "io" - "reflect" - "testing" -) - -func TestNew(t *testing.T) { - tests := []struct { - err string - want error - }{ - {"", fmt.Errorf("")}, - {"foo", fmt.Errorf("foo")}, - {"foo", New("foo")}, - {"string with format specifiers: %v", errors.New("string with format specifiers: %v")}, - } - - for _, tt := range tests { - got := New(tt.err) - if got.Error() != tt.want.Error() { - t.Errorf("New.Error(): got: %q, want %q", got, tt.want) - } - } -} - -func TestWrapNil(t *testing.T) { - got := Wrap(nil, "no error") - if got != nil { - t.Errorf("Wrap(nil, \"no error\"): got %#v, expected nil", got) - } -} - -func TestWrap(t *testing.T) { - tests := []struct { - err error - message string - want string - }{ - {io.EOF, "read error", "read error: EOF"}, - {Wrap(io.EOF, "read error"), "client error", "client error: read error: EOF"}, - } - - for _, tt := range tests { - got := Wrap(tt.err, tt.message).Error() - if got != tt.want { - t.Errorf("Wrap(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) - } - } -} - -type nilError struct{} - -func (nilError) Error() string { return "nil error" } - -func TestCause(t *testing.T) { - x := New("error") - tests := []struct { - err error - want error - }{{ - // nil error is nil - err: nil, - want: nil, - }, { - // explicit nil error is nil - err: (error)(nil), - want: nil, - }, { - // typed nil is nil - err: (*nilError)(nil), - want: (*nilError)(nil), - }, { - // uncaused error is unaffected - err: io.EOF, - want: io.EOF, - }, { - // caused error returns cause - err: Wrap(io.EOF, "ignored"), - want: io.EOF, - }, { - err: x, // return from errors.New - want: x, - }, { - WithMessage(nil, "whoops"), - nil, - }, { - WithMessage(io.EOF, "whoops"), - io.EOF, - }, { - WithStack(nil), - nil, - }, { - WithStack(io.EOF), - io.EOF, - }} - - for i, tt := range tests { - got := Cause(tt.err) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("test %d: got %#v, want %#v", i+1, got, tt.want) - } - } -} - -func TestWrapfNil(t *testing.T) { - got := Wrapf(nil, "no error") - if got != nil { - t.Errorf("Wrapf(nil, \"no error\"): got %#v, expected nil", got) - } -} - -func TestWrapf(t *testing.T) { - tests := []struct { - err error - message string - want string - }{ - {io.EOF, "read error", "read error: EOF"}, - {Wrapf(io.EOF, "read error without format specifiers"), "client error", "client error: read error without format specifiers: EOF"}, - {Wrapf(io.EOF, "read error with %d format specifier", 1), "client error", "client error: read error with 1 format specifier: EOF"}, - } - - for _, tt := range tests { - got := Wrapf(tt.err, tt.message).Error() - if got != tt.want { - t.Errorf("Wrapf(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) - } - } -} - -func TestErrorf(t *testing.T) { - tests := []struct { - err error - want string - }{ - {Errorf("read error without format specifiers"), "read error without format specifiers"}, - {Errorf("read error with %d format specifier", 1), "read error with 1 format specifier"}, - } - - for _, tt := range tests { - got := tt.err.Error() - if got != tt.want { - t.Errorf("Errorf(%v): got: %q, want %q", tt.err, got, tt.want) - } - } -} - -func TestWithStackNil(t *testing.T) { - got := WithStack(nil) - if got != nil { - t.Errorf("WithStack(nil): got %#v, expected nil", got) - } -} - -func TestWithStack(t *testing.T) { - tests := []struct { - err error - want string - }{ - {io.EOF, "EOF"}, - {WithStack(io.EOF), "EOF"}, - } - - for _, tt := range tests { - got := WithStack(tt.err).Error() - if got != tt.want { - t.Errorf("WithStack(%v): got: %v, want %v", tt.err, got, tt.want) - } - } -} - -func TestWithMessageNil(t *testing.T) { - got := WithMessage(nil, "no error") - if got != nil { - t.Errorf("WithMessage(nil, \"no error\"): got %#v, expected nil", got) - } -} - -func TestWithMessage(t *testing.T) { - tests := []struct { - err error - message string - want string - }{ - {io.EOF, "read error", "read error: EOF"}, - {WithMessage(io.EOF, "read error"), "client error", "client error: read error: EOF"}, - } - - for _, tt := range tests { - got := WithMessage(tt.err, tt.message).Error() - if got != tt.want { - t.Errorf("WithMessage(%v, %q): got: %q, want %q", tt.err, tt.message, got, tt.want) - } - } - -} - -// errors.New, etc values are not expected to be compared by value -// but the change in errors#27 made them incomparable. Assert that -// various kinds of errors have a functional equality operator, even -// if the result of that equality is always false. -func TestErrorEquality(t *testing.T) { - vals := []error{ - nil, - io.EOF, - errors.New("EOF"), - New("EOF"), - Errorf("EOF"), - Wrap(io.EOF, "EOF"), - Wrapf(io.EOF, "EOF%d", 2), - WithMessage(nil, "whoops"), - WithMessage(io.EOF, "whoops"), - WithStack(io.EOF), - WithStack(nil), - } - - for i := range vals { - for j := range vals { - _ = vals[i] == vals[j] // mustn't panic - } - } -} diff --git a/vendor/github.com/pkg/errors/example_test.go b/vendor/github.com/pkg/errors/example_test.go deleted file mode 100644 index c1fc13e384..0000000000 --- a/vendor/github.com/pkg/errors/example_test.go +++ /dev/null @@ -1,205 +0,0 @@ -package errors_test - -import ( - "fmt" - - "github.com/pkg/errors" -) - -func ExampleNew() { - err := errors.New("whoops") - fmt.Println(err) - - // Output: whoops -} - -func ExampleNew_printf() { - err := errors.New("whoops") - fmt.Printf("%+v", err) - - // Example output: - // whoops - // github.com/pkg/errors_test.ExampleNew_printf - // /home/dfc/src/github.com/pkg/errors/example_test.go:17 - // testing.runExample - // /home/dfc/go/src/testing/example.go:114 - // testing.RunExamples - // /home/dfc/go/src/testing/example.go:38 - // testing.(*M).Run - // /home/dfc/go/src/testing/testing.go:744 - // main.main - // /github.com/pkg/errors/_test/_testmain.go:106 - // runtime.main - // /home/dfc/go/src/runtime/proc.go:183 - // runtime.goexit - // /home/dfc/go/src/runtime/asm_amd64.s:2059 -} - -func ExampleWithMessage() { - cause := errors.New("whoops") - err := errors.WithMessage(cause, "oh noes") - fmt.Println(err) - - // Output: oh noes: whoops -} - -func ExampleWithStack() { - cause := errors.New("whoops") - err := errors.WithStack(cause) - fmt.Println(err) - - // Output: whoops -} - -func ExampleWithStack_printf() { - cause := errors.New("whoops") - err := errors.WithStack(cause) - fmt.Printf("%+v", err) - - // Example Output: - // whoops - // github.com/pkg/errors_test.ExampleWithStack_printf - // /home/fabstu/go/src/github.com/pkg/errors/example_test.go:55 - // testing.runExample - // /usr/lib/go/src/testing/example.go:114 - // testing.RunExamples - // /usr/lib/go/src/testing/example.go:38 - // testing.(*M).Run - // /usr/lib/go/src/testing/testing.go:744 - // main.main - // github.com/pkg/errors/_test/_testmain.go:106 - // runtime.main - // /usr/lib/go/src/runtime/proc.go:183 - // runtime.goexit - // /usr/lib/go/src/runtime/asm_amd64.s:2086 - // github.com/pkg/errors_test.ExampleWithStack_printf - // /home/fabstu/go/src/github.com/pkg/errors/example_test.go:56 - // testing.runExample - // /usr/lib/go/src/testing/example.go:114 - // testing.RunExamples - // /usr/lib/go/src/testing/example.go:38 - // testing.(*M).Run - // /usr/lib/go/src/testing/testing.go:744 - // main.main - // github.com/pkg/errors/_test/_testmain.go:106 - // runtime.main - // /usr/lib/go/src/runtime/proc.go:183 - // runtime.goexit - // /usr/lib/go/src/runtime/asm_amd64.s:2086 -} - -func ExampleWrap() { - cause := errors.New("whoops") - err := errors.Wrap(cause, "oh noes") - fmt.Println(err) - - // Output: oh noes: whoops -} - -func fn() error { - e1 := errors.New("error") - e2 := errors.Wrap(e1, "inner") - e3 := errors.Wrap(e2, "middle") - return errors.Wrap(e3, "outer") -} - -func ExampleCause() { - err := fn() - fmt.Println(err) - fmt.Println(errors.Cause(err)) - - // Output: outer: middle: inner: error - // error -} - -func ExampleWrap_extended() { - err := fn() - fmt.Printf("%+v\n", err) - - // Example output: - // error - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:47 - // github.com/pkg/errors_test.ExampleCause_printf - // /home/dfc/src/github.com/pkg/errors/example_test.go:63 - // testing.runExample - // /home/dfc/go/src/testing/example.go:114 - // testing.RunExamples - // /home/dfc/go/src/testing/example.go:38 - // testing.(*M).Run - // /home/dfc/go/src/testing/testing.go:744 - // main.main - // /github.com/pkg/errors/_test/_testmain.go:104 - // runtime.main - // /home/dfc/go/src/runtime/proc.go:183 - // runtime.goexit - // /home/dfc/go/src/runtime/asm_amd64.s:2059 - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:48: inner - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:49: middle - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:50: outer -} - -func ExampleWrapf() { - cause := errors.New("whoops") - err := errors.Wrapf(cause, "oh noes #%d", 2) - fmt.Println(err) - - // Output: oh noes #2: whoops -} - -func ExampleErrorf_extended() { - err := errors.Errorf("whoops: %s", "foo") - fmt.Printf("%+v", err) - - // Example output: - // whoops: foo - // github.com/pkg/errors_test.ExampleErrorf - // /home/dfc/src/github.com/pkg/errors/example_test.go:101 - // testing.runExample - // /home/dfc/go/src/testing/example.go:114 - // testing.RunExamples - // /home/dfc/go/src/testing/example.go:38 - // testing.(*M).Run - // /home/dfc/go/src/testing/testing.go:744 - // main.main - // /github.com/pkg/errors/_test/_testmain.go:102 - // runtime.main - // /home/dfc/go/src/runtime/proc.go:183 - // runtime.goexit - // /home/dfc/go/src/runtime/asm_amd64.s:2059 -} - -func Example_stackTrace() { - type stackTracer interface { - StackTrace() errors.StackTrace - } - - err, ok := errors.Cause(fn()).(stackTracer) - if !ok { - panic("oops, err does not implement stackTracer") - } - - st := err.StackTrace() - fmt.Printf("%+v", st[0:2]) // top two frames - - // Example output: - // github.com/pkg/errors_test.fn - // /home/dfc/src/github.com/pkg/errors/example_test.go:47 - // github.com/pkg/errors_test.Example_stackTrace - // /home/dfc/src/github.com/pkg/errors/example_test.go:127 -} - -func ExampleCause_printf() { - err := errors.Wrap(func() error { - return func() error { - return errors.Errorf("hello %s", fmt.Sprintf("world")) - }() - }(), "failed") - - fmt.Printf("%v", err) - - // Output: failed: hello world -} diff --git a/vendor/github.com/pkg/errors/format_test.go b/vendor/github.com/pkg/errors/format_test.go deleted file mode 100644 index 15fd7d89d7..0000000000 --- a/vendor/github.com/pkg/errors/format_test.go +++ /dev/null @@ -1,535 +0,0 @@ -package errors - -import ( - "errors" - "fmt" - "io" - "regexp" - "strings" - "testing" -) - -func TestFormatNew(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - New("error"), - "%s", - "error", - }, { - New("error"), - "%v", - "error", - }, { - New("error"), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatNew\n" + - "\t.+/github.com/pkg/errors/format_test.go:26", - }, { - New("error"), - "%q", - `"error"`, - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatErrorf(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - Errorf("%s", "error"), - "%s", - "error", - }, { - Errorf("%s", "error"), - "%v", - "error", - }, { - Errorf("%s", "error"), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatErrorf\n" + - "\t.+/github.com/pkg/errors/format_test.go:56", - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatWrap(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - Wrap(New("error"), "error2"), - "%s", - "error2: error", - }, { - Wrap(New("error"), "error2"), - "%v", - "error2: error", - }, { - Wrap(New("error"), "error2"), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatWrap\n" + - "\t.+/github.com/pkg/errors/format_test.go:82", - }, { - Wrap(io.EOF, "error"), - "%s", - "error: EOF", - }, { - Wrap(io.EOF, "error"), - "%v", - "error: EOF", - }, { - Wrap(io.EOF, "error"), - "%+v", - "EOF\n" + - "error\n" + - "github.com/pkg/errors.TestFormatWrap\n" + - "\t.+/github.com/pkg/errors/format_test.go:96", - }, { - Wrap(Wrap(io.EOF, "error1"), "error2"), - "%+v", - "EOF\n" + - "error1\n" + - "github.com/pkg/errors.TestFormatWrap\n" + - "\t.+/github.com/pkg/errors/format_test.go:103\n", - }, { - Wrap(New("error with space"), "context"), - "%q", - `"context: error with space"`, - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatWrapf(t *testing.T) { - tests := []struct { - error - format string - want string - }{{ - Wrapf(io.EOF, "error%d", 2), - "%s", - "error2: EOF", - }, { - Wrapf(io.EOF, "error%d", 2), - "%v", - "error2: EOF", - }, { - Wrapf(io.EOF, "error%d", 2), - "%+v", - "EOF\n" + - "error2\n" + - "github.com/pkg/errors.TestFormatWrapf\n" + - "\t.+/github.com/pkg/errors/format_test.go:134", - }, { - Wrapf(New("error"), "error%d", 2), - "%s", - "error2: error", - }, { - Wrapf(New("error"), "error%d", 2), - "%v", - "error2: error", - }, { - Wrapf(New("error"), "error%d", 2), - "%+v", - "error\n" + - "github.com/pkg/errors.TestFormatWrapf\n" + - "\t.+/github.com/pkg/errors/format_test.go:149", - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.error, tt.format, tt.want) - } -} - -func TestFormatWithStack(t *testing.T) { - tests := []struct { - error - format string - want []string - }{{ - WithStack(io.EOF), - "%s", - []string{"EOF"}, - }, { - WithStack(io.EOF), - "%v", - []string{"EOF"}, - }, { - WithStack(io.EOF), - "%+v", - []string{"EOF", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:175"}, - }, { - WithStack(New("error")), - "%s", - []string{"error"}, - }, { - WithStack(New("error")), - "%v", - []string{"error"}, - }, { - WithStack(New("error")), - "%+v", - []string{"error", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:189", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:189"}, - }, { - WithStack(WithStack(io.EOF)), - "%+v", - []string{"EOF", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:197", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:197"}, - }, { - WithStack(WithStack(Wrapf(io.EOF, "message"))), - "%+v", - []string{"EOF", - "message", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:205", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:205", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:205"}, - }, { - WithStack(Errorf("error%d", 1)), - "%+v", - []string{"error1", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:216", - "github.com/pkg/errors.TestFormatWithStack\n" + - "\t.+/github.com/pkg/errors/format_test.go:216"}, - }} - - for i, tt := range tests { - testFormatCompleteCompare(t, i, tt.error, tt.format, tt.want, true) - } -} - -func TestFormatWithMessage(t *testing.T) { - tests := []struct { - error - format string - want []string - }{{ - WithMessage(New("error"), "error2"), - "%s", - []string{"error2: error"}, - }, { - WithMessage(New("error"), "error2"), - "%v", - []string{"error2: error"}, - }, { - WithMessage(New("error"), "error2"), - "%+v", - []string{ - "error", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:244", - "error2"}, - }, { - WithMessage(io.EOF, "addition1"), - "%s", - []string{"addition1: EOF"}, - }, { - WithMessage(io.EOF, "addition1"), - "%v", - []string{"addition1: EOF"}, - }, { - WithMessage(io.EOF, "addition1"), - "%+v", - []string{"EOF", "addition1"}, - }, { - WithMessage(WithMessage(io.EOF, "addition1"), "addition2"), - "%v", - []string{"addition2: addition1: EOF"}, - }, { - WithMessage(WithMessage(io.EOF, "addition1"), "addition2"), - "%+v", - []string{"EOF", "addition1", "addition2"}, - }, { - Wrap(WithMessage(io.EOF, "error1"), "error2"), - "%+v", - []string{"EOF", "error1", "error2", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:272"}, - }, { - WithMessage(Errorf("error%d", 1), "error2"), - "%+v", - []string{"error1", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:278", - "error2"}, - }, { - WithMessage(WithStack(io.EOF), "error"), - "%+v", - []string{ - "EOF", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:285", - "error"}, - }, { - WithMessage(Wrap(WithStack(io.EOF), "inside-error"), "outside-error"), - "%+v", - []string{ - "EOF", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:293", - "inside-error", - "github.com/pkg/errors.TestFormatWithMessage\n" + - "\t.+/github.com/pkg/errors/format_test.go:293", - "outside-error"}, - }} - - for i, tt := range tests { - testFormatCompleteCompare(t, i, tt.error, tt.format, tt.want, true) - } -} - -func TestFormatGeneric(t *testing.T) { - starts := []struct { - err error - want []string - }{ - {New("new-error"), []string{ - "new-error", - "github.com/pkg/errors.TestFormatGeneric\n" + - "\t.+/github.com/pkg/errors/format_test.go:315"}, - }, {Errorf("errorf-error"), []string{ - "errorf-error", - "github.com/pkg/errors.TestFormatGeneric\n" + - "\t.+/github.com/pkg/errors/format_test.go:319"}, - }, {errors.New("errors-new-error"), []string{ - "errors-new-error"}, - }, - } - - wrappers := []wrapper{ - { - func(err error) error { return WithMessage(err, "with-message") }, - []string{"with-message"}, - }, { - func(err error) error { return WithStack(err) }, - []string{ - "github.com/pkg/errors.(func·002|TestFormatGeneric.func2)\n\t" + - ".+/github.com/pkg/errors/format_test.go:333", - }, - }, { - func(err error) error { return Wrap(err, "wrap-error") }, - []string{ - "wrap-error", - "github.com/pkg/errors.(func·003|TestFormatGeneric.func3)\n\t" + - ".+/github.com/pkg/errors/format_test.go:339", - }, - }, { - func(err error) error { return Wrapf(err, "wrapf-error%d", 1) }, - []string{ - "wrapf-error1", - "github.com/pkg/errors.(func·004|TestFormatGeneric.func4)\n\t" + - ".+/github.com/pkg/errors/format_test.go:346", - }, - }, - } - - for s := range starts { - err := starts[s].err - want := starts[s].want - testFormatCompleteCompare(t, s, err, "%+v", want, false) - testGenericRecursive(t, err, want, wrappers, 3) - } -} - -func testFormatRegexp(t *testing.T, n int, arg interface{}, format, want string) { - got := fmt.Sprintf(format, arg) - gotLines := strings.SplitN(got, "\n", -1) - wantLines := strings.SplitN(want, "\n", -1) - - if len(wantLines) > len(gotLines) { - t.Errorf("test %d: wantLines(%d) > gotLines(%d):\n got: %q\nwant: %q", n+1, len(wantLines), len(gotLines), got, want) - return - } - - for i, w := range wantLines { - match, err := regexp.MatchString(w, gotLines[i]) - if err != nil { - t.Fatal(err) - } - if !match { - t.Errorf("test %d: line %d: fmt.Sprintf(%q, err):\n got: %q\nwant: %q", n+1, i+1, format, got, want) - } - } -} - -var stackLineR = regexp.MustCompile(`\.`) - -// parseBlocks parses input into a slice, where: -// - incase entry contains a newline, its a stacktrace -// - incase entry contains no newline, its a solo line. -// -// Detecting stack boundaries only works incase the WithStack-calls are -// to be found on the same line, thats why it is optionally here. -// -// Example use: -// -// for _, e := range blocks { -// if strings.ContainsAny(e, "\n") { -// // Match as stack -// } else { -// // Match as line -// } -// } -// -func parseBlocks(input string, detectStackboundaries bool) ([]string, error) { - var blocks []string - - stack := "" - wasStack := false - lines := map[string]bool{} // already found lines - - for _, l := range strings.Split(input, "\n") { - isStackLine := stackLineR.MatchString(l) - - switch { - case !isStackLine && wasStack: - blocks = append(blocks, stack, l) - stack = "" - lines = map[string]bool{} - case isStackLine: - if wasStack { - // Detecting two stacks after another, possible cause lines match in - // our tests due to WithStack(WithStack(io.EOF)) on same line. - if detectStackboundaries { - if lines[l] { - if len(stack) == 0 { - return nil, errors.New("len of block must not be zero here") - } - - blocks = append(blocks, stack) - stack = l - lines = map[string]bool{l: true} - continue - } - } - - stack = stack + "\n" + l - } else { - stack = l - } - lines[l] = true - case !isStackLine && !wasStack: - blocks = append(blocks, l) - default: - return nil, errors.New("must not happen") - } - - wasStack = isStackLine - } - - // Use up stack - if stack != "" { - blocks = append(blocks, stack) - } - return blocks, nil -} - -func testFormatCompleteCompare(t *testing.T, n int, arg interface{}, format string, want []string, detectStackBoundaries bool) { - gotStr := fmt.Sprintf(format, arg) - - got, err := parseBlocks(gotStr, detectStackBoundaries) - if err != nil { - t.Fatal(err) - } - - if len(got) != len(want) { - t.Fatalf("test %d: fmt.Sprintf(%s, err) -> wrong number of blocks: got(%d) want(%d)\n got: %s\nwant: %s\ngotStr: %q", - n+1, format, len(got), len(want), prettyBlocks(got), prettyBlocks(want), gotStr) - } - - for i := range got { - if strings.ContainsAny(want[i], "\n") { - // Match as stack - match, err := regexp.MatchString(want[i], got[i]) - if err != nil { - t.Fatal(err) - } - if !match { - t.Fatalf("test %d: block %d: fmt.Sprintf(%q, err):\ngot:\n%q\nwant:\n%q\nall-got:\n%s\nall-want:\n%s\n", - n+1, i+1, format, got[i], want[i], prettyBlocks(got), prettyBlocks(want)) - } - } else { - // Match as message - if got[i] != want[i] { - t.Fatalf("test %d: fmt.Sprintf(%s, err) at block %d got != want:\n got: %q\nwant: %q", n+1, format, i+1, got[i], want[i]) - } - } - } -} - -type wrapper struct { - wrap func(err error) error - want []string -} - -func prettyBlocks(blocks []string, prefix ...string) string { - var out []string - - for _, b := range blocks { - out = append(out, fmt.Sprintf("%v", b)) - } - - return " " + strings.Join(out, "\n ") -} - -func testGenericRecursive(t *testing.T, beforeErr error, beforeWant []string, list []wrapper, maxDepth int) { - if len(beforeWant) == 0 { - panic("beforeWant must not be empty") - } - for _, w := range list { - if len(w.want) == 0 { - panic("want must not be empty") - } - - err := w.wrap(beforeErr) - - // Copy required cause append(beforeWant, ..) modified beforeWant subtly. - beforeCopy := make([]string, len(beforeWant)) - copy(beforeCopy, beforeWant) - - beforeWant := beforeCopy - last := len(beforeWant) - 1 - var want []string - - // Merge two stacks behind each other. - if strings.ContainsAny(beforeWant[last], "\n") && strings.ContainsAny(w.want[0], "\n") { - want = append(beforeWant[:last], append([]string{beforeWant[last] + "((?s).*)" + w.want[0]}, w.want[1:]...)...) - } else { - want = append(beforeWant, w.want...) - } - - testFormatCompleteCompare(t, maxDepth, err, "%+v", want, false) - if maxDepth > 0 { - testGenericRecursive(t, err, want, list, maxDepth-1) - } - } -} diff --git a/vendor/github.com/pkg/errors/stack_test.go b/vendor/github.com/pkg/errors/stack_test.go deleted file mode 100644 index 510c27a9f9..0000000000 --- a/vendor/github.com/pkg/errors/stack_test.go +++ /dev/null @@ -1,292 +0,0 @@ -package errors - -import ( - "fmt" - "runtime" - "testing" -) - -var initpc, _, _, _ = runtime.Caller(0) - -func TestFrameLine(t *testing.T) { - var tests = []struct { - Frame - want int - }{{ - Frame(initpc), - 9, - }, { - func() Frame { - var pc, _, _, _ = runtime.Caller(0) - return Frame(pc) - }(), - 20, - }, { - func() Frame { - var pc, _, _, _ = runtime.Caller(1) - return Frame(pc) - }(), - 28, - }, { - Frame(0), // invalid PC - 0, - }} - - for _, tt := range tests { - got := tt.Frame.line() - want := tt.want - if want != got { - t.Errorf("Frame(%v): want: %v, got: %v", uintptr(tt.Frame), want, got) - } - } -} - -type X struct{} - -func (x X) val() Frame { - var pc, _, _, _ = runtime.Caller(0) - return Frame(pc) -} - -func (x *X) ptr() Frame { - var pc, _, _, _ = runtime.Caller(0) - return Frame(pc) -} - -func TestFrameFormat(t *testing.T) { - var tests = []struct { - Frame - format string - want string - }{{ - Frame(initpc), - "%s", - "stack_test.go", - }, { - Frame(initpc), - "%+s", - "github.com/pkg/errors.init\n" + - "\t.+/github.com/pkg/errors/stack_test.go", - }, { - Frame(0), - "%s", - "unknown", - }, { - Frame(0), - "%+s", - "unknown", - }, { - Frame(initpc), - "%d", - "9", - }, { - Frame(0), - "%d", - "0", - }, { - Frame(initpc), - "%n", - "init", - }, { - func() Frame { - var x X - return x.ptr() - }(), - "%n", - `\(\*X\).ptr`, - }, { - func() Frame { - var x X - return x.val() - }(), - "%n", - "X.val", - }, { - Frame(0), - "%n", - "", - }, { - Frame(initpc), - "%v", - "stack_test.go:9", - }, { - Frame(initpc), - "%+v", - "github.com/pkg/errors.init\n" + - "\t.+/github.com/pkg/errors/stack_test.go:9", - }, { - Frame(0), - "%v", - "unknown:0", - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.Frame, tt.format, tt.want) - } -} - -func TestFuncname(t *testing.T) { - tests := []struct { - name, want string - }{ - {"", ""}, - {"runtime.main", "main"}, - {"github.com/pkg/errors.funcname", "funcname"}, - {"funcname", "funcname"}, - {"io.copyBuffer", "copyBuffer"}, - {"main.(*R).Write", "(*R).Write"}, - } - - for _, tt := range tests { - got := funcname(tt.name) - want := tt.want - if got != want { - t.Errorf("funcname(%q): want: %q, got %q", tt.name, want, got) - } - } -} - -func TestTrimGOPATH(t *testing.T) { - var tests = []struct { - Frame - want string - }{{ - Frame(initpc), - "github.com/pkg/errors/stack_test.go", - }} - - for i, tt := range tests { - pc := tt.Frame.pc() - fn := runtime.FuncForPC(pc) - file, _ := fn.FileLine(pc) - got := trimGOPATH(fn.Name(), file) - testFormatRegexp(t, i, got, "%s", tt.want) - } -} - -func TestStackTrace(t *testing.T) { - tests := []struct { - err error - want []string - }{{ - New("ooh"), []string{ - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:172", - }, - }, { - Wrap(New("ooh"), "ahh"), []string{ - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:177", // this is the stack of Wrap, not New - }, - }, { - Cause(Wrap(New("ooh"), "ahh")), []string{ - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:182", // this is the stack of New - }, - }, { - func() error { return New("ooh") }(), []string{ - `github.com/pkg/errors.(func·009|TestStackTrace.func1)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New's caller - }, - }, { - Cause(func() error { - return func() error { - return Errorf("hello %s", fmt.Sprintf("world")) - }() - }()), []string{ - `github.com/pkg/errors.(func·010|TestStackTrace.func2.1)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:196", // this is the stack of Errorf - `github.com/pkg/errors.(func·011|TestStackTrace.func2)` + - "\n\t.+/github.com/pkg/errors/stack_test.go:197", // this is the stack of Errorf's caller - "github.com/pkg/errors.TestStackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:198", // this is the stack of Errorf's caller's caller - }, - }} - for i, tt := range tests { - x, ok := tt.err.(interface { - StackTrace() StackTrace - }) - if !ok { - t.Errorf("expected %#v to implement StackTrace() StackTrace", tt.err) - continue - } - st := x.StackTrace() - for j, want := range tt.want { - testFormatRegexp(t, i, st[j], "%+v", want) - } - } -} - -func stackTrace() StackTrace { - const depth = 8 - var pcs [depth]uintptr - n := runtime.Callers(1, pcs[:]) - var st stack = pcs[0:n] - return st.StackTrace() -} - -func TestStackTraceFormat(t *testing.T) { - tests := []struct { - StackTrace - format string - want string - }{{ - nil, - "%s", - `\[\]`, - }, { - nil, - "%v", - `\[\]`, - }, { - nil, - "%+v", - "", - }, { - nil, - "%#v", - `\[\]errors.Frame\(nil\)`, - }, { - make(StackTrace, 0), - "%s", - `\[\]`, - }, { - make(StackTrace, 0), - "%v", - `\[\]`, - }, { - make(StackTrace, 0), - "%+v", - "", - }, { - make(StackTrace, 0), - "%#v", - `\[\]errors.Frame{}`, - }, { - stackTrace()[:2], - "%s", - `\[stack_test.go stack_test.go\]`, - }, { - stackTrace()[:2], - "%v", - `\[stack_test.go:225 stack_test.go:272\]`, - }, { - stackTrace()[:2], - "%+v", - "\n" + - "github.com/pkg/errors.stackTrace\n" + - "\t.+/github.com/pkg/errors/stack_test.go:225\n" + - "github.com/pkg/errors.TestStackTraceFormat\n" + - "\t.+/github.com/pkg/errors/stack_test.go:276", - }, { - stackTrace()[:2], - "%#v", - `\[\]errors.Frame{stack_test.go:225, stack_test.go:284}`, - }} - - for i, tt := range tests { - testFormatRegexp(t, i, tt.StackTrace, tt.format, tt.want) - } -} diff --git a/vendor/github.com/sdboyer/constext/README.md b/vendor/github.com/sdboyer/constext/README.md deleted file mode 100644 index e267fd5478..0000000000 --- a/vendor/github.com/sdboyer/constext/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# constext [![Doc Status](https://godoc.org/github.com/sdboyer/constext?status.png)](https://godoc.org/github.com/sdboyer/constext) - -constext allows you to [`cons`](https://en.wikipedia.org/wiki/Cons) `Context`s -together as a pair, conjoining them for the purpose of all `Context` behaviors: - -1. If either parent context is canceled, the constext is canceled. The - err is set to whatever the err of the parent that was canceled. -2. If either parent has a deadline, the constext uses that same - deadline. If both have a deadline, it uses the sooner/lesser one. -3. Values from both parents are unioned together. When a key is present in both - parent trees, the left (first) context supercedes the right (second). - -Paired contexts can be recombined using the standard `context.With*()` -functions. - -## Usage - -Use is simple, and patterned after the `context` package. The `constext.Cons()` -function takes two `context.Context` arguments and returns a single, unified -one, along with a `context.CancelFunc`. - -```go -cctx, cancelFunc := constext.Cons(context.Background(), context.Background()) -``` - -True to the spirit of `cons`, recursive trees can be formed through -nesting: - -```go -bg := context.Background() -cctx := constext.Cons(bg, constext.Cons(bg, constext.Cons(bg, bg))) -``` - -This probably isn't a good idea, but it's possible. - -## Rationale - -While the unary model of context works well for the original vision - an object -operating within an [HTTP] request's scope - there are times when we need a -little more. - -For example: in [dep](https://github.com/golang/dep), the subsystem that -manages interaction with source repositories is called a -[`SourceManager`](https://godoc.org/github.com/sdboyer/gps#SourceManager). It -is a long-lived object; generally, only one is created over the course of any -single `dep` invocation. The `SourceManager` has a number of methods on it that -may initiate network and/or disk interaction. As such, these methods need to -take a `context.Context`, so that the caller can cancel them if needed. - -However, this is not sufficient. The `SourceManager` itself may need to be -terminated (e.g., if the process received a signal). In such a case, in-flight -method calls also need to be canceled, to avoid leaving disk in inconsistent -state. - -As a result, each in-flight request serves two parents - the initator of the -request, and the `SourceManager` itself. We can abstract away this complexity -by having a `Context` for each, and `Cons`ing them together on a per-call -basis. - -## Caveats - -_tl;dr: GC doesn't work right, so explicitly cancel constexts when done with them._ - -The stdlib context packages uses internal tree-walking trickery to avoid -spawning goroutines unless it actually has to. We can't rely on that same -trickery, in part because we can't access the tree internals, but also because -it's not so straightforward when multiple parents are involved. Consequently, -`Cons()` almost always must spawn a goroutine to ensure correct cancellation -behavior, whereas e.g. `context.WithCancel()` rarely has to. - -If, as in the use case above, your constext has one short-lived and one -long-lived parent, and the short-lived parent is not explicitly canceled (which -is typical), then until the long-lived parent is canceled, neither the -constext, nor any otherwise-unreachable members of the short-lived context tree -will be GCed. - -So, for now, explicitly cancel your constexts before they go out of scope, -otherwise you'll leak memory. diff --git a/vendor/github.com/sdboyer/constext/constext_test.go b/vendor/github.com/sdboyer/constext/constext_test.go deleted file mode 100644 index 907483b218..0000000000 --- a/vendor/github.com/sdboyer/constext/constext_test.go +++ /dev/null @@ -1,156 +0,0 @@ -package constext - -import ( - "context" - "runtime" - "testing" - "time" -) - -var bgc = context.Background() - -func TestConsCancel(t *testing.T) { - c1, cancel1 := context.WithCancel(bgc) - c2, cancel2 := context.WithCancel(bgc) - - cc, _ := Cons(c1, c2) - if _, has := cc.Deadline(); has { - t.Fatal("constext should not have a deadline if parents do not") - } - - cancel1() - select { - case <-cc.Done(): - case <-time.After(1 * time.Second): - buf := make([]byte, 10<<10) - n := runtime.Stack(buf, true) - t.Fatalf("timed out waiting for parent to quit; stacks:\n%s", buf[:n]) - } - - cc, _ = Cons(c1, c2) - if cc.Err() == nil { - t.Fatal("pre-canceled car constext did not begin canceled") - } - - cc, _ = Cons(c2, c1) - if cc.Err() == nil { - t.Fatal("pre-canceled cdr constext did not begin canceled") - } - - c3, _ := context.WithCancel(bgc) - cc, _ = Cons(c3, c2) - cancel2() - select { - case <-cc.Done(): - case <-time.After(1 * time.Second): - buf := make([]byte, 10<<10) - n := runtime.Stack(buf, true) - t.Fatalf("timed out waiting for cdr to quit; stacks:\n%s", buf[:n]) - } -} - -func TestCancelPassdown(t *testing.T) { - c1, cancel1 := context.WithCancel(bgc) - c2, _ := context.WithCancel(bgc) - cc, _ := Cons(c1, c2) - c3, _ := context.WithCancel(cc) - - cancel1() - select { - case <-c3.Done(): - case <-time.After(1 * time.Second): - buf := make([]byte, 10<<10) - n := runtime.Stack(buf, true) - t.Fatalf("timed out waiting for parent to quit; stacks:\n%s", buf[:n]) - } - - c1, cancel1 = context.WithCancel(bgc) - cc, _ = Cons(c1, c2) - c3 = context.WithValue(cc, "foo", "bar") - - cancel1() - select { - case <-c3.Done(): - case <-time.After(1 * time.Second): - buf := make([]byte, 10<<10) - n := runtime.Stack(buf, true) - t.Fatalf("timed out waiting for parent to quit; stacks:\n%s", buf[:n]) - } -} - -func TestValueUnion(t *testing.T) { - c1 := context.WithValue(bgc, "foo", "bar") - c2 := context.WithValue(bgc, "foo", "baz") - cc, _ := Cons(c1, c2) - - v := cc.Value("foo") - if v != "bar" { - t.Fatalf("wanted value of \"foo\" from car, \"bar\", got %q", v) - } - - c3 := context.WithValue(bgc, "bar", "quux") - cc2, _ := Cons(c1, c3) - v = cc2.Value("bar") - if v != "quux" { - t.Fatalf("wanted value from cdr, \"quux\", got %q", v) - } - - cc, _ = Cons(cc, c3) - v = cc.Value("bar") - if v != "quux" { - t.Fatalf("wanted value from nested cdr, \"quux\", got %q", v) - } -} - -func TestDeadline(t *testing.T) { - t1 := time.Now().Add(1 * time.Second) - c1, _ := context.WithDeadline(bgc, t1) - cc, _ := Cons(c1, bgc) - - cct, ok := cc.Deadline() - if !ok { - t.Fatal("constext claimed to not have any deadline, but car did") - } - if cct != t1 { - t.Fatal("constext did not have correct deadline") - } - - cc, _ = Cons(bgc, c1) - cct, ok = cc.Deadline() - if !ok { - t.Fatal("constext claimed to not have any deadline, but cdr did") - } - if cct != t1 { - t.Fatal("constext did not have correct deadline") - } - - t2 := time.Now().Add(1 * time.Second) - c2, _ := context.WithDeadline(bgc, t2) - cc, _ = Cons(c1, c2) - cct, ok = cc.Deadline() - if !ok { - t.Fatal("constext claimed to not have any deadline, but both parents did") - } - - if cct != t1 { - t.Fatal("got wrong deadline time back") - } - - cc, _ = Cons(c2, c1) - cct, ok = cc.Deadline() - if !ok { - t.Fatal("constext claimed to not have any deadline, but both parents did") - } - - if cct != t1 { - t.Fatal("got wrong deadline time back") - } - - select { - case <-cc.Done(): - case <-time.After(t1.Sub(time.Now()) + 5*time.Millisecond): - buf := make([]byte, 10<<10) - n := runtime.Stack(buf, true) - t.Fatalf("car did not quit after deadline; stacks:\n%s", buf[:n]) - } -}