diff --git a/.travis.yml b/.travis.yml
index 667f6446..eba6eeaf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: go
go:
-- 1.4.2
+- 1.5
sudo: false
notifications:
slack:
diff --git a/INSTALLGO.md b/INSTALLGO.md
index f8d41c68..eb4435b4 100644
--- a/INSTALLGO.md
+++ b/INSTALLGO.md
@@ -7,15 +7,15 @@ This installation guide is based on Ubuntu 14.04+ on x86-64 platform.
$ sudo apt-get install git build-essential
```
-##### Install Go 1.4+
+##### Install Go 1.5+
-Download Go 1.4+ from [https://golang.org/dl/](https://golang.org/dl/).
+Download Go 1.5+ from [https://golang.org/dl/](https://golang.org/dl/).
```sh
-$ wget https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz
+$ wget https://storage.googleapis.com/golang/go1.5.linux-amd64.tar.gz
$ mkdir -p ${HOME}/bin/
$ mkdir -p ${HOME}/go/
-$ tar -C ${HOME}/bin/ -xzf go1.4.linux-amd64.tar.gz
+$ tar -C ${HOME}/bin/ -xzf go1.5.linux-amd64.tar.gz
```
##### Setup GOROOT and GOPATH
@@ -42,7 +42,7 @@ $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/maste
$ brew install git python
```
-##### Install Go 1.4+
+##### Install Go 1.5+
Install golang binaries using `brew`
diff --git a/Makefile b/Makefile
index 204c6e47..6ba81072 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
## filter multiple GOPATH
-all: getdeps install
+all: install
checkdeps:
@echo "Checking deps:"
@@ -20,37 +20,37 @@ verifiers: getdeps vet fmt lint cyclo deadcode
vet:
@echo "Running $@:"
- @go vet .
- @go vet github.com/minio/mc/pkg...
+ @GO15VENDOREXPERIMENT=1 go vet .
+ @GO15VENDOREXPERIMENT=1 go vet github.com/minio/mc/pkg...
fmt:
@echo "Running $@:"
- @gofmt -s -l *.go
- @gofmt -s -l pkg
+ @GO15VENDOREXPERIMENT=1 gofmt -s -l *.go
+ @GO15VENDOREXPERIMENT=1 gofmt -s -l pkg
lint:
@echo "Running $@:"
- @golint .
- @golint pkg
+ @GO15VENDOREXPERIMENT=1 golint .
+ @GO15VENDOREXPERIMENT=1 golint pkg
cyclo:
@echo "Running $@:"
- @gocyclo -over 30 .
+ @GO15VENDOREXPERIMENT=1 gocyclo -over 30 .
deadcode:
@echo "Running $@:"
- @deadcode
+ @GO15VENDOREXPERIMENT=1 deadcode
build: getdeps verifiers
@echo "Installing mc:"
- @go test -race ./
- @go test -race github.com/minio/mc/pkg...
+ @GO15VENDOREXPERIMENT=1 go test -race ./
+ @GO15VENDOREXPERIMENT=1 go test -race github.com/minio/mc/pkg...
gomake-all: build
- @go install github.com/minio/mc
+ @GO15VENDOREXPERIMENT=1 go install github.com/minio/mc
@mkdir -p $(HOME)/.mc
release: genversion
@echo "Installing mc with new version.go:"
- @go install github.com/minio/mc
+ @GO15VENDOREXPERIMENT=1 go install github.com/minio/mc
@mkdir -p $(HOME)/.mc
genversion:
@@ -58,7 +58,7 @@ genversion:
@go run genversion.go
coverage:
- @go test -race -coverprofile=cover.out
+ @GO15VENDOREXPERIMENT=1 go test -race -coverprofile=cover.out
@go tool cover -html=cover.out && echo "Visit your browser"
install: gomake-all
diff --git a/access-main.go b/access-main.go
index e985701b..39f54d53 100644
--- a/access-main.go
+++ b/access-main.go
@@ -19,9 +19,9 @@ package main
import (
"errors"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/aliases.go b/aliases.go
index 5aaa5dfb..4bb0ff05 100644
--- a/aliases.go
+++ b/aliases.go
@@ -20,8 +20,8 @@ import (
"regexp"
"strings"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio/pkg/probe"
)
// validAliasURL: use net/url.Parse to validate
diff --git a/buildscripts/checkdeps.sh b/buildscripts/checkdeps.sh
index 6c98f3b5..6da1ea81 100755
--- a/buildscripts/checkdeps.sh
+++ b/buildscripts/checkdeps.sh
@@ -24,7 +24,7 @@ _init() {
CLANG_VERSION="3.5"
YASM_VERSION="1.2.0"
GIT_VERSION="1.0"
- GO_VERSION="1.4"
+ GO_VERSION="1.5"
OSX_VERSION="10.8"
UNAME=$(uname -sm)
diff --git a/cat-main.go b/cat-main.go
index 18336466..f59fecc0 100644
--- a/cat-main.go
+++ b/cat-main.go
@@ -21,8 +21,8 @@ import (
"os"
"syscall"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/cat_test.go b/cat_test.go
index 7a8b5603..82249126 100644
--- a/cat_test.go
+++ b/cat_test.go
@@ -22,9 +22,9 @@ import (
"os"
"path/filepath"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestCatCmd(c *C) {
diff --git a/cmd_test.go b/cmd_test.go
index c1964cdc..06d307a4 100644
--- a/cmd_test.go
+++ b/cmd_test.go
@@ -26,10 +26,10 @@ import (
"net/http/httptest"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/quick"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/quick"
+ . "gopkg.in/check.v1"
)
var customConfigDir string
diff --git a/common-methods.go b/common-methods.go
index 5e2f42d1..1a890de2 100644
--- a/common-methods.go
+++ b/common-methods.go
@@ -23,10 +23,10 @@ import (
"strings"
"sync"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/client"
"github.com/minio/mc/pkg/client/fs"
"github.com/minio/mc/pkg/client/s3"
+ "github.com/minio/minio/pkg/probe"
)
// Check if the target URL represents folder. It may or may not exist yet.
diff --git a/common_methods_test.go b/common_methods_test.go
index 96d0f9cb..a5be5e3a 100644
--- a/common_methods_test.go
+++ b/common_methods_test.go
@@ -23,7 +23,7 @@ import (
"os"
"path/filepath"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestCommonMethods(c *C) {
diff --git a/config-main.go b/config-main.go
index db9a9110..2f019a98 100644
--- a/config-main.go
+++ b/config-main.go
@@ -21,11 +21,11 @@ import (
"fmt"
"strings"
- "github.com/minio/mc/internal/github.com/fatih/color"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/quick"
+ "github.com/fatih/color"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/quick"
)
// Configure minio client
diff --git a/config.go b/config.go
index fb4b78eb..5dd73748 100644
--- a/config.go
+++ b/config.go
@@ -23,9 +23,9 @@ import (
"runtime"
"sync"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/quick"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/quick"
)
type configV2 struct {
diff --git a/config_test.go b/config_test.go
index 54f78f00..63943d36 100644
--- a/config_test.go
+++ b/config_test.go
@@ -19,8 +19,8 @@ package main
import (
"os"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestConfigContext(c *C) {
diff --git a/cp-json.go b/cp-json.go
index aade1071..79c3d57c 100644
--- a/cp-json.go
+++ b/cp-json.go
@@ -20,7 +20,7 @@ import (
"encoding/json"
"fmt"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/probe"
)
// CopyMessage container for file copy messages
diff --git a/cp-main.go b/cp-main.go
index c5017346..4102da54 100644
--- a/cp-main.go
+++ b/cp-main.go
@@ -26,9 +26,9 @@ import (
"runtime"
"sync"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/cp-url.go b/cp-url.go
index 6632c577..e29ff1b5 100644
--- a/cp-url.go
+++ b/cp-url.go
@@ -22,9 +22,9 @@ import (
"path/filepath"
"strings"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio/pkg/probe"
)
type copyURLs struct {
diff --git a/cp_mirror_test.go b/cp_mirror_test.go
index 169e4f55..ae81dd22 100644
--- a/cp_mirror_test.go
+++ b/cp_mirror_test.go
@@ -19,8 +19,8 @@ package main
import (
"os"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestCopyURLType(c *C) {
diff --git a/diff-main.go b/diff-main.go
index 9fe3f376..971b629b 100644
--- a/diff-main.go
+++ b/diff-main.go
@@ -19,8 +19,8 @@ package main
import (
"fmt"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/diff.go b/diff.go
index a3b1327f..61e4fbeb 100644
--- a/diff.go
+++ b/diff.go
@@ -24,10 +24,10 @@ import (
"sync"
"time"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/tchap/go-patricia/patricia"
"github.com/minio/mc/pkg/client"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/tchap/go-patricia/patricia"
)
//
diff --git a/diff_test.go b/diff_test.go
index 234adddd..7abb7aee 100644
--- a/diff_test.go
+++ b/diff_test.go
@@ -23,9 +23,9 @@ import (
"path/filepath"
"strconv"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestDiffObjects(c *C) {
diff --git a/error.go b/error.go
index c0f220f0..bf481098 100644
--- a/error.go
+++ b/error.go
@@ -21,8 +21,8 @@ import (
"fmt"
"os"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// fatalIf wrapper function which takes error and selectively prints stack frames if available on debug
diff --git a/flags.go b/flags.go
index 726db14d..ba180baf 100644
--- a/flags.go
+++ b/flags.go
@@ -16,7 +16,7 @@
package main
-import "github.com/minio/mc/internal/github.com/minio/cli"
+import "github.com/minio/cli"
// Collection of mc commands currently supported are
var commands = []cli.Command{}
diff --git a/hostconfig.go b/hostconfig.go
index 42179fa4..6c3ca0ae 100644
--- a/hostconfig.go
+++ b/hostconfig.go
@@ -19,8 +19,8 @@ package main
import (
"path/filepath"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio/pkg/probe"
)
type hostConfig struct {
diff --git a/ls-main.go b/ls-main.go
index 3c9ef1ea..df81a3f0 100644
--- a/ls-main.go
+++ b/ls-main.go
@@ -17,8 +17,8 @@
package main
import (
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/ls.go b/ls.go
index 34d6d618..201a284b 100644
--- a/ls.go
+++ b/ls.go
@@ -22,10 +22,10 @@ import (
"runtime"
"strings"
- "github.com/minio/mc/internal/github.com/dustin/go-humanize"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/dustin/go-humanize"
"github.com/minio/mc/pkg/client"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
/// ls - related internal functions
diff --git a/ls_test.go b/ls_test.go
index 3fb855ac..640d1571 100644
--- a/ls_test.go
+++ b/ls_test.go
@@ -23,9 +23,9 @@ import (
"path/filepath"
"strconv"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestLSCmd(c *C) {
diff --git a/main.go b/main.go
index ce6121b2..5555628c 100644
--- a/main.go
+++ b/main.go
@@ -25,9 +25,9 @@ import (
"strconv"
"time"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/pb"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/pb"
)
// Check for the environment early on and gracefully report.
diff --git a/mb-main.go b/mb-main.go
index af97e67f..a3d3f560 100644
--- a/mb-main.go
+++ b/mb-main.go
@@ -17,9 +17,9 @@
package main
import (
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/mb_access_test.go b/mb_access_test.go
index f9752c14..e3a61a47 100644
--- a/mb_access_test.go
+++ b/mb_access_test.go
@@ -21,8 +21,8 @@ import (
"os"
"path/filepath"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestMbAndAccessCmd(c *C) {
diff --git a/mirror-main.go b/mirror-main.go
index efcbfd39..6d04cddf 100644
--- a/mirror-main.go
+++ b/mirror-main.go
@@ -26,9 +26,9 @@ import (
"runtime"
"sync"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/mirror-url.go b/mirror-url.go
index 6bd52afa..a5a7d39f 100644
--- a/mirror-url.go
+++ b/mirror-url.go
@@ -21,11 +21,11 @@ import (
"strings"
"sync"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/tchap/go-patricia/patricia"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/client"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/tchap/go-patricia/patricia"
)
type mirrorURLs struct {
diff --git a/notifier.go b/notifier.go
index 220ad19e..bfcd2896 100644
--- a/notifier.go
+++ b/notifier.go
@@ -22,8 +22,8 @@ import (
"runtime"
"strings"
- "github.com/minio/mc/internal/github.com/fatih/color"
- "github.com/minio/mc/internal/github.com/olekukonko/ts"
+ "github.com/fatih/color"
+ "github.com/olekukonko/ts"
)
// printUpdateNotify - inspired from Yeoman project npm package https://github.com/yeoman/update-notifier
diff --git a/pb.go b/pb.go
index 1f880f4e..598c7f58 100644
--- a/pb.go
+++ b/pb.go
@@ -24,10 +24,10 @@ import (
"sync/atomic"
"time"
- "github.com/minio/mc/internal/github.com/dustin/go-humanize"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/minio/pb"
- "github.com/minio/mc/internal/github.com/olekukonko/ts"
+ "github.com/dustin/go-humanize"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/minio/pb"
+ "github.com/olekukonko/ts"
"github.com/minio/mc/pkg/console"
)
diff --git a/pkg/client/client.go b/pkg/client/client.go
index 8dfc4700..71e3094b 100644
--- a/pkg/client/client.go
+++ b/pkg/client/client.go
@@ -21,7 +21,7 @@ import (
"os"
"time"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/probe"
)
// Client - client interface
diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go
index 907b6712..e468a0c5 100644
--- a/pkg/client/client_test.go
+++ b/pkg/client/client_test.go
@@ -19,7 +19,7 @@ package client
import (
"testing"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/pkg/client/fs/fs.go b/pkg/client/fs/fs.go
index 3179ace6..e40ddc3a 100644
--- a/pkg/client/fs/fs.go
+++ b/pkg/client/fs/fs.go
@@ -25,8 +25,8 @@ import (
"io/ioutil"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio/pkg/probe"
)
type fsClient struct {
diff --git a/pkg/client/fs/fs_test.go b/pkg/client/fs/fs_test.go
index 1951cb14..dcac0544 100644
--- a/pkg/client/fs/fs_test.go
+++ b/pkg/client/fs/fs_test.go
@@ -24,9 +24,9 @@ import (
"path/filepath"
"testing"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/client"
"github.com/minio/mc/pkg/client/fs"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/pkg/client/s3/s3.go b/pkg/client/s3/s3.go
index 8fffdaa7..aecdf096 100644
--- a/pkg/client/s3/s3.go
+++ b/pkg/client/s3/s3.go
@@ -24,9 +24,9 @@ import (
"strings"
"time"
- "github.com/minio/mc/internal/github.com/minio/minio-go"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio-go"
+ "github.com/minio/minio/pkg/probe"
)
// Config - see http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html
diff --git a/pkg/client/s3/s3_test.go b/pkg/client/s3/s3_test.go
index 83ea4d48..957e445e 100644
--- a/pkg/client/s3/s3_test.go
+++ b/pkg/client/s3/s3_test.go
@@ -26,7 +26,7 @@ import (
"testing"
"time"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
+ . "gopkg.in/check.v1"
)
type bucketHandler struct {
diff --git a/pkg/console/console.go b/pkg/console/console.go
index e6fa5844..5c375827 100644
--- a/pkg/console/console.go
+++ b/pkg/console/console.go
@@ -23,10 +23,10 @@ import (
"path/filepath"
- "github.com/minio/mc/internal/github.com/fatih/color"
- "github.com/minio/mc/internal/github.com/mattn/go-isatty"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/shiena/ansicolor"
+ "github.com/fatih/color"
+ "github.com/mattn/go-isatty"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/shiena/ansicolor"
)
// NoDebugPrint defines if the input should be printed in debug or not. By default it's set to true.
diff --git a/pkg/console/console_test.go b/pkg/console/console_test.go
index b28e0be1..bcccbbc2 100644
--- a/pkg/console/console_test.go
+++ b/pkg/console/console_test.go
@@ -19,8 +19,8 @@ package console
import (
"testing"
- "github.com/minio/mc/internal/github.com/fatih/color"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
+ "github.com/fatih/color"
+ . "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
diff --git a/session-main.go b/session-main.go
index 6e15f781..9ea386c4 100644
--- a/session-main.go
+++ b/session-main.go
@@ -21,9 +21,9 @@ import (
"sort"
"strings"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/session-v1.go b/session-v1.go
index 83ec70e6..f57bb63c 100644
--- a/session-v1.go
+++ b/session-v1.go
@@ -26,9 +26,9 @@ import (
"sync"
"time"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/quick"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/quick"
)
type sessionV1 struct {
diff --git a/session-v2.go b/session-v2.go
index 980faf1c..43f54249 100644
--- a/session-v2.go
+++ b/session-v2.go
@@ -25,9 +25,9 @@ import (
"sync"
"time"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/quick"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/quick"
)
// migrateSessionV1ToV2 migrates all session files from v1 to v2.
diff --git a/session.go b/session.go
index 3f5695a0..994e8d94 100644
--- a/session.go
+++ b/session.go
@@ -23,7 +23,7 @@ import (
"strings"
"time"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/minio/pkg/probe"
)
func migrateSession() {
diff --git a/session_test.go b/session_test.go
index ca3431d6..2d3af137 100644
--- a/session_test.go
+++ b/session_test.go
@@ -20,8 +20,8 @@ import (
"os"
"regexp"
- . "github.com/minio/mc/internal/gopkg.in/check.v1"
"github.com/minio/mc/pkg/console"
+ . "gopkg.in/check.v1"
)
func (s *CmdTestSuite) TestValidSessionID(c *C) {
diff --git a/share-main.go b/share-main.go
index 56884dbf..e310f298 100644
--- a/share-main.go
+++ b/share-main.go
@@ -22,10 +22,10 @@ import (
"strings"
"time"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/client"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// Help message.
diff --git a/update-main.go b/update-main.go
index 338613dd..0ce0233b 100644
--- a/update-main.go
+++ b/update-main.go
@@ -22,9 +22,9 @@ import (
"runtime"
"time"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
// Updates container to hold updates json
diff --git a/url.go b/url.go
index ed3dc847..aeaaf00a 100644
--- a/url.go
+++ b/url.go
@@ -19,8 +19,8 @@ package main
import (
"strings"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
"github.com/minio/mc/pkg/client"
+ "github.com/minio/minio/pkg/probe"
)
// ``...`` recursiveSeparator
diff --git a/internal/vendor.json b/vendor.json
similarity index 64%
rename from internal/vendor.json
rename to vendor.json
index f2e4add5..651829a3 100755
--- a/internal/vendor.json
+++ b/vendor.json
@@ -1,95 +1,95 @@
{
"comment": "",
- "ignore": "test",
+ "ignore": "",
"package": [
{
"canonical": "github.com/dustin/go-humanize",
"comment": "",
- "local": "github.com/dustin/go-humanize",
- "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
- "revisionTime": "2015-08-20T22:35:37-07:00"
+ "local": "vendor/github.com/dustin/go-humanize",
+ "revision": "1c212aae1d02984808182b98b0da7a3e07e4c770",
+ "revisionTime": "2015-08-09T13:14:05-07:00"
},
{
"canonical": "github.com/fatih/color",
"comment": "",
- "local": "github.com/fatih/color",
+ "local": "vendor/github.com/fatih/color",
"revision": "f773d4c806cc8e4a5749d6a35e2a4bbcd71443d6",
"revisionTime": "2015-08-04T08:17:43+03:00"
},
{
"canonical": "github.com/fatih/structs",
"comment": "",
- "local": "github.com/fatih/structs",
+ "local": "vendor/github.com/fatih/structs",
"revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
"revisionTime": "2015-08-20T22:35:37-07:00"
},
{
"canonical": "github.com/mattn/go-isatty",
"comment": "",
- "local": "github.com/mattn/go-isatty",
+ "local": "vendor/github.com/mattn/go-isatty",
"revision": "7fcbc72f853b92b5720db4a6b8482be612daef24",
"revisionTime": "2015-08-14T09:26:29+09:00"
},
{
"canonical": "github.com/minio/cli",
"comment": "",
- "local": "github.com/minio/cli",
+ "local": "vendor/github.com/minio/cli",
"revision": "ee386baecc113eef2b8945df429120a5aec319ef",
"revisionTime": "2015-08-19T11:23:55-07:00"
},
{
"canonical": "github.com/minio/minio-go",
"comment": "",
- "local": "github.com/minio/minio-go",
- "revision": "d3dc9fd261cacbe64e4c0e5f3929e1fb846db42b",
- "revisionTime": "2015-08-21T20:20:57-07:00"
+ "local": "vendor/github.com/minio/minio-go",
+ "revision": "ca58a5b7e02c2e0adf5fb404df3545f0ddc45b29",
+ "revisionTime": "2015-08-22T15:40:20-07:00"
},
{
"canonical": "github.com/minio/minio/pkg/probe",
"comment": "",
- "local": "github.com/minio/minio/pkg/probe",
- "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
- "revisionTime": "2015-08-20T22:35:37-07:00"
+ "local": "vendor/github.com/minio/minio/pkg/probe",
+ "revision": "4d1f38d28cabcfa321e9d88acef67e16e7bafb2a",
+ "revisionTime": "2015-08-22T18:37:56-07:00"
},
{
"canonical": "github.com/minio/minio/pkg/quick",
"comment": "",
- "local": "github.com/minio/minio/pkg/quick",
- "revision": "5721d85c9a0e65ee65005e7da48c56612ae04ee3",
- "revisionTime": "2015-08-20T22:35:37-07:00"
+ "local": "vendor/github.com/minio/minio/pkg/quick",
+ "revision": "4d1f38d28cabcfa321e9d88acef67e16e7bafb2a",
+ "revisionTime": "2015-08-22T18:37:56-07:00"
},
{
"canonical": "github.com/minio/pb",
"comment": "",
- "local": "github.com/minio/pb",
+ "local": "vendor/github.com/minio/pb",
"revision": "6a97c3b0da073f974e0b8d1ac1bc42c0a7adca46",
"revisionTime": "2015-08-12T18:13:54-07:00"
},
{
"canonical": "github.com/olekukonko/ts",
"comment": "",
- "local": "github.com/olekukonko/ts",
+ "local": "vendor/github.com/olekukonko/ts",
"revision": "ecf753e7c962639ab5a1fb46f7da627d4c0a04b8",
"revisionTime": "2014-04-12T15:01:45-07:00"
},
{
"canonical": "github.com/shiena/ansicolor",
"comment": "",
- "local": "github.com/shiena/ansicolor",
+ "local": "vendor/github.com/shiena/ansicolor",
"revision": "a5e2b567a4dd6cc74545b8a4f27c9d63b9e7735b",
"revisionTime": "2015-07-19T16:15:31+09:00"
},
{
"canonical": "github.com/tchap/go-patricia/patricia",
"comment": "",
- "local": "github.com/tchap/go-patricia/patricia",
+ "local": "vendor/github.com/tchap/go-patricia/patricia",
"revision": "a560f85131e8aafc2cc4bcb1e265ae3fc6ee5f50",
"revisionTime": "2015-06-11T09:53:39+02:00"
},
{
"canonical": "gopkg.in/check.v1",
"comment": "",
- "local": "gopkg.in/check.v1",
+ "local": "vendor/gopkg.in/check.v1",
"revision": "11d3bc7aa68e238947792f30573146a3231fc0f1",
"revisionTime": "2015-07-29T10:04:31+02:00"
}
diff --git a/internal/github.com/dustin/go-humanize/LICENSE b/vendor/github.com/dustin/go-humanize/LICENSE
similarity index 100%
rename from internal/github.com/dustin/go-humanize/LICENSE
rename to vendor/github.com/dustin/go-humanize/LICENSE
diff --git a/internal/github.com/dustin/go-humanize/README.markdown b/vendor/github.com/dustin/go-humanize/README.markdown
similarity index 100%
rename from internal/github.com/dustin/go-humanize/README.markdown
rename to vendor/github.com/dustin/go-humanize/README.markdown
diff --git a/internal/github.com/dustin/go-humanize/big.go b/vendor/github.com/dustin/go-humanize/big.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/big.go
rename to vendor/github.com/dustin/go-humanize/big.go
diff --git a/internal/github.com/dustin/go-humanize/bigbytes.go b/vendor/github.com/dustin/go-humanize/bigbytes.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/bigbytes.go
rename to vendor/github.com/dustin/go-humanize/bigbytes.go
diff --git a/vendor/github.com/dustin/go-humanize/bigbytes_test.go b/vendor/github.com/dustin/go-humanize/bigbytes_test.go
new file mode 100644
index 00000000..da367d41
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/bigbytes_test.go
@@ -0,0 +1,219 @@
+package humanize
+
+import (
+ "math/big"
+ "testing"
+)
+
+func TestBigByteParsing(t *testing.T) {
+ tests := []struct {
+ in string
+ exp uint64
+ }{
+ {"42", 42},
+ {"42MB", 42000000},
+ {"42MiB", 44040192},
+ {"42mb", 42000000},
+ {"42mib", 44040192},
+ {"42MIB", 44040192},
+ {"42 MB", 42000000},
+ {"42 MiB", 44040192},
+ {"42 mb", 42000000},
+ {"42 mib", 44040192},
+ {"42 MIB", 44040192},
+ {"42.5MB", 42500000},
+ {"42.5MiB", 44564480},
+ {"42.5 MB", 42500000},
+ {"42.5 MiB", 44564480},
+ // No need to say B
+ {"42M", 42000000},
+ {"42Mi", 44040192},
+ {"42m", 42000000},
+ {"42mi", 44040192},
+ {"42MI", 44040192},
+ {"42 M", 42000000},
+ {"42 Mi", 44040192},
+ {"42 m", 42000000},
+ {"42 mi", 44040192},
+ {"42 MI", 44040192},
+ {"42.5M", 42500000},
+ {"42.5Mi", 44564480},
+ {"42.5 M", 42500000},
+ {"42.5 Mi", 44564480},
+ // Large testing, breaks when too much larger than
+ // this.
+ {"12.5 EB", uint64(12.5 * float64(EByte))},
+ {"12.5 E", uint64(12.5 * float64(EByte))},
+ {"12.5 EiB", uint64(12.5 * float64(EiByte))},
+ }
+
+ for _, p := range tests {
+ got, err := ParseBigBytes(p.in)
+ if err != nil {
+ t.Errorf("Couldn't parse %v: %v", p.in, err)
+ } else {
+ if got.Uint64() != p.exp {
+ t.Errorf("Expected %v for %v, got %v",
+ p.exp, p.in, got)
+ }
+ }
+ }
+}
+
+func TestBigByteErrors(t *testing.T) {
+ got, err := ParseBigBytes("84 JB")
+ if err == nil {
+ t.Errorf("Expected error, got %v", got)
+ }
+ got, err = ParseBigBytes("")
+ if err == nil {
+ t.Errorf("Expected error parsing nothing")
+ }
+}
+
+func bbyte(in uint64) string {
+ return BigBytes((&big.Int{}).SetUint64(in))
+}
+
+func bibyte(in uint64) string {
+ return BigIBytes((&big.Int{}).SetUint64(in))
+}
+
+func TestBigBytes(t *testing.T) {
+ testList{
+ {"bytes(0)", bbyte(0), "0B"},
+ {"bytes(1)", bbyte(1), "1B"},
+ {"bytes(803)", bbyte(803), "803B"},
+ {"bytes(999)", bbyte(999), "999B"},
+
+ {"bytes(1024)", bbyte(1024), "1.0kB"},
+ {"bytes(1MB - 1)", bbyte(MByte - Byte), "1000kB"},
+
+ {"bytes(1MB)", bbyte(1024 * 1024), "1.0MB"},
+ {"bytes(1GB - 1K)", bbyte(GByte - KByte), "1000MB"},
+
+ {"bytes(1GB)", bbyte(GByte), "1.0GB"},
+ {"bytes(1TB - 1M)", bbyte(TByte - MByte), "1000GB"},
+
+ {"bytes(1TB)", bbyte(TByte), "1.0TB"},
+ {"bytes(1PB - 1T)", bbyte(PByte - TByte), "999TB"},
+
+ {"bytes(1PB)", bbyte(PByte), "1.0PB"},
+ {"bytes(1PB - 1T)", bbyte(EByte - PByte), "999PB"},
+
+ {"bytes(1EB)", bbyte(EByte), "1.0EB"},
+ // Overflows.
+ // {"bytes(1EB - 1P)", Bytes((KByte*EByte)-PByte), "1023EB"},
+
+ {"bytes(0)", bibyte(0), "0B"},
+ {"bytes(1)", bibyte(1), "1B"},
+ {"bytes(803)", bibyte(803), "803B"},
+ {"bytes(1023)", bibyte(1023), "1023B"},
+
+ {"bytes(1024)", bibyte(1024), "1.0KiB"},
+ {"bytes(1MB - 1)", bibyte(MiByte - IByte), "1024KiB"},
+
+ {"bytes(1MB)", bibyte(1024 * 1024), "1.0MiB"},
+ {"bytes(1GB - 1K)", bibyte(GiByte - KiByte), "1024MiB"},
+
+ {"bytes(1GB)", bibyte(GiByte), "1.0GiB"},
+ {"bytes(1TB - 1M)", bibyte(TiByte - MiByte), "1024GiB"},
+
+ {"bytes(1TB)", bibyte(TiByte), "1.0TiB"},
+ {"bytes(1PB - 1T)", bibyte(PiByte - TiByte), "1023TiB"},
+
+ {"bytes(1PB)", bibyte(PiByte), "1.0PiB"},
+ {"bytes(1PB - 1T)", bibyte(EiByte - PiByte), "1023PiB"},
+
+ {"bytes(1EiB)", bibyte(EiByte), "1.0EiB"},
+ // Overflows.
+ // {"bytes(1EB - 1P)", bibyte((KIByte*EIByte)-PiByte), "1023EB"},
+
+ {"bytes(5.5GiB)", bibyte(5.5 * GiByte), "5.5GiB"},
+
+ {"bytes(5.5GB)", bbyte(5.5 * GByte), "5.5GB"},
+ }.validate(t)
+}
+
+func TestVeryBigBytes(t *testing.T) {
+ b, _ := (&big.Int{}).SetString("15347691069326346944512", 10)
+ s := BigBytes(b)
+ if s != "15ZB" {
+ t.Errorf("Expected 15ZB, got %v", s)
+ }
+ s = BigIBytes(b)
+ if s != "13ZiB" {
+ t.Errorf("Expected 13ZiB, got %v", s)
+ }
+
+ b, _ = (&big.Int{}).SetString("15716035654990179271180288", 10)
+ s = BigBytes(b)
+ if s != "16YB" {
+ t.Errorf("Expected 16YB, got %v", s)
+ }
+ s = BigIBytes(b)
+ if s != "13YiB" {
+ t.Errorf("Expected 13YiB, got %v", s)
+ }
+}
+
+func TestVeryVeryBigBytes(t *testing.T) {
+ b, _ := (&big.Int{}).SetString("16093220510709943573688614912", 10)
+ s := BigBytes(b)
+ if s != "16093YB" {
+ t.Errorf("Expected 16093YB, got %v", s)
+ }
+ s = BigIBytes(b)
+ if s != "13312YiB" {
+ t.Errorf("Expected 13312YiB, got %v", s)
+ }
+}
+
+func TestParseVeryBig(t *testing.T) {
+ tests := []struct {
+ in string
+ out string
+ }{
+ {"16ZB", "16000000000000000000000"},
+ {"16ZiB", "18889465931478580854784"},
+ {"16.5ZB", "16500000000000000000000"},
+ {"16.5ZiB", "19479761741837286506496"},
+ {"16Z", "16000000000000000000000"},
+ {"16Zi", "18889465931478580854784"},
+ {"16.5Z", "16500000000000000000000"},
+ {"16.5Zi", "19479761741837286506496"},
+
+ {"16YB", "16000000000000000000000000"},
+ {"16YiB", "19342813113834066795298816"},
+ {"16.5YB", "16500000000000000000000000"},
+ {"16.5YiB", "19947276023641381382651904"},
+ {"16Y", "16000000000000000000000000"},
+ {"16Yi", "19342813113834066795298816"},
+ {"16.5Y", "16500000000000000000000000"},
+ {"16.5Yi", "19947276023641381382651904"},
+ }
+
+ for _, test := range tests {
+ x, err := ParseBigBytes(test.in)
+ if err != nil {
+ t.Errorf("Error parsing %q: %v", test.in, err)
+ continue
+ }
+
+ if x.String() != test.out {
+ t.Errorf("Expected %q for %q, got %v", test.out, test.in, x)
+ }
+ }
+}
+
+func BenchmarkParseBigBytes(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ ParseBigBytes("16.5Z")
+ }
+}
+
+func BenchmarkBigBytes(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ bibyte(16.5 * GByte)
+ }
+}
diff --git a/internal/github.com/dustin/go-humanize/bytes.go b/vendor/github.com/dustin/go-humanize/bytes.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/bytes.go
rename to vendor/github.com/dustin/go-humanize/bytes.go
diff --git a/vendor/github.com/dustin/go-humanize/bytes_test.go b/vendor/github.com/dustin/go-humanize/bytes_test.go
new file mode 100644
index 00000000..7497fa00
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/bytes_test.go
@@ -0,0 +1,144 @@
+package humanize
+
+import (
+ "testing"
+)
+
+func TestByteParsing(t *testing.T) {
+ tests := []struct {
+ in string
+ exp uint64
+ }{
+ {"42", 42},
+ {"42MB", 42000000},
+ {"42MiB", 44040192},
+ {"42mb", 42000000},
+ {"42mib", 44040192},
+ {"42MIB", 44040192},
+ {"42 MB", 42000000},
+ {"42 MiB", 44040192},
+ {"42 mb", 42000000},
+ {"42 mib", 44040192},
+ {"42 MIB", 44040192},
+ {"42.5MB", 42500000},
+ {"42.5MiB", 44564480},
+ {"42.5 MB", 42500000},
+ {"42.5 MiB", 44564480},
+ // No need to say B
+ {"42M", 42000000},
+ {"42Mi", 44040192},
+ {"42m", 42000000},
+ {"42mi", 44040192},
+ {"42MI", 44040192},
+ {"42 M", 42000000},
+ {"42 Mi", 44040192},
+ {"42 m", 42000000},
+ {"42 mi", 44040192},
+ {"42 MI", 44040192},
+ {"42.5M", 42500000},
+ {"42.5Mi", 44564480},
+ {"42.5 M", 42500000},
+ {"42.5 Mi", 44564480},
+ // Large testing, breaks when too much larger than
+ // this.
+ {"12.5 EB", uint64(12.5 * float64(EByte))},
+ {"12.5 E", uint64(12.5 * float64(EByte))},
+ {"12.5 EiB", uint64(12.5 * float64(EiByte))},
+ }
+
+ for _, p := range tests {
+ got, err := ParseBytes(p.in)
+ if err != nil {
+ t.Errorf("Couldn't parse %v: %v", p.in, err)
+ }
+ if got != p.exp {
+ t.Errorf("Expected %v for %v, got %v",
+ p.exp, p.in, got)
+ }
+ }
+}
+
+func TestByteErrors(t *testing.T) {
+ got, err := ParseBytes("84 JB")
+ if err == nil {
+ t.Errorf("Expected error, got %v", got)
+ }
+ got, err = ParseBytes("")
+ if err == nil {
+ t.Errorf("Expected error parsing nothing")
+ }
+ got, err = ParseBytes("16 EiB")
+ if err == nil {
+ t.Errorf("Expected error, got %v", got)
+ }
+}
+
+func TestBytes(t *testing.T) {
+ testList{
+ {"bytes(0)", Bytes(0), "0B"},
+ {"bytes(1)", Bytes(1), "1B"},
+ {"bytes(803)", Bytes(803), "803B"},
+ {"bytes(999)", Bytes(999), "999B"},
+
+ {"bytes(1024)", Bytes(1024), "1.0kB"},
+ {"bytes(9999)", Bytes(9999), "10kB"},
+ {"bytes(1MB - 1)", Bytes(MByte - Byte), "1000kB"},
+
+ {"bytes(1MB)", Bytes(1024 * 1024), "1.0MB"},
+ {"bytes(1GB - 1K)", Bytes(GByte - KByte), "1000MB"},
+
+ {"bytes(1GB)", Bytes(GByte), "1.0GB"},
+ {"bytes(1TB - 1M)", Bytes(TByte - MByte), "1000GB"},
+ {"bytes(10MB)", Bytes(9999 * 1000), "10MB"},
+
+ {"bytes(1TB)", Bytes(TByte), "1.0TB"},
+ {"bytes(1PB - 1T)", Bytes(PByte - TByte), "999TB"},
+
+ {"bytes(1PB)", Bytes(PByte), "1.0PB"},
+ {"bytes(1PB - 1T)", Bytes(EByte - PByte), "999PB"},
+
+ {"bytes(1EB)", Bytes(EByte), "1.0EB"},
+ // Overflows.
+ // {"bytes(1EB - 1P)", Bytes((KByte*EByte)-PByte), "1023EB"},
+
+ {"bytes(0)", IBytes(0), "0B"},
+ {"bytes(1)", IBytes(1), "1B"},
+ {"bytes(803)", IBytes(803), "803B"},
+ {"bytes(1023)", IBytes(1023), "1023B"},
+
+ {"bytes(1024)", IBytes(1024), "1.0KiB"},
+ {"bytes(1MB - 1)", IBytes(MiByte - IByte), "1024KiB"},
+
+ {"bytes(1MB)", IBytes(1024 * 1024), "1.0MiB"},
+ {"bytes(1GB - 1K)", IBytes(GiByte - KiByte), "1024MiB"},
+
+ {"bytes(1GB)", IBytes(GiByte), "1.0GiB"},
+ {"bytes(1TB - 1M)", IBytes(TiByte - MiByte), "1024GiB"},
+
+ {"bytes(1TB)", IBytes(TiByte), "1.0TiB"},
+ {"bytes(1PB - 1T)", IBytes(PiByte - TiByte), "1023TiB"},
+
+ {"bytes(1PB)", IBytes(PiByte), "1.0PiB"},
+ {"bytes(1PB - 1T)", IBytes(EiByte - PiByte), "1023PiB"},
+
+ {"bytes(1EiB)", IBytes(EiByte), "1.0EiB"},
+ // Overflows.
+ // {"bytes(1EB - 1P)", IBytes((KIByte*EIByte)-PiByte), "1023EB"},
+
+ {"bytes(5.5GiB)", IBytes(5.5 * GiByte), "5.5GiB"},
+
+ {"bytes(5.5GB)", Bytes(5.5 * GByte), "5.5GB"},
+ }.validate(t)
+}
+
+func BenchmarkParseBytes(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ ParseBytes("16.5GB")
+ }
+}
+
+func BenchmarkBytes(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ Bytes(16.5 * GByte)
+ }
+}
diff --git a/internal/github.com/dustin/go-humanize/comma.go b/vendor/github.com/dustin/go-humanize/comma.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/comma.go
rename to vendor/github.com/dustin/go-humanize/comma.go
diff --git a/vendor/github.com/dustin/go-humanize/comma_test.go b/vendor/github.com/dustin/go-humanize/comma_test.go
new file mode 100644
index 00000000..49040fb7
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/comma_test.go
@@ -0,0 +1,134 @@
+package humanize
+
+import (
+ "math"
+ "math/big"
+ "testing"
+)
+
+func TestCommas(t *testing.T) {
+ testList{
+ {"0", Comma(0), "0"},
+ {"10", Comma(10), "10"},
+ {"100", Comma(100), "100"},
+ {"1,000", Comma(1000), "1,000"},
+ {"10,000", Comma(10000), "10,000"},
+ {"100,000", Comma(100000), "100,000"},
+ {"10,000,000", Comma(10000000), "10,000,000"},
+ {"10,100,000", Comma(10100000), "10,100,000"},
+ {"10,010,000", Comma(10010000), "10,010,000"},
+ {"10,001,000", Comma(10001000), "10,001,000"},
+ {"123,456,789", Comma(123456789), "123,456,789"},
+ {"maxint", Comma(9.223372e+18), "9,223,372,000,000,000,000"},
+ {"minint", Comma(-9.223372e+18), "-9,223,372,000,000,000,000"},
+ {"-123,456,789", Comma(-123456789), "-123,456,789"},
+ {"-10,100,000", Comma(-10100000), "-10,100,000"},
+ {"-10,010,000", Comma(-10010000), "-10,010,000"},
+ {"-10,001,000", Comma(-10001000), "-10,001,000"},
+ {"-10,000,000", Comma(-10000000), "-10,000,000"},
+ {"-100,000", Comma(-100000), "-100,000"},
+ {"-10,000", Comma(-10000), "-10,000"},
+ {"-1,000", Comma(-1000), "-1,000"},
+ {"-100", Comma(-100), "-100"},
+ {"-10", Comma(-10), "-10"},
+ }.validate(t)
+}
+
+func TestCommafs(t *testing.T) {
+ testList{
+ {"0", Commaf(0), "0"},
+ {"10.11", Commaf(10.11), "10.11"},
+ {"100", Commaf(100), "100"},
+ {"1,000", Commaf(1000), "1,000"},
+ {"10,000", Commaf(10000), "10,000"},
+ {"100,000", Commaf(100000), "100,000"},
+ {"834,142.32", Commaf(834142.32), "834,142.32"},
+ {"10,000,000", Commaf(10000000), "10,000,000"},
+ {"10,100,000", Commaf(10100000), "10,100,000"},
+ {"10,010,000", Commaf(10010000), "10,010,000"},
+ {"10,001,000", Commaf(10001000), "10,001,000"},
+ {"123,456,789", Commaf(123456789), "123,456,789"},
+ {"maxf64", Commaf(math.MaxFloat64), "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000"},
+ {"minf64", Commaf(math.SmallestNonzeroFloat64), "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005"},
+ {"-123,456,789", Commaf(-123456789), "-123,456,789"},
+ {"-10,100,000", Commaf(-10100000), "-10,100,000"},
+ {"-10,010,000", Commaf(-10010000), "-10,010,000"},
+ {"-10,001,000", Commaf(-10001000), "-10,001,000"},
+ {"-10,000,000", Commaf(-10000000), "-10,000,000"},
+ {"-100,000", Commaf(-100000), "-100,000"},
+ {"-10,000", Commaf(-10000), "-10,000"},
+ {"-1,000", Commaf(-1000), "-1,000"},
+ {"-100.11", Commaf(-100.11), "-100.11"},
+ {"-10", Commaf(-10), "-10"},
+ }.validate(t)
+}
+
+func BenchmarkCommas(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ Comma(1234567890)
+ }
+}
+
+func BenchmarkCommaf(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ Commaf(1234567890.83584)
+ }
+}
+
+func BenchmarkBigCommas(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ BigComma(big.NewInt(1234567890))
+ }
+}
+
+func bigComma(i int64) string {
+ return BigComma(big.NewInt(i))
+}
+
+func TestBigCommas(t *testing.T) {
+ testList{
+ {"0", bigComma(0), "0"},
+ {"10", bigComma(10), "10"},
+ {"100", bigComma(100), "100"},
+ {"1,000", bigComma(1000), "1,000"},
+ {"10,000", bigComma(10000), "10,000"},
+ {"100,000", bigComma(100000), "100,000"},
+ {"10,000,000", bigComma(10000000), "10,000,000"},
+ {"10,100,000", bigComma(10100000), "10,100,000"},
+ {"10,010,000", bigComma(10010000), "10,010,000"},
+ {"10,001,000", bigComma(10001000), "10,001,000"},
+ {"123,456,789", bigComma(123456789), "123,456,789"},
+ {"maxint", bigComma(9.223372e+18), "9,223,372,000,000,000,000"},
+ {"minint", bigComma(-9.223372e+18), "-9,223,372,000,000,000,000"},
+ {"-123,456,789", bigComma(-123456789), "-123,456,789"},
+ {"-10,100,000", bigComma(-10100000), "-10,100,000"},
+ {"-10,010,000", bigComma(-10010000), "-10,010,000"},
+ {"-10,001,000", bigComma(-10001000), "-10,001,000"},
+ {"-10,000,000", bigComma(-10000000), "-10,000,000"},
+ {"-100,000", bigComma(-100000), "-100,000"},
+ {"-10,000", bigComma(-10000), "-10,000"},
+ {"-1,000", bigComma(-1000), "-1,000"},
+ {"-100", bigComma(-100), "-100"},
+ {"-10", bigComma(-10), "-10"},
+ }.validate(t)
+}
+
+func TestVeryBigCommas(t *testing.T) {
+ tests := []struct{ in, exp string }{
+ {
+ "84889279597249724975972597249849757294578485",
+ "84,889,279,597,249,724,975,972,597,249,849,757,294,578,485",
+ },
+ {
+ "-84889279597249724975972597249849757294578485",
+ "-84,889,279,597,249,724,975,972,597,249,849,757,294,578,485",
+ },
+ }
+ for _, test := range tests {
+ n, _ := (&big.Int{}).SetString(test.in, 10)
+ got := BigComma(n)
+ if test.exp != got {
+ t.Errorf("Expected %q, got %q", test.exp, got)
+ }
+ }
+}
diff --git a/vendor/github.com/dustin/go-humanize/common_test.go b/vendor/github.com/dustin/go-humanize/common_test.go
new file mode 100644
index 00000000..fc7db151
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/common_test.go
@@ -0,0 +1,18 @@
+package humanize
+
+import (
+ "testing"
+)
+
+type testList []struct {
+ name, got, exp string
+}
+
+func (tl testList) validate(t *testing.T) {
+ for _, test := range tl {
+ if test.got != test.exp {
+ t.Errorf("On %v, expected '%v', but got '%v'",
+ test.name, test.exp, test.got)
+ }
+ }
+}
diff --git a/internal/github.com/dustin/go-humanize/ftoa.go b/vendor/github.com/dustin/go-humanize/ftoa.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/ftoa.go
rename to vendor/github.com/dustin/go-humanize/ftoa.go
diff --git a/vendor/github.com/dustin/go-humanize/ftoa_test.go b/vendor/github.com/dustin/go-humanize/ftoa_test.go
new file mode 100644
index 00000000..40d13bd7
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/ftoa_test.go
@@ -0,0 +1,55 @@
+package humanize
+
+import (
+ "fmt"
+ "regexp"
+ "strconv"
+ "testing"
+)
+
+func TestFtoa(t *testing.T) {
+ testList{
+ {"200", Ftoa(200), "200"},
+ {"2", Ftoa(2), "2"},
+ {"2.2", Ftoa(2.2), "2.2"},
+ {"2.02", Ftoa(2.02), "2.02"},
+ {"200.02", Ftoa(200.02), "200.02"},
+ }.validate(t)
+}
+
+func BenchmarkFtoaRegexTrailing(b *testing.B) {
+ trailingZerosRegex := regexp.MustCompile(`\.?0+$`)
+
+ b.ResetTimer()
+ for i := 0; i < b.N; i++ {
+ trailingZerosRegex.ReplaceAllString("2.00000", "")
+ trailingZerosRegex.ReplaceAllString("2.0000", "")
+ trailingZerosRegex.ReplaceAllString("2.000", "")
+ trailingZerosRegex.ReplaceAllString("2.00", "")
+ trailingZerosRegex.ReplaceAllString("2.0", "")
+ trailingZerosRegex.ReplaceAllString("2", "")
+ }
+}
+
+func BenchmarkFtoaFunc(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ stripTrailingZeros("2.00000")
+ stripTrailingZeros("2.0000")
+ stripTrailingZeros("2.000")
+ stripTrailingZeros("2.00")
+ stripTrailingZeros("2.0")
+ stripTrailingZeros("2")
+ }
+}
+
+func BenchmarkFmtF(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ fmt.Sprintf("%f", 2.03584)
+ }
+}
+
+func BenchmarkStrconvF(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ strconv.FormatFloat(2.03584, 'f', 6, 64)
+ }
+}
diff --git a/internal/github.com/dustin/go-humanize/humanize.go b/vendor/github.com/dustin/go-humanize/humanize.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/humanize.go
rename to vendor/github.com/dustin/go-humanize/humanize.go
diff --git a/internal/github.com/dustin/go-humanize/number.go b/vendor/github.com/dustin/go-humanize/number.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/number.go
rename to vendor/github.com/dustin/go-humanize/number.go
diff --git a/vendor/github.com/dustin/go-humanize/number_test.go b/vendor/github.com/dustin/go-humanize/number_test.go
new file mode 100644
index 00000000..dd38a5bb
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/number_test.go
@@ -0,0 +1,78 @@
+package humanize
+
+import (
+ "math"
+ "testing"
+)
+
+type TestStruct struct {
+ name string
+ format string
+ num float64
+ formatted string
+}
+
+func TestFormatFloat(t *testing.T) {
+ tests := []TestStruct{
+ {"default", "", 12345.6789, "12,345.68"},
+ {"#", "#", 12345.6789, "12345.678900000"},
+ {"#.", "#.", 12345.6789, "12346"},
+ {"#,#", "#,#", 12345.6789, "12345,7"},
+ {"#,##", "#,##", 12345.6789, "12345,68"},
+ {"#,###", "#,###", 12345.6789, "12345,679"},
+ {"#,###.", "#,###.", 12345.6789, "12,346"},
+ {"#,###.##", "#,###.##", 12345.6789, "12,345.68"},
+ {"#,###.###", "#,###.###", 12345.6789, "12,345.679"},
+ {"#,###.####", "#,###.####", 12345.6789, "12,345.6789"},
+ {"#.###,######", "#.###,######", 12345.6789, "12.345,678900"},
+ {"#\u202f###,##", "#\u202f###,##", 12345.6789, "12 345,68"},
+
+ // special cases
+ {"NaN", "#", math.NaN(), "NaN"},
+ {"+Inf", "#", math.Inf(1), "Infinity"},
+ {"-Inf", "#", math.Inf(-1), "-Infinity"},
+ {"signStr <= -0.000000001", "", -0.000000002, "-0.00"},
+ {"signStr = 0", "", 0, "0.00"},
+ {"Format directive must start with +", "+000", 12345.6789, "+12345.678900000"},
+ }
+
+ for _, test := range tests {
+ got := FormatFloat(test.format, test.num)
+ if got != test.formatted {
+ t.Errorf("On %v (%v, %v), got %v, wanted %v",
+ test.name, test.format, test.num, got, test.formatted)
+ }
+ }
+ // Test a single integer
+ got := FormatInteger("#", 12345)
+ if got != "12345.000000000" {
+ t.Errorf("On %v (%v, %v), got %v, wanted %v",
+ "integerTest", "#", 12345, got, "12345.000000000")
+ }
+ // Test the things that could panic
+ panictests := []TestStruct{
+ {"RenderFloat(): invalid positive sign directive", "-", 12345.6789, "12,345.68"},
+ {"RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers", "0.01", 12345.6789, "12,345.68"},
+ }
+ for _, test := range panictests {
+ didPanic := false
+ var message interface{}
+ func() {
+
+ defer func() {
+ if message = recover(); message != nil {
+ didPanic = true
+ }
+ }()
+
+ // call the target function
+ _ = FormatFloat(test.format, test.num)
+
+ }()
+ if didPanic != true {
+ t.Errorf("On %v, should have panic and did not.",
+ test.name)
+ }
+ }
+
+}
diff --git a/internal/github.com/dustin/go-humanize/ordinals.go b/vendor/github.com/dustin/go-humanize/ordinals.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/ordinals.go
rename to vendor/github.com/dustin/go-humanize/ordinals.go
diff --git a/vendor/github.com/dustin/go-humanize/ordinals_test.go b/vendor/github.com/dustin/go-humanize/ordinals_test.go
new file mode 100644
index 00000000..51d85ee7
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/ordinals_test.go
@@ -0,0 +1,22 @@
+package humanize
+
+import (
+ "testing"
+)
+
+func TestOrdinals(t *testing.T) {
+ testList{
+ {"0", Ordinal(0), "0th"},
+ {"1", Ordinal(1), "1st"},
+ {"2", Ordinal(2), "2nd"},
+ {"3", Ordinal(3), "3rd"},
+ {"4", Ordinal(4), "4th"},
+ {"10", Ordinal(10), "10th"},
+ {"11", Ordinal(11), "11th"},
+ {"12", Ordinal(12), "12th"},
+ {"13", Ordinal(13), "13th"},
+ {"101", Ordinal(101), "101st"},
+ {"102", Ordinal(102), "102nd"},
+ {"103", Ordinal(103), "103rd"},
+ }.validate(t)
+}
diff --git a/internal/github.com/dustin/go-humanize/si.go b/vendor/github.com/dustin/go-humanize/si.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/si.go
rename to vendor/github.com/dustin/go-humanize/si.go
diff --git a/vendor/github.com/dustin/go-humanize/si_test.go b/vendor/github.com/dustin/go-humanize/si_test.go
new file mode 100644
index 00000000..32fb386b
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/si_test.go
@@ -0,0 +1,98 @@
+package humanize
+
+import (
+ "math"
+ "testing"
+)
+
+func TestSI(t *testing.T) {
+ tests := []struct {
+ name string
+ num float64
+ formatted string
+ }{
+ {"e-24", 1e-24, "1yF"},
+ {"e-21", 1e-21, "1zF"},
+ {"e-18", 1e-18, "1aF"},
+ {"e-15", 1e-15, "1fF"},
+ {"e-12", 1e-12, "1pF"},
+ {"e-12", 2.2345e-12, "2.2345pF"},
+ {"e-12", 2.23e-12, "2.23pF"},
+ {"e-11", 2.23e-11, "22.3pF"},
+ {"e-10", 2.2e-10, "220pF"},
+ {"e-9", 2.2e-9, "2.2nF"},
+ {"e-8", 2.2e-8, "22nF"},
+ {"e-7", 2.2e-7, "220nF"},
+ {"e-6", 2.2e-6, "2.2µF"},
+ {"e-6", 1e-6, "1µF"},
+ {"e-5", 2.2e-5, "22µF"},
+ {"e-4", 2.2e-4, "220µF"},
+ {"e-3", 2.2e-3, "2.2mF"},
+ {"e-2", 2.2e-2, "22mF"},
+ {"e-1", 2.2e-1, "220mF"},
+ {"e+0", 2.2e-0, "2.2F"},
+ {"e+0", 2.2, "2.2F"},
+ {"e+1", 2.2e+1, "22F"},
+ {"0", 0, "0F"},
+ {"e+1", 22, "22F"},
+ {"e+2", 2.2e+2, "220F"},
+ {"e+2", 220, "220F"},
+ {"e+3", 2.2e+3, "2.2kF"},
+ {"e+3", 2200, "2.2kF"},
+ {"e+4", 2.2e+4, "22kF"},
+ {"e+4", 22000, "22kF"},
+ {"e+5", 2.2e+5, "220kF"},
+ {"e+6", 2.2e+6, "2.2MF"},
+ {"e+6", 1e+6, "1MF"},
+ {"e+7", 2.2e+7, "22MF"},
+ {"e+8", 2.2e+8, "220MF"},
+ {"e+9", 2.2e+9, "2.2GF"},
+ {"e+10", 2.2e+10, "22GF"},
+ {"e+11", 2.2e+11, "220GF"},
+ {"e+12", 2.2e+12, "2.2TF"},
+ {"e+15", 2.2e+15, "2.2PF"},
+ {"e+18", 2.2e+18, "2.2EF"},
+ {"e+21", 2.2e+21, "2.2ZF"},
+ {"e+24", 2.2e+24, "2.2YF"},
+
+ // special case
+ {"1F", 1000 * 1000, "1MF"},
+ {"1F", 1e6, "1MF"},
+ }
+
+ for _, test := range tests {
+ got := SI(test.num, "F")
+ if got != test.formatted {
+ t.Errorf("On %v (%v), got %v, wanted %v",
+ test.name, test.num, got, test.formatted)
+ }
+
+ gotf, gotu, err := ParseSI(test.formatted)
+ if err != nil {
+ t.Errorf("Error parsing %v (%v): %v", test.name, test.formatted, err)
+ continue
+ }
+
+ if math.Abs(1-(gotf/test.num)) > 0.01 {
+ t.Errorf("On %v (%v), got %v, wanted %v (±%v)",
+ test.name, test.formatted, gotf, test.num,
+ math.Abs(1-(gotf/test.num)))
+ }
+ if gotu != "F" {
+ t.Errorf("On %v (%v), expected unit F, got %v",
+ test.name, test.formatted, gotu)
+ }
+ }
+
+ // Parse error
+ gotf, gotu, err := ParseSI("x1.21JW") // 1.21 jigga whats
+ if err == nil {
+ t.Errorf("Expected error on x1.21JW, got %v %v", gotf, gotu)
+ }
+}
+
+func BenchmarkParseSI(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ ParseSI("2.2346ZB")
+ }
+}
diff --git a/internal/github.com/dustin/go-humanize/times.go b/vendor/github.com/dustin/go-humanize/times.go
similarity index 100%
rename from internal/github.com/dustin/go-humanize/times.go
rename to vendor/github.com/dustin/go-humanize/times.go
diff --git a/vendor/github.com/dustin/go-humanize/times_test.go b/vendor/github.com/dustin/go-humanize/times_test.go
new file mode 100644
index 00000000..528daa4e
--- /dev/null
+++ b/vendor/github.com/dustin/go-humanize/times_test.go
@@ -0,0 +1,71 @@
+package humanize
+
+import (
+ "math"
+ "testing"
+ "time"
+)
+
+func TestPast(t *testing.T) {
+ now := time.Now().Unix()
+ testList{
+ {"now", Time(time.Unix(now, 0)), "now"},
+ {"1 second ago", Time(time.Unix(now-1, 0)), "1 second ago"},
+ {"12 seconds ago", Time(time.Unix(now-12, 0)), "12 seconds ago"},
+ {"30 seconds ago", Time(time.Unix(now-30, 0)), "30 seconds ago"},
+ {"45 seconds ago", Time(time.Unix(now-45, 0)), "45 seconds ago"},
+ {"1 minute ago", Time(time.Unix(now-63, 0)), "1 minute ago"},
+ {"15 minutes ago", Time(time.Unix(now-15*Minute, 0)), "15 minutes ago"},
+ {"1 hour ago", Time(time.Unix(now-63*Minute, 0)), "1 hour ago"},
+ {"2 hours ago", Time(time.Unix(now-2*Hour, 0)), "2 hours ago"},
+ {"21 hours ago", Time(time.Unix(now-21*Hour, 0)), "21 hours ago"},
+ {"1 day ago", Time(time.Unix(now-26*Hour, 0)), "1 day ago"},
+ {"2 days ago", Time(time.Unix(now-49*Hour, 0)), "2 days ago"},
+ {"3 days ago", Time(time.Unix(now-3*Day, 0)), "3 days ago"},
+ {"1 week ago (1)", Time(time.Unix(now-7*Day, 0)), "1 week ago"},
+ {"1 week ago (2)", Time(time.Unix(now-12*Day, 0)), "1 week ago"},
+ {"2 weeks ago", Time(time.Unix(now-15*Day, 0)), "2 weeks ago"},
+ {"1 month ago", Time(time.Unix(now-39*Day, 0)), "1 month ago"},
+ {"3 months ago", Time(time.Unix(now-99*Day, 0)), "3 months ago"},
+ {"1 year ago (1)", Time(time.Unix(now-365*Day, 0)), "1 year ago"},
+ {"1 year ago (1)", Time(time.Unix(now-400*Day, 0)), "1 year ago"},
+ {"2 years ago (1)", Time(time.Unix(now-548*Day, 0)), "2 years ago"},
+ {"2 years ago (2)", Time(time.Unix(now-725*Day, 0)), "2 years ago"},
+ {"2 years ago (3)", Time(time.Unix(now-800*Day, 0)), "2 years ago"},
+ {"3 years ago", Time(time.Unix(now-3*Year, 0)), "3 years ago"},
+ {"long ago", Time(time.Unix(now-LongTime, 0)), "a long while ago"},
+ }.validate(t)
+}
+
+func TestFuture(t *testing.T) {
+ now := time.Now().Unix()
+ testList{
+ {"now", Time(time.Unix(now, 0)), "now"},
+ {"1 second from now", Time(time.Unix(now+1, 0)), "1 second from now"},
+ {"12 seconds from now", Time(time.Unix(now+12, 0)), "12 seconds from now"},
+ {"30 seconds from now", Time(time.Unix(now+30, 0)), "30 seconds from now"},
+ {"45 seconds from now", Time(time.Unix(now+45, 0)), "45 seconds from now"},
+ {"15 minutes from now", Time(time.Unix(now+15*Minute, 0)), "15 minutes from now"},
+ {"2 hours from now", Time(time.Unix(now+2*Hour, 0)), "2 hours from now"},
+ {"21 hours from now", Time(time.Unix(now+21*Hour, 0)), "21 hours from now"},
+ {"1 day from now", Time(time.Unix(now+26*Hour, 0)), "1 day from now"},
+ {"2 days from now", Time(time.Unix(now+49*Hour, 0)), "2 days from now"},
+ {"3 days from now", Time(time.Unix(now+3*Day, 0)), "3 days from now"},
+ {"1 week from now (1)", Time(time.Unix(now+7*Day, 0)), "1 week from now"},
+ {"1 week from now (2)", Time(time.Unix(now+12*Day, 0)), "1 week from now"},
+ {"2 weeks from now", Time(time.Unix(now+15*Day, 0)), "2 weeks from now"},
+ {"1 month from now", Time(time.Unix(now+30*Day, 0)), "1 month from now"},
+ {"1 year from now", Time(time.Unix(now+365*Day, 0)), "1 year from now"},
+ {"2 years from now", Time(time.Unix(now+2*Year, 0)), "2 years from now"},
+ {"a while from now", Time(time.Unix(now+LongTime, 0)), "a long while from now"},
+ }.validate(t)
+}
+
+func TestRange(t *testing.T) {
+ start := time.Time{}
+ end := time.Unix(math.MaxInt64, math.MaxInt64)
+ x := RelTime(start, end, "ago", "from now")
+ if x != "a long while from now" {
+ t.Errorf("Expected a long while from now, got %q", x)
+ }
+}
diff --git a/internal/github.com/fatih/color/LICENSE.md b/vendor/github.com/fatih/color/LICENSE.md
similarity index 100%
rename from internal/github.com/fatih/color/LICENSE.md
rename to vendor/github.com/fatih/color/LICENSE.md
diff --git a/internal/github.com/fatih/color/README.md b/vendor/github.com/fatih/color/README.md
similarity index 100%
rename from internal/github.com/fatih/color/README.md
rename to vendor/github.com/fatih/color/README.md
diff --git a/internal/github.com/fatih/color/color.go b/vendor/github.com/fatih/color/color.go
similarity index 98%
rename from internal/github.com/fatih/color/color.go
rename to vendor/github.com/fatih/color/color.go
index 7da09172..c4a10c3c 100644
--- a/internal/github.com/fatih/color/color.go
+++ b/vendor/github.com/fatih/color/color.go
@@ -6,8 +6,8 @@ import (
"strconv"
"strings"
- "github.com/minio/mc/internal/github.com/mattn/go-isatty"
- "github.com/minio/mc/internal/github.com/shiena/ansicolor"
+ "github.com/mattn/go-isatty"
+ "github.com/shiena/ansicolor"
)
// NoColor defines if the output is colorized or not. It's dynamically set to
diff --git a/vendor/github.com/fatih/color/color_test.go b/vendor/github.com/fatih/color/color_test.go
new file mode 100644
index 00000000..a1192b55
--- /dev/null
+++ b/vendor/github.com/fatih/color/color_test.go
@@ -0,0 +1,176 @@
+package color
+
+import (
+ "bytes"
+ "fmt"
+ "os"
+ "testing"
+
+ "github.com/shiena/ansicolor"
+)
+
+// Testing colors is kinda different. First we test for given colors and their
+// escaped formatted results. Next we create some visual tests to be tested.
+// Each visual test includes the color name to be compared.
+func TestColor(t *testing.T) {
+ rb := new(bytes.Buffer)
+ Output = rb
+
+ testColors := []struct {
+ text string
+ code Attribute
+ }{
+ {text: "black", code: FgBlack},
+ {text: "red", code: FgRed},
+ {text: "green", code: FgGreen},
+ {text: "yellow", code: FgYellow},
+ {text: "blue", code: FgBlue},
+ {text: "magent", code: FgMagenta},
+ {text: "cyan", code: FgCyan},
+ {text: "white", code: FgWhite},
+ }
+
+ for _, c := range testColors {
+ New(c.code).Print(c.text)
+
+ line, _ := rb.ReadString('\n')
+ scannedLine := fmt.Sprintf("%q", line)
+ colored := fmt.Sprintf("\x1b[%dm%s\x1b[0m", c.code, c.text)
+ escapedForm := fmt.Sprintf("%q", colored)
+
+ fmt.Printf("%s\t: %s\n", c.text, line)
+
+ if scannedLine != escapedForm {
+ t.Errorf("Expecting %s, got '%s'\n", escapedForm, scannedLine)
+ }
+ }
+}
+
+func TestNoColor(t *testing.T) {
+ rb := new(bytes.Buffer)
+ Output = rb
+
+ testColors := []struct {
+ text string
+ code Attribute
+ }{
+ {text: "black", code: FgBlack},
+ {text: "red", code: FgRed},
+ {text: "green", code: FgGreen},
+ {text: "yellow", code: FgYellow},
+ {text: "blue", code: FgBlue},
+ {text: "magent", code: FgMagenta},
+ {text: "cyan", code: FgCyan},
+ {text: "white", code: FgWhite},
+ }
+
+ for _, c := range testColors {
+ p := New(c.code)
+ p.DisableColor()
+ p.Print(c.text)
+
+ line, _ := rb.ReadString('\n')
+ if line != c.text {
+ t.Errorf("Expecting %s, got '%s'\n", c.text, line)
+ }
+ }
+
+ // global check
+ NoColor = true
+ defer func() {
+ NoColor = false
+ }()
+ for _, c := range testColors {
+ p := New(c.code)
+ p.Print(c.text)
+
+ line, _ := rb.ReadString('\n')
+ if line != c.text {
+ t.Errorf("Expecting %s, got '%s'\n", c.text, line)
+ }
+ }
+
+}
+
+func TestColorVisual(t *testing.T) {
+ // First Visual Test
+ fmt.Println("")
+ Output = ansicolor.NewAnsiColorWriter(os.Stdout)
+
+ New(FgRed).Printf("red\t")
+ New(BgRed).Print(" ")
+ New(FgRed, Bold).Println(" red")
+
+ New(FgGreen).Printf("green\t")
+ New(BgGreen).Print(" ")
+ New(FgGreen, Bold).Println(" green")
+
+ New(FgYellow).Printf("yellow\t")
+ New(BgYellow).Print(" ")
+ New(FgYellow, Bold).Println(" yellow")
+
+ New(FgBlue).Printf("blue\t")
+ New(BgBlue).Print(" ")
+ New(FgBlue, Bold).Println(" blue")
+
+ New(FgMagenta).Printf("magenta\t")
+ New(BgMagenta).Print(" ")
+ New(FgMagenta, Bold).Println(" magenta")
+
+ New(FgCyan).Printf("cyan\t")
+ New(BgCyan).Print(" ")
+ New(FgCyan, Bold).Println(" cyan")
+
+ New(FgWhite).Printf("white\t")
+ New(BgWhite).Print(" ")
+ New(FgWhite, Bold).Println(" white")
+ fmt.Println("")
+
+ // Second Visual test
+ Black("black")
+ Red("red")
+ Green("green")
+ Yellow("yellow")
+ Blue("blue")
+ Magenta("magenta")
+ Cyan("cyan")
+ White("white")
+
+ // Third visual test
+ fmt.Println()
+ Set(FgBlue)
+ fmt.Println("is this blue?")
+ Unset()
+
+ Set(FgMagenta)
+ fmt.Println("and this magenta?")
+ Unset()
+
+ // Fourth Visual test
+ fmt.Println()
+ blue := New(FgBlue).PrintlnFunc()
+ blue("blue text with custom print func")
+
+ red := New(FgRed).PrintfFunc()
+ red("red text with a printf func: %d\n", 123)
+
+ put := New(FgYellow).SprintFunc()
+ warn := New(FgRed).SprintFunc()
+
+ fmt.Fprintf(Output, "this is a %s and this is %s.\n", put("warning"), warn("error"))
+
+ info := New(FgWhite, BgGreen).SprintFunc()
+ fmt.Fprintf(Output, "this %s rocks!\n", info("package"))
+
+ // Fifth Visual Test
+ fmt.Println()
+
+ fmt.Fprintln(Output, BlackString("black"))
+ fmt.Fprintln(Output, RedString("red"))
+ fmt.Fprintln(Output, GreenString("green"))
+ fmt.Fprintln(Output, YellowString("yellow"))
+ fmt.Fprintln(Output, BlueString("blue"))
+ fmt.Fprintln(Output, MagentaString("magenta"))
+ fmt.Fprintln(Output, CyanString("cyan"))
+ fmt.Fprintln(Output, WhiteString("white"))
+}
diff --git a/internal/github.com/fatih/color/doc.go b/vendor/github.com/fatih/color/doc.go
similarity index 100%
rename from internal/github.com/fatih/color/doc.go
rename to vendor/github.com/fatih/color/doc.go
diff --git a/internal/github.com/fatih/structs/LICENSE b/vendor/github.com/fatih/structs/LICENSE
similarity index 100%
rename from internal/github.com/fatih/structs/LICENSE
rename to vendor/github.com/fatih/structs/LICENSE
diff --git a/internal/github.com/fatih/structs/README.md b/vendor/github.com/fatih/structs/README.md
similarity index 100%
rename from internal/github.com/fatih/structs/README.md
rename to vendor/github.com/fatih/structs/README.md
diff --git a/internal/github.com/fatih/structs/field.go b/vendor/github.com/fatih/structs/field.go
similarity index 100%
rename from internal/github.com/fatih/structs/field.go
rename to vendor/github.com/fatih/structs/field.go
diff --git a/internal/github.com/fatih/structs/structs.go b/vendor/github.com/fatih/structs/structs.go
similarity index 100%
rename from internal/github.com/fatih/structs/structs.go
rename to vendor/github.com/fatih/structs/structs.go
diff --git a/internal/github.com/fatih/structs/tags.go b/vendor/github.com/fatih/structs/tags.go
similarity index 100%
rename from internal/github.com/fatih/structs/tags.go
rename to vendor/github.com/fatih/structs/tags.go
diff --git a/internal/github.com/mattn/go-isatty/LICENSE b/vendor/github.com/mattn/go-isatty/LICENSE
similarity index 100%
rename from internal/github.com/mattn/go-isatty/LICENSE
rename to vendor/github.com/mattn/go-isatty/LICENSE
diff --git a/internal/github.com/mattn/go-isatty/README.md b/vendor/github.com/mattn/go-isatty/README.md
similarity index 100%
rename from internal/github.com/mattn/go-isatty/README.md
rename to vendor/github.com/mattn/go-isatty/README.md
diff --git a/internal/github.com/mattn/go-isatty/doc.go b/vendor/github.com/mattn/go-isatty/doc.go
similarity index 100%
rename from internal/github.com/mattn/go-isatty/doc.go
rename to vendor/github.com/mattn/go-isatty/doc.go
diff --git a/internal/github.com/mattn/go-isatty/isatty_bsd.go b/vendor/github.com/mattn/go-isatty/isatty_bsd.go
similarity index 100%
rename from internal/github.com/mattn/go-isatty/isatty_bsd.go
rename to vendor/github.com/mattn/go-isatty/isatty_bsd.go
diff --git a/internal/github.com/mattn/go-isatty/isatty_linux.go b/vendor/github.com/mattn/go-isatty/isatty_linux.go
similarity index 100%
rename from internal/github.com/mattn/go-isatty/isatty_linux.go
rename to vendor/github.com/mattn/go-isatty/isatty_linux.go
diff --git a/internal/github.com/mattn/go-isatty/isatty_windows.go b/vendor/github.com/mattn/go-isatty/isatty_windows.go
similarity index 100%
rename from internal/github.com/mattn/go-isatty/isatty_windows.go
rename to vendor/github.com/mattn/go-isatty/isatty_windows.go
diff --git a/internal/github.com/minio/cli/LICENSE b/vendor/github.com/minio/cli/LICENSE
similarity index 100%
rename from internal/github.com/minio/cli/LICENSE
rename to vendor/github.com/minio/cli/LICENSE
diff --git a/internal/github.com/minio/cli/README.md b/vendor/github.com/minio/cli/README.md
similarity index 100%
rename from internal/github.com/minio/cli/README.md
rename to vendor/github.com/minio/cli/README.md
diff --git a/internal/github.com/minio/cli/app.go b/vendor/github.com/minio/cli/app.go
similarity index 100%
rename from internal/github.com/minio/cli/app.go
rename to vendor/github.com/minio/cli/app.go
diff --git a/vendor/github.com/minio/cli/app_test.go b/vendor/github.com/minio/cli/app_test.go
new file mode 100644
index 00000000..98653c42
--- /dev/null
+++ b/vendor/github.com/minio/cli/app_test.go
@@ -0,0 +1,587 @@
+package cli_test
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "testing"
+
+ "github.com/minio/cli"
+)
+
+func ExampleApp() {
+ // set args for examples sake
+ os.Args = []string{"greet", "--name", "Jeremy"}
+
+ app := cli.NewApp()
+ app.Name = "greet"
+ app.Flags = []cli.Flag{
+ cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
+ }
+ app.Action = func(c *cli.Context) {
+ fmt.Printf("Hello %v\n", c.String("name"))
+ }
+ app.Author = "Harrison"
+ app.Email = "harrison@lolwut.com"
+ app.Authors = []cli.Author{{Name: "Oliver Allen", Email: "oliver@toyshop.com"}}
+ app.Run(os.Args)
+ // Output:
+ // Hello Jeremy
+}
+
+func ExampleAppSubcommand() {
+ // set args for examples sake
+ os.Args = []string{"say", "hi", "english", "--name", "Jeremy"}
+ app := cli.NewApp()
+ app.Name = "say"
+ app.Commands = []cli.Command{
+ {
+ Name: "hello",
+ Aliases: []string{"hi"},
+ Usage: "use it to see a description",
+ Description: "This is how we describe hello the function",
+ Subcommands: []cli.Command{
+ {
+ Name: "english",
+ Aliases: []string{"en"},
+ Usage: "sends a greeting in english",
+ Description: "greets someone in english",
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "name",
+ Value: "Bob",
+ Usage: "Name of the person to greet",
+ },
+ },
+ Action: func(c *cli.Context) {
+ fmt.Println("Hello,", c.String("name"))
+ },
+ },
+ },
+ },
+ }
+
+ app.Run(os.Args)
+ // Output:
+ // Hello, Jeremy
+}
+
+func ExampleAppHelp() {
+ // set args for examples sake
+ os.Args = []string{"greet", "h", "describeit"}
+
+ app := cli.NewApp()
+ app.Name = "greet"
+ app.Flags = []cli.Flag{
+ cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
+ }
+ app.Commands = []cli.Command{
+ {
+ Name: "describeit",
+ Aliases: []string{"d"},
+ Usage: "use it to see a description",
+ Description: "This is how we describe describeit the function",
+ Action: func(c *cli.Context) {
+ fmt.Printf("i like to describe things")
+ },
+ },
+ }
+ app.Run(os.Args)
+ // Output:
+ // NAME:
+ // describeit - use it to see a description
+ //
+ // USAGE:
+ // command describeit [arguments...]
+ //
+ // DESCRIPTION:
+ // This is how we describe describeit the function
+}
+
+func TestApp_Run(t *testing.T) {
+ s := ""
+
+ app := cli.NewApp()
+ app.Action = func(c *cli.Context) {
+ s = s + c.Args().First()
+ }
+
+ err := app.Run([]string{"command", "foo"})
+ expect(t, err, nil)
+ err = app.Run([]string{"command", "bar"})
+ expect(t, err, nil)
+ expect(t, s, "foobar")
+}
+
+var commandAppTests = []struct {
+ name string
+ expected bool
+}{
+ {"foobar", true},
+ {"batbaz", true},
+ {"b", true},
+ {"f", true},
+ {"bat", false},
+ {"nothing", false},
+}
+
+func TestApp_Command(t *testing.T) {
+ app := cli.NewApp()
+ fooCommand := cli.Command{Name: "foobar", Aliases: []string{"f"}}
+ batCommand := cli.Command{Name: "batbaz", Aliases: []string{"b"}}
+ app.Commands = []cli.Command{
+ fooCommand,
+ batCommand,
+ }
+
+ for _, test := range commandAppTests {
+ expect(t, app.Command(test.name) != nil, test.expected)
+ }
+}
+
+func TestApp_CommandWithArgBeforeFlags(t *testing.T) {
+ var parsedOption, firstArg string
+
+ app := cli.NewApp()
+ command := cli.Command{
+ Name: "cmd",
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
+ },
+ Action: func(c *cli.Context) {
+ parsedOption = c.String("option")
+ firstArg = c.Args().First()
+ },
+ }
+ app.Commands = []cli.Command{command}
+
+ app.Run([]string{"", "cmd", "my-arg", "--option", "my-option"})
+
+ expect(t, parsedOption, "my-option")
+ expect(t, firstArg, "my-arg")
+}
+
+func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
+ var context *cli.Context
+
+ a := cli.NewApp()
+ a.Commands = []cli.Command{
+ {
+ Name: "foo",
+ Action: func(c *cli.Context) {
+ context = c
+ },
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "lang",
+ Value: "english",
+ Usage: "language for the greeting",
+ },
+ },
+ Before: func(_ *cli.Context) error { return nil },
+ },
+ }
+ a.Run([]string{"", "foo", "--lang", "spanish", "abcd"})
+
+ expect(t, context.Args().Get(0), "abcd")
+ expect(t, context.String("lang"), "spanish")
+}
+
+func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
+ var parsedOption string
+ var args []string
+
+ app := cli.NewApp()
+ command := cli.Command{
+ Name: "cmd",
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "option", Value: "", Usage: "some option"},
+ },
+ Action: func(c *cli.Context) {
+ parsedOption = c.String("option")
+ args = c.Args()
+ },
+ }
+ app.Commands = []cli.Command{command}
+
+ app.Run([]string{"", "cmd", "my-arg", "--option", "my-option", "--", "--notARealFlag"})
+
+ expect(t, parsedOption, "my-option")
+ expect(t, args[0], "my-arg")
+ expect(t, args[1], "--")
+ expect(t, args[2], "--notARealFlag")
+}
+
+func TestApp_CommandWithNoFlagBeforeTerminator(t *testing.T) {
+ var args []string
+
+ app := cli.NewApp()
+ command := cli.Command{
+ Name: "cmd",
+ Action: func(c *cli.Context) {
+ args = c.Args()
+ },
+ }
+ app.Commands = []cli.Command{command}
+
+ app.Run([]string{"", "cmd", "my-arg", "--", "notAFlagAtAll"})
+
+ expect(t, args[0], "my-arg")
+ expect(t, args[1], "--")
+ expect(t, args[2], "notAFlagAtAll")
+}
+
+func TestApp_Float64Flag(t *testing.T) {
+ var meters float64
+
+ app := cli.NewApp()
+ app.Flags = []cli.Flag{
+ cli.Float64Flag{Name: "height", Value: 1.5, Usage: "Set the height, in meters"},
+ }
+ app.Action = func(c *cli.Context) {
+ meters = c.Float64("height")
+ }
+
+ app.Run([]string{"", "--height", "1.93"})
+ expect(t, meters, 1.93)
+}
+
+func TestApp_ParseSliceFlags(t *testing.T) {
+ var parsedOption, firstArg string
+ var parsedIntSlice []int
+ var parsedStringSlice []string
+
+ app := cli.NewApp()
+ command := cli.Command{
+ Name: "cmd",
+ Flags: []cli.Flag{
+ cli.IntSliceFlag{Name: "p", Value: &cli.IntSlice{}, Usage: "set one or more ip addr"},
+ cli.StringSliceFlag{Name: "ip", Value: &cli.StringSlice{}, Usage: "set one or more ports to open"},
+ },
+ Action: func(c *cli.Context) {
+ parsedIntSlice = c.IntSlice("p")
+ parsedStringSlice = c.StringSlice("ip")
+ parsedOption = c.String("option")
+ firstArg = c.Args().First()
+ },
+ }
+ app.Commands = []cli.Command{command}
+
+ app.Run([]string{"", "cmd", "my-arg", "-p", "22", "-p", "80", "-ip", "8.8.8.8", "-ip", "8.8.4.4"})
+
+ IntsEquals := func(a, b []int) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for i, v := range a {
+ if v != b[i] {
+ return false
+ }
+ }
+ return true
+ }
+
+ StrsEquals := func(a, b []string) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for i, v := range a {
+ if v != b[i] {
+ return false
+ }
+ }
+ return true
+ }
+ var expectedIntSlice = []int{22, 80}
+ var expectedStringSlice = []string{"8.8.8.8", "8.8.4.4"}
+
+ if !IntsEquals(parsedIntSlice, expectedIntSlice) {
+ t.Errorf("%v does not match %v", parsedIntSlice, expectedIntSlice)
+ }
+
+ if !StrsEquals(parsedStringSlice, expectedStringSlice) {
+ t.Errorf("%v does not match %v", parsedStringSlice, expectedStringSlice)
+ }
+}
+
+func TestApp_DefaultStdout(t *testing.T) {
+ app := cli.NewApp()
+
+ if app.Writer != os.Stdout {
+ t.Error("Default output writer not set.")
+ }
+}
+
+type mockWriter struct {
+ written []byte
+}
+
+func (fw *mockWriter) Write(p []byte) (n int, err error) {
+ if fw.written == nil {
+ fw.written = p
+ } else {
+ fw.written = append(fw.written, p...)
+ }
+
+ return len(p), nil
+}
+
+func (fw *mockWriter) GetWritten() (b []byte) {
+ return fw.written
+}
+
+func TestApp_SetStdout(t *testing.T) {
+ w := &mockWriter{}
+
+ app := cli.NewApp()
+ app.Name = "test"
+ app.Writer = w
+
+ err := app.Run([]string{"help"})
+
+ if err != nil {
+ t.Fatalf("Run error: %s", err)
+ }
+
+ if len(w.written) == 0 {
+ t.Error("App did not write output to desired writer.")
+ }
+}
+
+func TestApp_BeforeFunc(t *testing.T) {
+ beforeRun, subcommandRun := false, false
+ beforeError := fmt.Errorf("fail")
+ var err error
+
+ app := cli.NewApp()
+
+ app.Before = func(c *cli.Context) error {
+ beforeRun = true
+ s := c.String("opt")
+ if s == "fail" {
+ return beforeError
+ }
+
+ return nil
+ }
+
+ app.Commands = []cli.Command{
+ {
+ Name: "sub",
+ Action: func(c *cli.Context) {
+ subcommandRun = true
+ },
+ },
+ }
+
+ app.Flags = []cli.Flag{
+ cli.StringFlag{Name: "opt"},
+ }
+
+ // run with the Before() func succeeding
+ err = app.Run([]string{"command", "--opt", "succeed", "sub"})
+
+ if err != nil {
+ t.Fatalf("Run error: %s", err)
+ }
+
+ if beforeRun == false {
+ t.Errorf("Before() not executed when expected")
+ }
+
+ if subcommandRun == false {
+ t.Errorf("Subcommand not executed when expected")
+ }
+
+ // reset
+ beforeRun, subcommandRun = false, false
+
+ // run with the Before() func failing
+ err = app.Run([]string{"command", "--opt", "fail", "sub"})
+
+ // should be the same error produced by the Before func
+ if err != beforeError {
+ t.Errorf("Run error expected, but not received")
+ }
+
+ if beforeRun == false {
+ t.Errorf("Before() not executed when expected")
+ }
+
+ if subcommandRun == true {
+ t.Errorf("Subcommand executed when NOT expected")
+ }
+
+}
+
+func TestApp_AfterFunc(t *testing.T) {
+ afterRun, subcommandRun := false, false
+ afterError := fmt.Errorf("fail")
+ var err error
+
+ app := cli.NewApp()
+
+ app.After = func(c *cli.Context) error {
+ afterRun = true
+ s := c.String("opt")
+ if s == "fail" {
+ return afterError
+ }
+
+ return nil
+ }
+
+ app.Commands = []cli.Command{
+ {
+ Name: "sub",
+ Action: func(c *cli.Context) {
+ subcommandRun = true
+ },
+ },
+ }
+
+ app.Flags = []cli.Flag{
+ cli.StringFlag{Name: "opt"},
+ }
+
+ // run with the After() func succeeding
+ err = app.Run([]string{"command", "--opt", "succeed", "sub"})
+
+ if err != nil {
+ t.Fatalf("Run error: %s", err)
+ }
+
+ if afterRun == false {
+ t.Errorf("After() not executed when expected")
+ }
+
+ if subcommandRun == false {
+ t.Errorf("Subcommand not executed when expected")
+ }
+
+ // reset
+ afterRun, subcommandRun = false, false
+
+ // run with the Before() func failing
+ err = app.Run([]string{"command", "--opt", "fail", "sub"})
+
+ // should be the same error produced by the Before func
+ if err != afterError {
+ t.Errorf("Run error expected, but not received")
+ }
+
+ if afterRun == false {
+ t.Errorf("After() not executed when expected")
+ }
+
+ if subcommandRun == false {
+ t.Errorf("Subcommand not executed when expected")
+ }
+}
+
+func TestAppNoHelpFlag(t *testing.T) {
+ oldFlag := cli.HelpFlag
+ defer func() {
+ cli.HelpFlag = oldFlag
+ }()
+
+ cli.HelpFlag = cli.BoolFlag{}
+
+ app := cli.NewApp()
+ err := app.Run([]string{"test", "-h"})
+
+ if err != flag.ErrHelp {
+ t.Errorf("expected error about missing help flag, but got: %s (%T)", err, err)
+ }
+}
+
+func TestAppHelpPrinter(t *testing.T) {
+ oldPrinter := cli.HelpPrinter
+ defer func() {
+ cli.HelpPrinter = oldPrinter
+ }()
+
+ var wasCalled = false
+ cli.HelpPrinter = func(template string, data interface{}) {
+ wasCalled = true
+ }
+
+ app := cli.NewApp()
+ app.Run([]string{"-h"})
+
+ if wasCalled == false {
+ t.Errorf("Help printer expected to be called, but was not")
+ }
+}
+
+func TestAppVersionPrinter(t *testing.T) {
+ oldPrinter := cli.VersionPrinter
+ defer func() {
+ cli.VersionPrinter = oldPrinter
+ }()
+
+ var wasCalled = false
+ cli.VersionPrinter = func(c *cli.Context) {
+ wasCalled = true
+ }
+
+ app := cli.NewApp()
+ ctx := cli.NewContext(app, nil, nil)
+ cli.ShowVersion(ctx)
+
+ if wasCalled == false {
+ t.Errorf("Version printer expected to be called, but was not")
+ }
+}
+
+func TestAppCommandNotFound(t *testing.T) {
+ beforeRun, subcommandRun := false, false
+ app := cli.NewApp()
+
+ app.CommandNotFound = func(c *cli.Context, command string) {
+ beforeRun = true
+ }
+
+ app.Commands = []cli.Command{
+ {
+ Name: "bar",
+ Action: func(c *cli.Context) {
+ subcommandRun = true
+ },
+ },
+ }
+
+ app.Run([]string{"command", "foo"})
+
+ expect(t, beforeRun, true)
+ expect(t, subcommandRun, false)
+}
+
+func TestGlobalFlagsInSubcommands(t *testing.T) {
+ subcommandRun := false
+ app := cli.NewApp()
+
+ app.Flags = []cli.Flag{
+ cli.BoolFlag{Name: "debug, d", Usage: "Enable debugging"},
+ }
+
+ app.Commands = []cli.Command{
+ {
+ Name: "foo",
+ Subcommands: []cli.Command{
+ {
+ Name: "bar",
+ Action: func(c *cli.Context) {
+ if c.GlobalBool("debug") {
+ subcommandRun = true
+ }
+ },
+ },
+ },
+ },
+ }
+
+ app.Run([]string{"command", "-d", "foo", "bar"})
+
+ expect(t, subcommandRun, true)
+}
diff --git a/internal/github.com/minio/cli/bool.go b/vendor/github.com/minio/cli/bool.go
similarity index 100%
rename from internal/github.com/minio/cli/bool.go
rename to vendor/github.com/minio/cli/bool.go
diff --git a/internal/github.com/minio/cli/cli.go b/vendor/github.com/minio/cli/cli.go
similarity index 100%
rename from internal/github.com/minio/cli/cli.go
rename to vendor/github.com/minio/cli/cli.go
diff --git a/vendor/github.com/minio/cli/cli_test.go b/vendor/github.com/minio/cli/cli_test.go
new file mode 100644
index 00000000..c097b3b8
--- /dev/null
+++ b/vendor/github.com/minio/cli/cli_test.go
@@ -0,0 +1,100 @@
+package cli_test
+
+import (
+ "os"
+
+ "github.com/minio/cli"
+)
+
+func Example() {
+ app := cli.NewApp()
+ app.Name = "todo"
+ app.Usage = "task list on the command line"
+ app.Commands = []cli.Command{
+ {
+ Name: "add",
+ Aliases: []string{"a"},
+ Usage: "add a task to the list",
+ Action: func(c *cli.Context) {
+ println("added task: ", c.Args().First())
+ },
+ },
+ {
+ Name: "complete",
+ Aliases: []string{"c"},
+ Usage: "complete a task on the list",
+ Action: func(c *cli.Context) {
+ println("completed task: ", c.Args().First())
+ },
+ },
+ }
+
+ app.Run(os.Args)
+}
+
+func ExampleSubcommand() {
+ app := cli.NewApp()
+ app.Name = "say"
+ app.Commands = []cli.Command{
+ {
+ Name: "hello",
+ Aliases: []string{"hi"},
+ Usage: "use it to see a description",
+ Description: "This is how we describe hello the function",
+ Subcommands: []cli.Command{
+ {
+ Name: "english",
+ Aliases: []string{"en"},
+ Usage: "sends a greeting in english",
+ Description: "greets someone in english",
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "name",
+ Value: "Bob",
+ Usage: "Name of the person to greet",
+ },
+ },
+ Action: func(c *cli.Context) {
+ println("Hello, ", c.String("name"))
+ },
+ }, {
+ Name: "spanish",
+ Aliases: []string{"sp"},
+ Usage: "sends a greeting in spanish",
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "surname",
+ Value: "Jones",
+ Usage: "Surname of the person to greet",
+ },
+ },
+ Action: func(c *cli.Context) {
+ println("Hola, ", c.String("surname"))
+ },
+ }, {
+ Name: "french",
+ Aliases: []string{"fr"},
+ Usage: "sends a greeting in french",
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "nickname",
+ Value: "Stevie",
+ Usage: "Nickname of the person to greet",
+ },
+ },
+ Action: func(c *cli.Context) {
+ println("Bonjour, ", c.String("nickname"))
+ },
+ },
+ },
+ }, {
+ Name: "bye",
+ Usage: "says goodbye",
+ Action: func(c *cli.Context) {
+ println("bye")
+ },
+ },
+ }
+
+ app.Run(os.Args)
+}
diff --git a/internal/github.com/minio/cli/command.go b/vendor/github.com/minio/cli/command.go
similarity index 100%
rename from internal/github.com/minio/cli/command.go
rename to vendor/github.com/minio/cli/command.go
diff --git a/vendor/github.com/minio/cli/command_test.go b/vendor/github.com/minio/cli/command_test.go
new file mode 100644
index 00000000..08adc15d
--- /dev/null
+++ b/vendor/github.com/minio/cli/command_test.go
@@ -0,0 +1,49 @@
+package cli_test
+
+import (
+ "flag"
+ "testing"
+
+ "github.com/minio/cli"
+)
+
+func TestCommandDoNotIgnoreFlags(t *testing.T) {
+ app := cli.NewApp()
+ set := flag.NewFlagSet("test", 0)
+ test := []string{"blah", "blah", "-break"}
+ set.Parse(test)
+
+ c := cli.NewContext(app, set, set)
+
+ command := cli.Command{
+ Name: "test-cmd",
+ Aliases: []string{"tc"},
+ Usage: "this is for testing",
+ Description: "testing",
+ Action: func(_ *cli.Context) {},
+ }
+ err := command.Run(c)
+
+ expect(t, err.Error(), "flag provided but not defined: -break")
+}
+
+func TestCommandIgnoreFlags(t *testing.T) {
+ app := cli.NewApp()
+ set := flag.NewFlagSet("test", 0)
+ test := []string{"blah", "blah"}
+ set.Parse(test)
+
+ c := cli.NewContext(app, set, set)
+
+ command := cli.Command{
+ Name: "test-cmd",
+ Aliases: []string{"tc"},
+ Usage: "this is for testing",
+ Description: "testing",
+ Action: func(_ *cli.Context) {},
+ SkipFlagParsing: true,
+ }
+ err := command.Run(c)
+
+ expect(t, err, nil)
+}
diff --git a/internal/github.com/minio/cli/context.go b/vendor/github.com/minio/cli/context.go
similarity index 100%
rename from internal/github.com/minio/cli/context.go
rename to vendor/github.com/minio/cli/context.go
diff --git a/vendor/github.com/minio/cli/context_test.go b/vendor/github.com/minio/cli/context_test.go
new file mode 100644
index 00000000..207161d7
--- /dev/null
+++ b/vendor/github.com/minio/cli/context_test.go
@@ -0,0 +1,111 @@
+package cli_test
+
+import (
+ "flag"
+ "testing"
+ "time"
+
+ "github.com/minio/cli"
+)
+
+func TestNewContext(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Int("myflag", 12, "doc")
+ globalSet := flag.NewFlagSet("test", 0)
+ globalSet.Int("myflag", 42, "doc")
+ command := cli.Command{Name: "mycommand"}
+ c := cli.NewContext(nil, set, globalSet)
+ c.Command = command
+ expect(t, c.Int("myflag"), 12)
+ expect(t, c.GlobalInt("myflag"), 42)
+ expect(t, c.Command.Name, "mycommand")
+}
+
+func TestContext_Int(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Int("myflag", 12, "doc")
+ c := cli.NewContext(nil, set, set)
+ expect(t, c.Int("myflag"), 12)
+}
+
+func TestContext_Duration(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Duration("myflag", time.Duration(12*time.Second), "doc")
+ c := cli.NewContext(nil, set, set)
+ expect(t, c.Duration("myflag"), time.Duration(12*time.Second))
+}
+
+func TestContext_String(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.String("myflag", "hello world", "doc")
+ c := cli.NewContext(nil, set, set)
+ expect(t, c.String("myflag"), "hello world")
+}
+
+func TestContext_Bool(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Bool("myflag", false, "doc")
+ c := cli.NewContext(nil, set, set)
+ expect(t, c.Bool("myflag"), false)
+}
+
+func TestContext_BoolT(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Bool("myflag", true, "doc")
+ c := cli.NewContext(nil, set, set)
+ expect(t, c.BoolT("myflag"), true)
+}
+
+func TestContext_Args(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Bool("myflag", false, "doc")
+ c := cli.NewContext(nil, set, set)
+ set.Parse([]string{"--myflag", "bat", "baz"})
+ expect(t, len(c.Args()), 2)
+ expect(t, c.Bool("myflag"), true)
+}
+
+func TestContext_IsSet(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Bool("myflag", false, "doc")
+ set.String("otherflag", "hello world", "doc")
+ globalSet := flag.NewFlagSet("test", 0)
+ globalSet.Bool("myflagGlobal", true, "doc")
+ c := cli.NewContext(nil, set, globalSet)
+ set.Parse([]string{"--myflag", "bat", "baz"})
+ globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
+ expect(t, c.IsSet("myflag"), true)
+ expect(t, c.IsSet("otherflag"), false)
+ expect(t, c.IsSet("bogusflag"), false)
+ expect(t, c.IsSet("myflagGlobal"), false)
+}
+
+func TestContext_GlobalIsSet(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Bool("myflag", false, "doc")
+ set.String("otherflag", "hello world", "doc")
+ globalSet := flag.NewFlagSet("test", 0)
+ globalSet.Bool("myflagGlobal", true, "doc")
+ globalSet.Bool("myflagGlobalUnset", true, "doc")
+ c := cli.NewContext(nil, set, globalSet)
+ set.Parse([]string{"--myflag", "bat", "baz"})
+ globalSet.Parse([]string{"--myflagGlobal", "bat", "baz"})
+ expect(t, c.GlobalIsSet("myflag"), false)
+ expect(t, c.GlobalIsSet("otherflag"), false)
+ expect(t, c.GlobalIsSet("bogusflag"), false)
+ expect(t, c.GlobalIsSet("myflagGlobal"), true)
+ expect(t, c.GlobalIsSet("myflagGlobalUnset"), false)
+ expect(t, c.GlobalIsSet("bogusGlobal"), false)
+}
+
+func TestContext_NumFlags(t *testing.T) {
+ set := flag.NewFlagSet("test", 0)
+ set.Bool("myflag", false, "doc")
+ set.String("otherflag", "hello world", "doc")
+ globalSet := flag.NewFlagSet("test", 0)
+ globalSet.Bool("myflagGlobal", true, "doc")
+ c := cli.NewContext(nil, set, globalSet)
+ set.Parse([]string{"--myflag", "--otherflag=foo"})
+ globalSet.Parse([]string{"--myflagGlobal"})
+ expect(t, c.NumFlags(), 2)
+}
diff --git a/internal/github.com/minio/cli/duration.go b/vendor/github.com/minio/cli/duration.go
similarity index 100%
rename from internal/github.com/minio/cli/duration.go
rename to vendor/github.com/minio/cli/duration.go
diff --git a/internal/github.com/minio/cli/flag.go b/vendor/github.com/minio/cli/flag.go
similarity index 100%
rename from internal/github.com/minio/cli/flag.go
rename to vendor/github.com/minio/cli/flag.go
diff --git a/vendor/github.com/minio/cli/flag_test.go b/vendor/github.com/minio/cli/flag_test.go
new file mode 100644
index 00000000..cda91c55
--- /dev/null
+++ b/vendor/github.com/minio/cli/flag_test.go
@@ -0,0 +1,742 @@
+package cli_test
+
+import (
+ "fmt"
+ "os"
+ "reflect"
+ "strings"
+ "testing"
+
+ "github.com/minio/cli"
+)
+
+var boolFlagTests = []struct {
+ name string
+ expected string
+}{
+ {"help", "--help\t"},
+ {"h", "-h\t"},
+}
+
+func TestBoolFlagHelpOutput(t *testing.T) {
+
+ for _, test := range boolFlagTests {
+ flag := cli.BoolFlag{Name: test.name}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%s does not match %s", output, test.expected)
+ }
+ }
+}
+
+var stringFlagTests = []struct {
+ name string
+ value string
+ expected string
+}{
+ {"help", "", "--help \t"},
+ {"h", "", "-h \t"},
+ {"h", "", "-h \t"},
+ {"test", "Something", "--test \"Something\"\t"},
+}
+
+func TestStringFlagHelpOutput(t *testing.T) {
+
+ for _, test := range stringFlagTests {
+ flag := cli.StringFlag{Name: test.name, Value: test.value}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%s does not match %s", output, test.expected)
+ }
+ }
+}
+
+func TestStringFlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_FOO", "derp")
+ for _, test := range stringFlagTests {
+ flag := cli.StringFlag{Name: test.name, Value: test.value, EnvVar: "APP_FOO"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_FOO]") {
+ t.Errorf("%s does not end with [$APP_FOO]", output)
+ }
+ }
+}
+
+var stringSliceFlagTests = []struct {
+ name string
+ value *cli.StringSlice
+ expected string
+}{
+ {"help", func() *cli.StringSlice {
+ s := &cli.StringSlice{}
+ s.Set("")
+ return s
+ }(), "--help [--help option --help option]\t"},
+ {"h", func() *cli.StringSlice {
+ s := &cli.StringSlice{}
+ s.Set("")
+ return s
+ }(), "-h [-h option -h option]\t"},
+ {"h", func() *cli.StringSlice {
+ s := &cli.StringSlice{}
+ s.Set("")
+ return s
+ }(), "-h [-h option -h option]\t"},
+ {"test", func() *cli.StringSlice {
+ s := &cli.StringSlice{}
+ s.Set("Something")
+ return s
+ }(), "--test [--test option --test option]\t"},
+}
+
+func TestStringSliceFlagHelpOutput(t *testing.T) {
+
+ for _, test := range stringSliceFlagTests {
+ flag := cli.StringSliceFlag{Name: test.name, Value: test.value}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%q does not match %q", output, test.expected)
+ }
+ }
+}
+
+func TestStringSliceFlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_QWWX", "11,4")
+ for _, test := range stringSliceFlagTests {
+ flag := cli.StringSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_QWWX"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_QWWX]") {
+ t.Errorf("%q does not end with [$APP_QWWX]", output)
+ }
+ }
+}
+
+var intFlagTests = []struct {
+ name string
+ expected string
+}{
+ {"help", "--help \"0\"\t"},
+ {"h", "-h \"0\"\t"},
+}
+
+func TestIntFlagHelpOutput(t *testing.T) {
+
+ for _, test := range intFlagTests {
+ flag := cli.IntFlag{Name: test.name}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%s does not match %s", output, test.expected)
+ }
+ }
+}
+
+func TestIntFlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_BAR", "2")
+ for _, test := range intFlagTests {
+ flag := cli.IntFlag{Name: test.name, EnvVar: "APP_BAR"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_BAR]") {
+ t.Errorf("%s does not end with [$APP_BAR]", output)
+ }
+ }
+}
+
+var durationFlagTests = []struct {
+ name string
+ expected string
+}{
+ {"help", "--help \"0\"\t"},
+ {"h", "-h \"0\"\t"},
+}
+
+func TestDurationFlagHelpOutput(t *testing.T) {
+
+ for _, test := range durationFlagTests {
+ flag := cli.DurationFlag{Name: test.name}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%s does not match %s", output, test.expected)
+ }
+ }
+}
+
+func TestDurationFlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_BAR", "2h3m6s")
+ for _, test := range durationFlagTests {
+ flag := cli.DurationFlag{Name: test.name, EnvVar: "APP_BAR"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_BAR]") {
+ t.Errorf("%s does not end with [$APP_BAR]", output)
+ }
+ }
+}
+
+var intSliceFlagTests = []struct {
+ name string
+ value *cli.IntSlice
+ expected string
+}{
+ {"help", &cli.IntSlice{}, "--help [--help option --help option]\t"},
+ {"h", &cli.IntSlice{}, "-h [-h option -h option]\t"},
+ {"h", &cli.IntSlice{}, "-h [-h option -h option]\t"},
+ {"test", func() *cli.IntSlice {
+ i := &cli.IntSlice{}
+ i.Set("9")
+ return i
+ }(), "--test [--test option --test option]\t"},
+}
+
+func TestIntSliceFlagHelpOutput(t *testing.T) {
+
+ for _, test := range intSliceFlagTests {
+ flag := cli.IntSliceFlag{Name: test.name, Value: test.value}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%q does not match %q", output, test.expected)
+ }
+ }
+}
+
+func TestIntSliceFlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_SMURF", "42,3")
+ for _, test := range intSliceFlagTests {
+ flag := cli.IntSliceFlag{Name: test.name, Value: test.value, EnvVar: "APP_SMURF"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_SMURF]") {
+ t.Errorf("%q does not end with [$APP_SMURF]", output)
+ }
+ }
+}
+
+var float64FlagTests = []struct {
+ name string
+ expected string
+}{
+ {"help", "--help \"0\"\t"},
+ {"h", "-h \"0\"\t"},
+}
+
+func TestFloat64FlagHelpOutput(t *testing.T) {
+
+ for _, test := range float64FlagTests {
+ flag := cli.Float64Flag{Name: test.name}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%s does not match %s", output, test.expected)
+ }
+ }
+}
+
+func TestFloat64FlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_BAZ", "99.4")
+ for _, test := range float64FlagTests {
+ flag := cli.Float64Flag{Name: test.name, EnvVar: "APP_BAZ"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_BAZ]") {
+ t.Errorf("%s does not end with [$APP_BAZ]", output)
+ }
+ }
+}
+
+var genericFlagTests = []struct {
+ name string
+ value cli.Generic
+ expected string
+}{
+ {"test", &Parser{"abc", "def"}, "--test \"abc,def\"\ttest flag"},
+ {"t", &Parser{"abc", "def"}, "-t \"abc,def\"\ttest flag"},
+}
+
+func TestGenericFlagHelpOutput(t *testing.T) {
+
+ for _, test := range genericFlagTests {
+ flag := cli.GenericFlag{Name: test.name, Value: test.value, Usage: "test flag"}
+ output := flag.String()
+
+ if output != test.expected {
+ t.Errorf("%q does not match %q", output, test.expected)
+ }
+ }
+}
+
+func TestGenericFlagWithEnvVarHelpOutput(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_ZAP", "3")
+ for _, test := range genericFlagTests {
+ flag := cli.GenericFlag{Name: test.name, EnvVar: "APP_ZAP"}
+ output := flag.String()
+
+ if !strings.HasSuffix(output, " [$APP_ZAP]") {
+ t.Errorf("%s does not end with [$APP_ZAP]", output)
+ }
+ }
+}
+
+func TestParseMultiString(t *testing.T) {
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "serve, s"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.String("serve") != "10" {
+ t.Errorf("main name not set")
+ }
+ if ctx.String("s") != "10" {
+ t.Errorf("short name not set")
+ }
+ },
+ }).Run([]string{"run", "-s", "10"})
+}
+
+func TestParseMultiStringFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_COUNT", "20")
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "count, c", EnvVar: "APP_COUNT"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.String("count") != "20" {
+ t.Errorf("main name not set")
+ }
+ if ctx.String("c") != "20" {
+ t.Errorf("short name not set")
+ }
+ },
+ }).Run([]string{"run"})
+}
+
+func TestParseMultiStringFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_COUNT", "20")
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.StringFlag{Name: "count, c", EnvVar: "COMPAT_COUNT,APP_COUNT"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.String("count") != "20" {
+ t.Errorf("main name not set")
+ }
+ if ctx.String("c") != "20" {
+ t.Errorf("short name not set")
+ }
+ },
+ }).Run([]string{"run"})
+}
+
+func TestParseMultiStringSlice(t *testing.T) {
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{Name: "serve, s", Value: &cli.StringSlice{}},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.StringSlice("serve"), []string{"10", "20"}) {
+ t.Errorf("main name not set")
+ }
+ if !reflect.DeepEqual(ctx.StringSlice("s"), []string{"10", "20"}) {
+ t.Errorf("short name not set")
+ }
+ },
+ }).Run([]string{"run", "-s", "10", "-s", "20"})
+}
+
+func TestParseMultiStringSliceFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_INTERVALS", "20,30,40")
+
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "APP_INTERVALS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
+ t.Errorf("main name not set from env")
+ }
+ if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }).Run([]string{"run"})
+}
+
+func TestParseMultiStringSliceFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_INTERVALS", "20,30,40")
+
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{Name: "intervals, i", Value: &cli.StringSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.StringSlice("intervals"), []string{"20", "30", "40"}) {
+ t.Errorf("main name not set from env")
+ }
+ if !reflect.DeepEqual(ctx.StringSlice("i"), []string{"20", "30", "40"}) {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }).Run([]string{"run"})
+}
+
+func TestParseMultiInt(t *testing.T) {
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "serve, s"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Int("serve") != 10 {
+ t.Errorf("main name not set")
+ }
+ if ctx.Int("s") != 10 {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run", "-s", "10"})
+}
+
+func TestParseMultiIntFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_TIMEOUT_SECONDS", "10")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Int("timeout") != 10 {
+ t.Errorf("main name not set")
+ }
+ if ctx.Int("t") != 10 {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiIntFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_TIMEOUT_SECONDS", "10")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.IntFlag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Int("timeout") != 10 {
+ t.Errorf("main name not set")
+ }
+ if ctx.Int("t") != 10 {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiIntSlice(t *testing.T) {
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.IntSliceFlag{Name: "serve, s", Value: &cli.IntSlice{}},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.IntSlice("serve"), []int{10, 20}) {
+ t.Errorf("main name not set")
+ }
+ if !reflect.DeepEqual(ctx.IntSlice("s"), []int{10, 20}) {
+ t.Errorf("short name not set")
+ }
+ },
+ }).Run([]string{"run", "-s", "10", "-s", "20"})
+}
+
+func TestParseMultiIntSliceFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_INTERVALS", "20,30,40")
+
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "APP_INTERVALS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
+ t.Errorf("main name not set from env")
+ }
+ if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }).Run([]string{"run"})
+}
+
+func TestParseMultiIntSliceFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_INTERVALS", "20,30,40")
+
+ (&cli.App{
+ Flags: []cli.Flag{
+ cli.IntSliceFlag{Name: "intervals, i", Value: &cli.IntSlice{}, EnvVar: "COMPAT_INTERVALS,APP_INTERVALS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.IntSlice("intervals"), []int{20, 30, 40}) {
+ t.Errorf("main name not set from env")
+ }
+ if !reflect.DeepEqual(ctx.IntSlice("i"), []int{20, 30, 40}) {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }).Run([]string{"run"})
+}
+
+func TestParseMultiFloat64(t *testing.T) {
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.Float64Flag{Name: "serve, s"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Float64("serve") != 10.2 {
+ t.Errorf("main name not set")
+ }
+ if ctx.Float64("s") != 10.2 {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run", "-s", "10.2"})
+}
+
+func TestParseMultiFloat64FromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.Float64Flag{Name: "timeout, t", EnvVar: "APP_TIMEOUT_SECONDS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Float64("timeout") != 15.5 {
+ t.Errorf("main name not set")
+ }
+ if ctx.Float64("t") != 15.5 {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiFloat64FromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_TIMEOUT_SECONDS", "15.5")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.Float64Flag{Name: "timeout, t", EnvVar: "COMPAT_TIMEOUT_SECONDS,APP_TIMEOUT_SECONDS"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Float64("timeout") != 15.5 {
+ t.Errorf("main name not set")
+ }
+ if ctx.Float64("t") != 15.5 {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiBool(t *testing.T) {
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "serve, s"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Bool("serve") != true {
+ t.Errorf("main name not set")
+ }
+ if ctx.Bool("s") != true {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run", "--serve"})
+}
+
+func TestParseMultiBoolFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_DEBUG", "1")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Bool("debug") != true {
+ t.Errorf("main name not set from env")
+ }
+ if ctx.Bool("d") != true {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiBoolFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_DEBUG", "1")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.BoolFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.Bool("debug") != true {
+ t.Errorf("main name not set from env")
+ }
+ if ctx.Bool("d") != true {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiBoolT(t *testing.T) {
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.BoolTFlag{Name: "serve, s"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.BoolT("serve") != true {
+ t.Errorf("main name not set")
+ }
+ if ctx.BoolT("s") != true {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run", "--serve"})
+}
+
+func TestParseMultiBoolTFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_DEBUG", "0")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.BoolTFlag{Name: "debug, d", EnvVar: "APP_DEBUG"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.BoolT("debug") != false {
+ t.Errorf("main name not set from env")
+ }
+ if ctx.BoolT("d") != false {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseMultiBoolTFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_DEBUG", "0")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.BoolTFlag{Name: "debug, d", EnvVar: "COMPAT_DEBUG,APP_DEBUG"},
+ },
+ Action: func(ctx *cli.Context) {
+ if ctx.BoolT("debug") != false {
+ t.Errorf("main name not set from env")
+ }
+ if ctx.BoolT("d") != false {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+type Parser [2]string
+
+func (p *Parser) Set(value string) error {
+ parts := strings.Split(value, ",")
+ if len(parts) != 2 {
+ return fmt.Errorf("invalid format")
+ }
+
+ (*p)[0] = parts[0]
+ (*p)[1] = parts[1]
+
+ return nil
+}
+
+func (p *Parser) String() string {
+ return fmt.Sprintf("%s,%s", p[0], p[1])
+}
+
+func TestParseGeneric(t *testing.T) {
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.GenericFlag{Name: "serve, s", Value: &Parser{}},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"10", "20"}) {
+ t.Errorf("main name not set")
+ }
+ if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"10", "20"}) {
+ t.Errorf("short name not set")
+ }
+ },
+ }
+ a.Run([]string{"run", "-s", "10,20"})
+}
+
+func TestParseGenericFromEnv(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_SERVE", "20,30")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.GenericFlag{Name: "serve, s", Value: &Parser{}, EnvVar: "APP_SERVE"},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.Generic("serve"), &Parser{"20", "30"}) {
+ t.Errorf("main name not set from env")
+ }
+ if !reflect.DeepEqual(ctx.Generic("s"), &Parser{"20", "30"}) {
+ t.Errorf("short name not set from env")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
+
+func TestParseGenericFromEnvCascade(t *testing.T) {
+ os.Clearenv()
+ os.Setenv("APP_FOO", "99,2000")
+ a := cli.App{
+ Flags: []cli.Flag{
+ cli.GenericFlag{Name: "foos", Value: &Parser{}, EnvVar: "COMPAT_FOO,APP_FOO"},
+ },
+ Action: func(ctx *cli.Context) {
+ if !reflect.DeepEqual(ctx.Generic("foos"), &Parser{"99", "2000"}) {
+ t.Errorf("value not set from env")
+ }
+ },
+ }
+ a.Run([]string{"run"})
+}
diff --git a/internal/github.com/minio/cli/float64.go b/vendor/github.com/minio/cli/float64.go
similarity index 100%
rename from internal/github.com/minio/cli/float64.go
rename to vendor/github.com/minio/cli/float64.go
diff --git a/internal/github.com/minio/cli/help.go b/vendor/github.com/minio/cli/help.go
similarity index 100%
rename from internal/github.com/minio/cli/help.go
rename to vendor/github.com/minio/cli/help.go
diff --git a/vendor/github.com/minio/cli/helpers_test.go b/vendor/github.com/minio/cli/helpers_test.go
new file mode 100644
index 00000000..cdc4feb2
--- /dev/null
+++ b/vendor/github.com/minio/cli/helpers_test.go
@@ -0,0 +1,19 @@
+package cli_test
+
+import (
+ "reflect"
+ "testing"
+)
+
+/* Test Helpers */
+func expect(t *testing.T, a interface{}, b interface{}) {
+ if a != b {
+ t.Errorf("Expected %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
+ }
+}
+
+func refute(t *testing.T, a interface{}, b interface{}) {
+ if a == b {
+ t.Errorf("Did not expect %v (type %v) - Got %v (type %v)", b, reflect.TypeOf(b), a, reflect.TypeOf(a))
+ }
+}
diff --git a/internal/github.com/minio/cli/int.go b/vendor/github.com/minio/cli/int.go
similarity index 100%
rename from internal/github.com/minio/cli/int.go
rename to vendor/github.com/minio/cli/int.go
diff --git a/internal/github.com/minio/cli/intslice.go b/vendor/github.com/minio/cli/intslice.go
similarity index 100%
rename from internal/github.com/minio/cli/intslice.go
rename to vendor/github.com/minio/cli/intslice.go
diff --git a/internal/github.com/minio/cli/string.go b/vendor/github.com/minio/cli/string.go
similarity index 100%
rename from internal/github.com/minio/cli/string.go
rename to vendor/github.com/minio/cli/string.go
diff --git a/internal/github.com/minio/cli/stringslice.go b/vendor/github.com/minio/cli/stringslice.go
similarity index 100%
rename from internal/github.com/minio/cli/stringslice.go
rename to vendor/github.com/minio/cli/stringslice.go
diff --git a/internal/github.com/minio/minio-go/CONTRIBUTING.md b/vendor/github.com/minio/minio-go/CONTRIBUTING.md
similarity index 100%
rename from internal/github.com/minio/minio-go/CONTRIBUTING.md
rename to vendor/github.com/minio/minio-go/CONTRIBUTING.md
diff --git a/internal/github.com/minio/minio-go/LICENSE b/vendor/github.com/minio/minio-go/LICENSE
similarity index 100%
rename from internal/github.com/minio/minio-go/LICENSE
rename to vendor/github.com/minio/minio-go/LICENSE
diff --git a/internal/github.com/minio/minio-go/README.md b/vendor/github.com/minio/minio-go/README.md
similarity index 100%
rename from internal/github.com/minio/minio-go/README.md
rename to vendor/github.com/minio/minio-go/README.md
diff --git a/internal/github.com/minio/minio-go/api-multipart-v1.go b/vendor/github.com/minio/minio-go/api-multipart-v1.go
similarity index 100%
rename from internal/github.com/minio/minio-go/api-multipart-v1.go
rename to vendor/github.com/minio/minio-go/api-multipart-v1.go
diff --git a/internal/github.com/minio/minio-go/api-v1.go b/vendor/github.com/minio/minio-go/api-v1.go
similarity index 100%
rename from internal/github.com/minio/minio-go/api-v1.go
rename to vendor/github.com/minio/minio-go/api-v1.go
diff --git a/internal/github.com/minio/minio-go/api-v2.go b/vendor/github.com/minio/minio-go/api-v2.go
similarity index 99%
rename from internal/github.com/minio/minio-go/api-v2.go
rename to vendor/github.com/minio/minio-go/api-v2.go
index 62f46891..6c43fbf0 100644
--- a/internal/github.com/minio/minio-go/api-v2.go
+++ b/vendor/github.com/minio/minio-go/api-v2.go
@@ -177,7 +177,7 @@ type Config struct {
// Global constants
const (
LibraryName = "minio-go"
- LibraryVersion = "0.2.2"
+ LibraryVersion = "0.2.3"
)
// SetUserAgent - append to a default user agent
diff --git a/vendor/github.com/minio/minio-go/api_handlers_test.go b/vendor/github.com/minio/minio-go/api_handlers_test.go
new file mode 100644
index 00000000..9bd23020
--- /dev/null
+++ b/vendor/github.com/minio/minio-go/api_handlers_test.go
@@ -0,0 +1,159 @@
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package minio_test
+
+// bucketHandler is an http.Handler that verifies bucket responses and validates incoming requests
+import (
+ "bytes"
+ "io"
+ "net/http"
+ "strconv"
+ "time"
+)
+
+type bucketHandler struct {
+ resource string
+}
+
+func (h bucketHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ switch {
+ case r.Method == "GET":
+ switch {
+ case r.URL.Path == "/":
+ response := []byte("bucket2015-05-20T23:05:09.230Zminiominio")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ case r.URL.Path == "/bucket":
+ _, ok := r.URL.Query()["acl"]
+ if ok {
+ response := []byte("75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06aCustomersName@amazon.com75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06aCustomersName@amazon.comFULL_CONTROL")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ return
+ }
+ fallthrough
+ case r.URL.Path == "/bucket":
+ response := []byte("\"259d04a13802ae09c7e41be50ccc6baa\"object2015-05-21T18:24:21.097Z22061miniominioSTANDARDfalse1000testbucket")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ }
+ case r.Method == "PUT":
+ switch {
+ case r.URL.Path == h.resource:
+ _, ok := r.URL.Query()["acl"]
+ if ok {
+ if r.Header.Get("x-amz-acl") != "public-read-write" {
+ w.WriteHeader(http.StatusNotImplemented)
+ }
+ }
+ w.WriteHeader(http.StatusOK)
+ default:
+ w.WriteHeader(http.StatusBadRequest)
+ }
+ case r.Method == "HEAD":
+ switch {
+ case r.URL.Path == h.resource:
+ w.WriteHeader(http.StatusOK)
+ default:
+ w.WriteHeader(http.StatusForbidden)
+ }
+ case r.Method == "DELETE":
+ switch {
+ case r.URL.Path != h.resource:
+ w.WriteHeader(http.StatusNotFound)
+ default:
+ h.resource = ""
+ w.WriteHeader(http.StatusOK)
+ }
+ }
+}
+
+// objectHandler is an http.Handler that verifies object responses and validates incoming requests
+type objectHandler struct {
+ resource string
+ data []byte
+}
+
+func (h objectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+ switch {
+ case r.Method == "PUT":
+ length, err := strconv.Atoi(r.Header.Get("Content-Length"))
+ if err != nil {
+ w.WriteHeader(http.StatusBadRequest)
+ return
+ }
+ var buffer bytes.Buffer
+ _, err = io.CopyN(&buffer, r.Body, int64(length))
+ if err != nil {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+ if !bytes.Equal(h.data, buffer.Bytes()) {
+ w.WriteHeader(http.StatusInternalServerError)
+ return
+ }
+ w.Header().Set("ETag", "\"9af2f8218b150c351ad802c6f3d66abe\"")
+ w.WriteHeader(http.StatusOK)
+ case r.Method == "HEAD":
+ if r.URL.Path != h.resource {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ w.Header().Set("Content-Length", strconv.Itoa(len(h.data)))
+ w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
+ w.Header().Set("ETag", "\"9af2f8218b150c351ad802c6f3d66abe\"")
+ w.WriteHeader(http.StatusOK)
+ case r.Method == "POST":
+ _, ok := r.URL.Query()["uploads"]
+ if ok {
+ response := []byte("example-bucketobjectXXBsb2FkIElEIGZvciBlbHZpbmcncyVcdS1tb3ZpZS5tMnRzEEEwbG9hZA")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ return
+ }
+ case r.Method == "GET":
+ _, ok := r.URL.Query()["uploadId"]
+ if ok {
+ uploadID := r.URL.Query().Get("uploadId")
+ if uploadID != "XXBsb2FkIElEIGZvciBlbHZpbmcncyVcdS1tb3ZpZS5tMnRzEEEwbG9hZA" {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ response := []byte("example-bucketexample-objectXXBsb2FkIElEIGZvciBlbHZpbmcncyVcdS1tb3ZpZS5tMnRzEEEwbG9hZAarn:aws:iam::111122223333:user/some-user-11116a31-17b5-4fb7-9df5-b288870f11xxumat-user-11116a31-17b5-4fb7-9df5-b288870f11xx75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06asomeNameSTANDARD132true22010-11-10T20:48:34.000Z\"7778aef83f66abc1fa1e8477f296d394\"1048576032010-11-10T20:48:33.000Z\"aaaa18db4cc2f85cedef654fccc4a4x8\"10485760")
+ w.Header().Set("Content-Length", strconv.Itoa(len(response)))
+ w.Write(response)
+ return
+ }
+ if r.URL.Path != h.resource {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ w.Header().Set("Content-Length", strconv.Itoa(len(h.data)))
+ w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
+ w.Header().Set("ETag", "\"9af2f8218b150c351ad802c6f3d66abe\"")
+ w.WriteHeader(http.StatusOK)
+ io.Copy(w, bytes.NewReader(h.data))
+ case r.Method == "DELETE":
+ if r.URL.Path != h.resource {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ h.resource = ""
+ h.data = nil
+ w.WriteHeader(http.StatusOK)
+ }
+}
diff --git a/vendor/github.com/minio/minio-go/api_private_test.go b/vendor/github.com/minio/minio-go/api_private_test.go
new file mode 100644
index 00000000..ed709859
--- /dev/null
+++ b/vendor/github.com/minio/minio-go/api_private_test.go
@@ -0,0 +1,116 @@
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package minio
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestACLTypes(t *testing.T) {
+ want := map[string]bool{
+ "private": true,
+ "public-read": true,
+ "public-read-write": true,
+ "authenticated-read": true,
+ "invalid": false,
+ }
+ for acl, ok := range want {
+ if BucketACL(acl).isValidBucketACL() != ok {
+ t.Fatal("Error")
+ }
+ }
+}
+
+func TestUserAgent(t *testing.T) {
+ conf := new(Config)
+ conf.SetUserAgent("minio", "1.0", "amd64")
+ if !strings.Contains(conf.userAgent, "minio") {
+ t.Fatalf("Error")
+ }
+}
+
+func TestGetRegion(t *testing.T) {
+ region, err := getRegion("s3.amazonaws.com")
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ if region != "us-east-1" {
+ t.Fatalf("Error")
+ }
+ region, err = getRegion("localhost:9000")
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ if region != "milkyway" {
+ t.Fatalf("Error")
+ }
+}
+
+func TestPartSize(t *testing.T) {
+ var maxPartSize int64 = 1024 * 1024 * 1024 * 5
+ partSize := calculatePartSize(5000000000000000000)
+ if partSize > minimumPartSize {
+ if partSize > maxPartSize {
+ t.Fatal("invalid result, cannot be bigger than maxPartSize 5GB")
+ }
+ }
+ partSize = calculatePartSize(50000000000)
+ if partSize > minimumPartSize {
+ t.Fatal("invalid result, cannot be bigger than minimumPartSize 5MB")
+ }
+}
+
+func TestURLEncoding(t *testing.T) {
+ type urlStrings struct {
+ name string
+ encodedName string
+ }
+
+ want := []urlStrings{
+ {
+ name: "bigfile-1._%",
+ encodedName: "bigfile-1._%25",
+ },
+ {
+ name: "本語",
+ encodedName: "%E6%9C%AC%E8%AA%9E",
+ },
+ {
+ name: "本語.1",
+ encodedName: "%E6%9C%AC%E8%AA%9E.1",
+ },
+ {
+ name: ">123>3123123",
+ encodedName: "%3E123%3E3123123",
+ },
+ {
+ name: "test 1 2.txt",
+ encodedName: "test%201%202.txt",
+ },
+ }
+
+ for _, u := range want {
+ encodedName, err := urlEncodeName(u.name)
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ if u.encodedName != encodedName {
+ t.Errorf("Error")
+ }
+ }
+}
diff --git a/vendor/github.com/minio/minio-go/api_public_test.go b/vendor/github.com/minio/minio-go/api_public_test.go
new file mode 100644
index 00000000..577ab6ab
--- /dev/null
+++ b/vendor/github.com/minio/minio-go/api_public_test.go
@@ -0,0 +1,287 @@
+/*
+ * Minio Go Library for Amazon S3 Compatible Cloud Storage (C) 2015 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package minio_test
+
+import (
+ "bytes"
+ "io"
+ "net/http/httptest"
+ "testing"
+ "time"
+
+ "github.com/minio/minio-go"
+)
+
+func TestBucketOperations(t *testing.T) {
+ bucket := bucketHandler(bucketHandler{
+ resource: "/bucket",
+ })
+ server := httptest.NewServer(bucket)
+ defer server.Close()
+
+ a, err := minio.New(minio.Config{Endpoint: server.URL})
+ if err != nil {
+ t.Errorf("Error")
+ }
+ err = a.MakeBucket("bucket", "private")
+ if err != nil {
+ t.Errorf("Error")
+ }
+
+ err = a.BucketExists("bucket")
+ if err != nil {
+ t.Errorf("Error")
+ }
+
+ err = a.BucketExists("bucket1")
+ if err == nil {
+ t.Errorf("Error")
+ }
+ if err.Error() != "Access Denied" {
+ t.Errorf("Error")
+ }
+
+ err = a.SetBucketACL("bucket", "public-read-write")
+ if err != nil {
+ t.Errorf("Error")
+ }
+
+ acl, err := a.GetBucketACL("bucket")
+ if err != nil {
+ t.Errorf("Error")
+ }
+ if acl != minio.BucketACL("private") {
+ t.Fatalf("Error")
+ }
+
+ for b := range a.ListBuckets() {
+ if b.Err != nil {
+ t.Fatalf(b.Err.Error())
+ }
+ if b.Stat.Name != "bucket" {
+ t.Errorf("Error")
+ }
+ }
+
+ for o := range a.ListObjects("bucket", "", true) {
+ if o.Err != nil {
+ t.Fatalf(o.Err.Error())
+ }
+ if o.Stat.Key != "object" {
+ t.Errorf("Error")
+ }
+ }
+
+ err = a.RemoveBucket("bucket")
+ if err != nil {
+ t.Errorf("Error")
+ }
+
+ err = a.RemoveBucket("bucket1")
+ if err == nil {
+ t.Fatalf("Error")
+ }
+ if err.Error() != "The specified bucket does not exist." {
+ t.Errorf("Error")
+ }
+}
+
+func TestBucketOperationsFail(t *testing.T) {
+ bucket := bucketHandler(bucketHandler{
+ resource: "/bucket",
+ })
+ server := httptest.NewServer(bucket)
+ defer server.Close()
+
+ a, err := minio.New(minio.Config{Endpoint: server.URL})
+ if err != nil {
+ t.Errorf("Error")
+ }
+ err = a.MakeBucket("bucket$$$", "private")
+ if err == nil {
+ t.Errorf("Error")
+ }
+
+ err = a.BucketExists("bucket.")
+ if err == nil {
+ t.Errorf("Error")
+ }
+
+ err = a.SetBucketACL("bucket-.", "public-read-write")
+ if err == nil {
+ t.Errorf("Error")
+ }
+
+ _, err = a.GetBucketACL("bucket??")
+ if err == nil {
+ t.Errorf("Error")
+ }
+
+ for o := range a.ListObjects("bucket??", "", true) {
+ if o.Err == nil {
+ t.Fatalf(o.Err.Error())
+ }
+ }
+
+ err = a.RemoveBucket("bucket??")
+ if err == nil {
+ t.Errorf("Error")
+ }
+
+ if err.Error() != "The specified bucket is not valid." {
+ t.Errorf("Error")
+ }
+}
+
+func TestObjectOperations(t *testing.T) {
+ object := objectHandler(objectHandler{
+ resource: "/bucket/object",
+ data: []byte("Hello, World"),
+ })
+ server := httptest.NewServer(object)
+ defer server.Close()
+
+ a, err := minio.New(minio.Config{Endpoint: server.URL})
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ data := []byte("Hello, World")
+ err = a.PutObject("bucket", "object", "", int64(len(data)), bytes.NewReader(data))
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ metadata, err := a.StatObject("bucket", "object")
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ if metadata.Key != "object" {
+ t.Fatalf("Error")
+ }
+ if metadata.ETag != "9af2f8218b150c351ad802c6f3d66abe" {
+ t.Fatalf("Error")
+ }
+
+ reader, metadata, err := a.GetObject("bucket", "object")
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ if metadata.Key != "object" {
+ t.Fatalf("Error")
+ }
+ if metadata.ETag != "9af2f8218b150c351ad802c6f3d66abe" {
+ t.Fatalf("Error")
+ }
+
+ var buffer bytes.Buffer
+ _, err = io.Copy(&buffer, reader)
+ if !bytes.Equal(buffer.Bytes(), data) {
+ t.Fatalf("Error")
+ }
+
+ err = a.RemoveObject("bucket", "object")
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ err = a.RemoveObject("bucket", "object1")
+ if err == nil {
+ t.Fatalf("Error")
+ }
+ if err.Error() != "The specified key does not exist." {
+ t.Errorf("Error")
+ }
+}
+
+func TestPresignedURL(t *testing.T) {
+ object := objectHandler(objectHandler{
+ resource: "/bucket/object",
+ data: []byte("Hello, World"),
+ })
+ server := httptest.NewServer(object)
+ defer server.Close()
+
+ a, err := minio.New(minio.Config{Endpoint: server.URL})
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ // should error out for invalid access keys
+ _, err = a.PresignedGetObject("bucket", "object", time.Duration(1000)*time.Second)
+ if err == nil {
+ t.Fatalf("Error")
+ }
+
+ a, err = minio.New(minio.Config{
+ Endpoint: server.URL,
+ AccessKeyID: "accessKey",
+ SecretAccessKey: "secretKey",
+ })
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ url, err := a.PresignedGetObject("bucket", "object", time.Duration(1000)*time.Second)
+ if err != nil {
+ t.Fatalf("Error")
+ }
+ if url == "" {
+ t.Fatalf("Error")
+ }
+ _, err = a.PresignedGetObject("bucket", "object", time.Duration(0)*time.Second)
+ if err == nil {
+ t.Fatalf("Error")
+ }
+ _, err = a.PresignedGetObject("bucket", "object", time.Duration(604801)*time.Second)
+ if err == nil {
+ t.Fatalf("Error")
+ }
+}
+
+func TestErrorResponse(t *testing.T) {
+ errorResponse := []byte("AccessDeniedAccess Denied/mybucket/myphoto.jpgF19772218238A85AGuWkjyviSiGHizehqpmsD1ndz5NClSP19DOT+s2mv7gXGQ8/X1lhbDGiIJEXpGFD")
+ errorReader := bytes.NewReader(errorResponse)
+ err := minio.BodyToErrorResponse(errorReader, "application/xml")
+ if err == nil {
+ t.Fatal("Error")
+ }
+ if err.Error() != "Access Denied" {
+ t.Fatal("Error")
+ }
+ resp := minio.ToErrorResponse(err)
+ // valid all fields
+ if resp == nil {
+ t.Fatal("Error")
+ }
+ if resp.Code != "AccessDenied" {
+ t.Fatal("Error")
+ }
+ if resp.RequestID != "F19772218238A85A" {
+ t.Fatal("Error")
+ }
+ if resp.Message != "Access Denied" {
+ t.Fatal("Error")
+ }
+ if resp.Resource != "/mybucket/myphoto.jpg" {
+ t.Fatal("Error")
+ }
+ if resp.HostID != "GuWkjyviSiGHizehqpmsD1ndz5NClSP19DOT+s2mv7gXGQ8/X1lhbDGiIJEXpGFD" {
+ t.Fatal("Error")
+ }
+ if resp.ToXML() == "" {
+ t.Fatal("Error")
+ }
+ if resp.ToJSON() == "" {
+ t.Fatal("Error")
+ }
+}
diff --git a/internal/github.com/minio/minio-go/bucket-acl.go b/vendor/github.com/minio/minio-go/bucket-acl.go
similarity index 100%
rename from internal/github.com/minio/minio-go/bucket-acl.go
rename to vendor/github.com/minio/minio-go/bucket-acl.go
diff --git a/internal/github.com/minio/minio-go/chopper.go b/vendor/github.com/minio/minio-go/chopper.go
similarity index 100%
rename from internal/github.com/minio/minio-go/chopper.go
rename to vendor/github.com/minio/minio-go/chopper.go
diff --git a/internal/github.com/minio/minio-go/common.go b/vendor/github.com/minio/minio-go/common.go
similarity index 100%
rename from internal/github.com/minio/minio-go/common.go
rename to vendor/github.com/minio/minio-go/common.go
diff --git a/internal/github.com/minio/minio-go/definitions.go b/vendor/github.com/minio/minio-go/definitions.go
similarity index 100%
rename from internal/github.com/minio/minio-go/definitions.go
rename to vendor/github.com/minio/minio-go/definitions.go
diff --git a/internal/github.com/minio/minio-go/errors.go b/vendor/github.com/minio/minio-go/errors.go
similarity index 100%
rename from internal/github.com/minio/minio-go/errors.go
rename to vendor/github.com/minio/minio-go/errors.go
diff --git a/internal/github.com/minio/minio-go/request.go b/vendor/github.com/minio/minio-go/request.go
similarity index 100%
rename from internal/github.com/minio/minio-go/request.go
rename to vendor/github.com/minio/minio-go/request.go
diff --git a/internal/github.com/minio/minio/pkg/probe/probe.go b/vendor/github.com/minio/minio/pkg/probe/probe.go
similarity index 98%
rename from internal/github.com/minio/minio/pkg/probe/probe.go
rename to vendor/github.com/minio/minio/pkg/probe/probe.go
index ee1e4886..a7872a8a 100644
--- a/internal/github.com/minio/minio/pkg/probe/probe.go
+++ b/vendor/github.com/minio/minio/pkg/probe/probe.go
@@ -26,7 +26,7 @@ import (
"strings"
"sync"
- "github.com/minio/mc/internal/github.com/dustin/go-humanize"
+ "github.com/dustin/go-humanize"
)
// GetSysInfo returns useful system statistics.
diff --git a/vendor/github.com/minio/minio/pkg/probe/probe_test.go b/vendor/github.com/minio/minio/pkg/probe/probe_test.go
new file mode 100644
index 00000000..b27ab270
--- /dev/null
+++ b/vendor/github.com/minio/minio/pkg/probe/probe_test.go
@@ -0,0 +1,61 @@
+/*
+ * Minio Cloud Storage, (C) 2015 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package probe_test
+
+import (
+ "os"
+ "testing"
+
+ "github.com/minio/minio/pkg/probe"
+ . "gopkg.in/check.v1"
+)
+
+func Test(t *testing.T) { TestingT(t) }
+
+type MySuite struct{}
+
+var _ = Suite(&MySuite{})
+
+func testDummy0() *probe.Error {
+ _, e := os.Stat("this-file-cannot-exit")
+ return probe.NewError(e)
+}
+
+func testDummy1() *probe.Error {
+ return testDummy0().Trace("DummyTag1")
+}
+
+func testDummy2() *probe.Error {
+ return testDummy1().Trace("DummyTag2")
+}
+
+func (s *MySuite) TestProbe(c *C) {
+ es := testDummy2().Trace("TopOfStack")
+ // Uncomment the following Println to visually test probe call trace.
+ // fmt.Println("Expecting a simulated error here.", es)
+ c.Assert(es, Not(Equals), nil)
+
+ newES := es.Trace()
+ c.Assert(newES, Not(Equals), nil)
+}
+
+func (s *MySuite) TestWrappedError(c *C) {
+ _, e := os.Stat("this-file-cannot-exit")
+ es := probe.NewError(e) // *probe.Error
+ e = probe.WrapError(es) // *probe.WrappedError
+ _, ok := probe.UnwrapError(e)
+ c.Assert(ok, Equals, true)
+}
diff --git a/internal/github.com/minio/minio/pkg/probe/wrapper.go b/vendor/github.com/minio/minio/pkg/probe/wrapper.go
similarity index 100%
rename from internal/github.com/minio/minio/pkg/probe/wrapper.go
rename to vendor/github.com/minio/minio/pkg/probe/wrapper.go
diff --git a/internal/github.com/minio/minio/pkg/quick/quick.go b/vendor/github.com/minio/minio/pkg/quick/quick.go
similarity index 97%
rename from internal/github.com/minio/minio/pkg/quick/quick.go
rename to vendor/github.com/minio/minio/pkg/quick/quick.go
index b0a776f7..c0b34193 100644
--- a/internal/github.com/minio/minio/pkg/quick/quick.go
+++ b/vendor/github.com/minio/minio/pkg/quick/quick.go
@@ -28,8 +28,8 @@ import (
"strings"
"sync"
- "github.com/minio/mc/internal/github.com/fatih/structs"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/fatih/structs"
+ "github.com/minio/minio/pkg/probe"
)
// Config - generic config interface functions
diff --git a/vendor/github.com/minio/minio/pkg/quick/quick_test.go b/vendor/github.com/minio/minio/pkg/quick/quick_test.go
new file mode 100644
index 00000000..4a7c30cb
--- /dev/null
+++ b/vendor/github.com/minio/minio/pkg/quick/quick_test.go
@@ -0,0 +1,146 @@
+/*
+ * Quick - Quick key value store for config files and persistent state files
+ *
+ * Minio Client (C) 2015 Minio, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package quick_test
+
+import (
+ "os"
+ "testing"
+
+ "github.com/minio/minio/pkg/quick"
+ . "gopkg.in/check.v1"
+)
+
+func Test(t *testing.T) { TestingT(t) }
+
+type MySuite struct{}
+
+var _ = Suite(&MySuite{})
+
+func (s *MySuite) TestCheckData(c *C) {
+ err := quick.CheckData(nil)
+ c.Assert(err, Not(IsNil))
+
+ type myStructBad struct {
+ User string
+ Password string
+ Folders []string
+ }
+ saveMeBad := myStructBad{"guest", "nopassword", []string{"Work", "Documents", "Music"}}
+ err = quick.CheckData(&saveMeBad)
+ c.Assert(err, Not(IsNil))
+
+ type myStructGood struct {
+ Version string
+ User string
+ Password string
+ Folders []string
+ }
+
+ saveMeGood := myStructGood{"1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
+ err = quick.CheckData(&saveMeGood)
+ c.Assert(err, IsNil)
+}
+
+func (s *MySuite) TestSaveLoad(c *C) {
+ defer os.RemoveAll("test.json")
+ type myStruct struct {
+ Version string
+ User string
+ Password string
+ Folders []string
+ }
+ saveMe := myStruct{"1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
+ config, err := quick.New(&saveMe)
+ c.Assert(err, IsNil)
+ c.Assert(config, Not(IsNil))
+ config.Save("test.json")
+
+ loadMe := myStruct{Version: "1"}
+ newConfig, err := quick.New(&loadMe)
+ c.Assert(err, IsNil)
+ c.Assert(newConfig, Not(IsNil))
+ newConfig.Load("test.json")
+
+ c.Assert(config.Data(), DeepEquals, newConfig.Data())
+ c.Assert(config.Data(), DeepEquals, &loadMe)
+
+ mismatch := myStruct{"1.1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
+ c.Assert(newConfig.Data(), Not(DeepEquals), &mismatch)
+}
+
+func (s *MySuite) TestDiff(c *C) {
+ type myStruct struct {
+ Version string
+ User string
+ Password string
+ Folders []string
+ }
+ saveMe := myStruct{"1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
+ config, err := quick.New(&saveMe)
+ c.Assert(err, IsNil)
+ c.Assert(config, Not(IsNil))
+
+ type myNewStruct struct {
+ Version string
+ // User string
+ Password string
+ Folders []string
+ }
+
+ mismatch := myNewStruct{"1", "nopassword", []string{"Work", "documents", "Music"}}
+ newConfig, err := quick.New(&mismatch)
+ c.Assert(err, IsNil)
+ c.Assert(newConfig, Not(IsNil))
+
+ fields, ok := config.Diff(newConfig)
+ c.Assert(ok, IsNil)
+ c.Assert(len(fields), Equals, 1)
+
+ // Uncomment for debugging
+ // for i, field := range fields {
+ // fmt.Printf("Diff[%d]: %s=%v\n", i, field.Name(), field.Value())
+ // }
+}
+
+func (s *MySuite) TestDeepDiff(c *C) {
+ type myStruct struct {
+ Version string
+ User string
+ Password string
+ Folders []string
+ }
+ saveMe := myStruct{"1", "guest", "nopassword", []string{"Work", "Documents", "Music"}}
+ config, err := quick.New(&saveMe)
+ c.Assert(err, IsNil)
+ c.Assert(config, Not(IsNil))
+
+ mismatch := myStruct{"1", "Guest", "nopassword", []string{"Work", "documents", "Music"}}
+ newConfig, err := quick.New(&mismatch)
+ c.Assert(err, IsNil)
+ c.Assert(newConfig, Not(IsNil))
+
+ fields, err := config.DeepDiff(newConfig)
+ c.Assert(err, IsNil)
+ c.Assert(len(fields), Equals, 2)
+
+ // Uncomment for debugging
+ // for i, field := range fields {
+ // fmt.Printf("DeepDiff[%d]: %s=%v\n", i, field.Name(), field.Value())
+ // }
+}
diff --git a/internal/github.com/minio/pb/LICENSE b/vendor/github.com/minio/pb/LICENSE
similarity index 100%
rename from internal/github.com/minio/pb/LICENSE
rename to vendor/github.com/minio/pb/LICENSE
diff --git a/internal/github.com/minio/pb/README.md b/vendor/github.com/minio/pb/README.md
similarity index 100%
rename from internal/github.com/minio/pb/README.md
rename to vendor/github.com/minio/pb/README.md
diff --git a/internal/github.com/minio/pb/format.go b/vendor/github.com/minio/pb/format.go
similarity index 100%
rename from internal/github.com/minio/pb/format.go
rename to vendor/github.com/minio/pb/format.go
diff --git a/vendor/github.com/minio/pb/format_test.go b/vendor/github.com/minio/pb/format_test.go
new file mode 100644
index 00000000..b76275e2
--- /dev/null
+++ b/vendor/github.com/minio/pb/format_test.go
@@ -0,0 +1,37 @@
+package pb
+
+import (
+ "fmt"
+ "strconv"
+ "testing"
+)
+
+func Test_DefaultsToInteger(t *testing.T) {
+ value := int64(1000)
+ expected := strconv.Itoa(int(value))
+ actual := Format(value, -1)
+
+ if actual != expected {
+ t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
+ }
+}
+
+func Test_CanFormatAsInteger(t *testing.T) {
+ value := int64(1000)
+ expected := strconv.Itoa(int(value))
+ actual := Format(value, U_NO)
+
+ if actual != expected {
+ t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
+ }
+}
+
+func Test_CanFormatAsBytes(t *testing.T) {
+ value := int64(1000)
+ expected := "1000 B"
+ actual := Format(value, U_BYTES)
+
+ if actual != expected {
+ t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
+ }
+}
diff --git a/internal/github.com/minio/pb/pb.go b/vendor/github.com/minio/pb/pb.go
similarity index 100%
rename from internal/github.com/minio/pb/pb.go
rename to vendor/github.com/minio/pb/pb.go
diff --git a/internal/github.com/minio/pb/pb_nix.go b/vendor/github.com/minio/pb/pb_nix.go
similarity index 100%
rename from internal/github.com/minio/pb/pb_nix.go
rename to vendor/github.com/minio/pb/pb_nix.go
diff --git a/internal/github.com/minio/pb/pb_solaris.go b/vendor/github.com/minio/pb/pb_solaris.go
similarity index 100%
rename from internal/github.com/minio/pb/pb_solaris.go
rename to vendor/github.com/minio/pb/pb_solaris.go
diff --git a/vendor/github.com/minio/pb/pb_test.go b/vendor/github.com/minio/pb/pb_test.go
new file mode 100644
index 00000000..dfe394fd
--- /dev/null
+++ b/vendor/github.com/minio/pb/pb_test.go
@@ -0,0 +1,37 @@
+package pb
+
+import (
+ "testing"
+)
+
+func Test_IncrementAddsOne(t *testing.T) {
+ count := 5000
+ bar := New(count)
+ expected := 1
+ actual := bar.Increment()
+
+ if actual != expected {
+ t.Errorf("Expected {%d} was {%d}", expected, actual)
+ }
+}
+
+func Test_Width(t *testing.T) {
+ count := 5000
+ bar := New(count)
+ width := 100
+ bar.SetWidth(100).Callback = func(out string) {
+ if len(out) != width {
+ t.Errorf("Bar width expected {%d} was {%d}", len(out), width)
+ }
+ }
+ bar.Start()
+ bar.Increment()
+ bar.Finish()
+}
+
+func Test_MultipleFinish(t *testing.T) {
+ bar := New(5000)
+ bar.Add(2000)
+ bar.Finish()
+ bar.Finish()
+}
diff --git a/internal/github.com/minio/pb/pb_win.go b/vendor/github.com/minio/pb/pb_win.go
similarity index 75%
rename from internal/github.com/minio/pb/pb_win.go
rename to vendor/github.com/minio/pb/pb_win.go
index 537534ce..eb36190c 100644
--- a/internal/github.com/minio/pb/pb_win.go
+++ b/vendor/github.com/minio/pb/pb_win.go
@@ -3,7 +3,7 @@
package pb
import (
- "github.com/minio/mc/internal/github.com/olekukonko/ts"
+ "github.com/olekukonko/ts"
)
func bold(str string) string {
diff --git a/internal/github.com/minio/pb/pb_x.go b/vendor/github.com/minio/pb/pb_x.go
similarity index 100%
rename from internal/github.com/minio/pb/pb_x.go
rename to vendor/github.com/minio/pb/pb_x.go
diff --git a/internal/github.com/minio/pb/reader.go b/vendor/github.com/minio/pb/reader.go
similarity index 100%
rename from internal/github.com/minio/pb/reader.go
rename to vendor/github.com/minio/pb/reader.go
diff --git a/internal/github.com/olekukonko/ts/LICENCE b/vendor/github.com/olekukonko/ts/LICENCE
similarity index 100%
rename from internal/github.com/olekukonko/ts/LICENCE
rename to vendor/github.com/olekukonko/ts/LICENCE
diff --git a/internal/github.com/olekukonko/ts/README.md b/vendor/github.com/olekukonko/ts/README.md
similarity index 100%
rename from internal/github.com/olekukonko/ts/README.md
rename to vendor/github.com/olekukonko/ts/README.md
diff --git a/internal/github.com/olekukonko/ts/doc.go b/vendor/github.com/olekukonko/ts/doc.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/doc.go
rename to vendor/github.com/olekukonko/ts/doc.go
diff --git a/internal/github.com/olekukonko/ts/ts.go b/vendor/github.com/olekukonko/ts/ts.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts.go
rename to vendor/github.com/olekukonko/ts/ts.go
diff --git a/internal/github.com/olekukonko/ts/ts_darwin.go b/vendor/github.com/olekukonko/ts/ts_darwin.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts_darwin.go
rename to vendor/github.com/olekukonko/ts/ts_darwin.go
diff --git a/internal/github.com/olekukonko/ts/ts_linux.go b/vendor/github.com/olekukonko/ts/ts_linux.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts_linux.go
rename to vendor/github.com/olekukonko/ts/ts_linux.go
diff --git a/internal/github.com/olekukonko/ts/ts_other.go b/vendor/github.com/olekukonko/ts/ts_other.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts_other.go
rename to vendor/github.com/olekukonko/ts/ts_other.go
diff --git a/vendor/github.com/olekukonko/ts/ts_test.go b/vendor/github.com/olekukonko/ts/ts_test.go
new file mode 100644
index 00000000..4998e7c0
--- /dev/null
+++ b/vendor/github.com/olekukonko/ts/ts_test.go
@@ -0,0 +1,32 @@
+// Copyright 2014 Oleku Konko All rights reserved.
+// Use of this source code is governed by a MIT
+// license that can be found in the LICENSE file.
+
+// This module is a Terminal API for the Go Programming Language.
+// The protocols were written in pure Go and works on windows and unix systems
+
+package ts
+
+import (
+ "fmt"
+ "testing"
+)
+
+func ExampleGetSize() {
+ size, _ := GetSize()
+ fmt.Println(size.Col()) // Get Width
+ fmt.Println(size.Row()) // Get Height
+ fmt.Println(size.PosX()) // Get X position
+ fmt.Println(size.PosY()) // Get Y position
+}
+
+func TestSize(t *testing.T) {
+ size, err := GetSize()
+
+ if err != nil {
+ t.Fatal(err)
+ }
+ if size.Col() == 0 || size.Row() == 0 {
+ t.Fatalf("Screen Size Failed")
+ }
+}
diff --git a/internal/github.com/olekukonko/ts/ts_unix.go b/vendor/github.com/olekukonko/ts/ts_unix.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts_unix.go
rename to vendor/github.com/olekukonko/ts/ts_unix.go
diff --git a/internal/github.com/olekukonko/ts/ts_windows.go b/vendor/github.com/olekukonko/ts/ts_windows.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts_windows.go
rename to vendor/github.com/olekukonko/ts/ts_windows.go
diff --git a/internal/github.com/olekukonko/ts/ts_x.go b/vendor/github.com/olekukonko/ts/ts_x.go
similarity index 100%
rename from internal/github.com/olekukonko/ts/ts_x.go
rename to vendor/github.com/olekukonko/ts/ts_x.go
diff --git a/internal/github.com/shiena/ansicolor/LICENSE b/vendor/github.com/shiena/ansicolor/LICENSE
similarity index 100%
rename from internal/github.com/shiena/ansicolor/LICENSE
rename to vendor/github.com/shiena/ansicolor/LICENSE
diff --git a/internal/github.com/shiena/ansicolor/README.md b/vendor/github.com/shiena/ansicolor/README.md
similarity index 100%
rename from internal/github.com/shiena/ansicolor/README.md
rename to vendor/github.com/shiena/ansicolor/README.md
diff --git a/internal/github.com/shiena/ansicolor/ansicolor.go b/vendor/github.com/shiena/ansicolor/ansicolor.go
similarity index 100%
rename from internal/github.com/shiena/ansicolor/ansicolor.go
rename to vendor/github.com/shiena/ansicolor/ansicolor.go
diff --git a/internal/github.com/shiena/ansicolor/ansicolor_ansi.go b/vendor/github.com/shiena/ansicolor/ansicolor_ansi.go
similarity index 100%
rename from internal/github.com/shiena/ansicolor/ansicolor_ansi.go
rename to vendor/github.com/shiena/ansicolor/ansicolor_ansi.go
diff --git a/vendor/github.com/shiena/ansicolor/ansicolor_test.go b/vendor/github.com/shiena/ansicolor/ansicolor_test.go
new file mode 100644
index 00000000..4feeb1de
--- /dev/null
+++ b/vendor/github.com/shiena/ansicolor/ansicolor_test.go
@@ -0,0 +1,25 @@
+package ansicolor_test
+
+import (
+ "bytes"
+ "testing"
+
+ "github.com/shiena/ansicolor"
+)
+
+func TestNewAnsiColor1(t *testing.T) {
+ inner := bytes.NewBufferString("")
+ w := ansicolor.NewAnsiColorWriter(inner)
+ if w == inner {
+ t.Errorf("Get %#v, want %#v", w, inner)
+ }
+}
+
+func TestNewAnsiColor2(t *testing.T) {
+ inner := bytes.NewBufferString("")
+ w1 := ansicolor.NewAnsiColorWriter(inner)
+ w2 := ansicolor.NewAnsiColorWriter(w1)
+ if w1 != w2 {
+ t.Errorf("Get %#v, want %#v", w1, w2)
+ }
+}
diff --git a/internal/github.com/shiena/ansicolor/ansicolor_windows.go b/vendor/github.com/shiena/ansicolor/ansicolor_windows.go
similarity index 100%
rename from internal/github.com/shiena/ansicolor/ansicolor_windows.go
rename to vendor/github.com/shiena/ansicolor/ansicolor_windows.go
diff --git a/vendor/github.com/shiena/ansicolor/ansicolor_windows_test.go b/vendor/github.com/shiena/ansicolor/ansicolor_windows_test.go
new file mode 100644
index 00000000..6c126d51
--- /dev/null
+++ b/vendor/github.com/shiena/ansicolor/ansicolor_windows_test.go
@@ -0,0 +1,236 @@
+// Copyright 2014 shiena Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package ansicolor_test
+
+import (
+ "bytes"
+ "fmt"
+ "syscall"
+ "testing"
+
+ "github.com/shiena/ansicolor"
+ . "github.com/shiena/ansicolor"
+)
+
+func TestWritePlanText(t *testing.T) {
+ inner := bytes.NewBufferString("")
+ w := ansicolor.NewAnsiColorWriter(inner)
+ expected := "plain text"
+ fmt.Fprintf(w, expected)
+ actual := inner.String()
+ if actual != expected {
+ t.Errorf("Get %s, want %s", actual, expected)
+ }
+}
+
+func TestWriteParseText(t *testing.T) {
+ inner := bytes.NewBufferString("")
+ w := ansicolor.NewAnsiColorWriter(inner)
+
+ inputTail := "\x1b[0mtail text"
+ expectedTail := "tail text"
+ fmt.Fprintf(w, inputTail)
+ actualTail := inner.String()
+ inner.Reset()
+ if actualTail != expectedTail {
+ t.Errorf("Get %s, want %s", actualTail, expectedTail)
+ }
+
+ inputHead := "head text\x1b[0m"
+ expectedHead := "head text"
+ fmt.Fprintf(w, inputHead)
+ actualHead := inner.String()
+ inner.Reset()
+ if actualHead != expectedHead {
+ t.Errorf("Get %s, want %s", actualHead, expectedHead)
+ }
+
+ inputBothEnds := "both ends \x1b[0m text"
+ expectedBothEnds := "both ends text"
+ fmt.Fprintf(w, inputBothEnds)
+ actualBothEnds := inner.String()
+ inner.Reset()
+ if actualBothEnds != expectedBothEnds {
+ t.Errorf("Get %s, want %s", actualBothEnds, expectedBothEnds)
+ }
+
+ inputManyEsc := "\x1b\x1b\x1b\x1b[0m many esc"
+ expectedManyEsc := "\x1b\x1b\x1b many esc"
+ fmt.Fprintf(w, inputManyEsc)
+ actualManyEsc := inner.String()
+ inner.Reset()
+ if actualManyEsc != expectedManyEsc {
+ t.Errorf("Get %s, want %s", actualManyEsc, expectedManyEsc)
+ }
+
+ expectedSplit := "split text"
+ for _, ch := range "split \x1b[0m text" {
+ fmt.Fprintf(w, string(ch))
+ }
+ actualSplit := inner.String()
+ inner.Reset()
+ if actualSplit != expectedSplit {
+ t.Errorf("Get %s, want %s", actualSplit, expectedSplit)
+ }
+}
+
+type screenNotFoundError struct {
+ error
+}
+
+func writeAnsiColor(expectedText, colorCode string) (actualText string, actualAttributes uint16, err error) {
+ inner := bytes.NewBufferString("")
+ w := ansicolor.NewAnsiColorWriter(inner)
+ fmt.Fprintf(w, "\x1b[%sm%s", colorCode, expectedText)
+
+ actualText = inner.String()
+ screenInfo := GetConsoleScreenBufferInfo(uintptr(syscall.Stdout))
+ if screenInfo != nil {
+ actualAttributes = screenInfo.WAttributes
+ } else {
+ err = &screenNotFoundError{}
+ }
+ return
+}
+
+type testParam struct {
+ text string
+ attributes uint16
+ ansiColor string
+}
+
+func TestWriteAnsiColorText(t *testing.T) {
+ screenInfo := GetConsoleScreenBufferInfo(uintptr(syscall.Stdout))
+ if screenInfo == nil {
+ t.Fatal("Could not get ConsoleScreenBufferInfo")
+ }
+ defer ChangeColor(screenInfo.WAttributes)
+ defaultFgColor := screenInfo.WAttributes & uint16(0x0007)
+ defaultBgColor := screenInfo.WAttributes & uint16(0x0070)
+ defaultFgIntensity := screenInfo.WAttributes & uint16(0x0008)
+ defaultBgIntensity := screenInfo.WAttributes & uint16(0x0080)
+
+ fgParam := []testParam{
+ {"foreground black ", uint16(0x0000 | 0x0000), "30"},
+ {"foreground red ", uint16(0x0004 | 0x0000), "31"},
+ {"foreground green ", uint16(0x0002 | 0x0000), "32"},
+ {"foreground yellow ", uint16(0x0006 | 0x0000), "33"},
+ {"foreground blue ", uint16(0x0001 | 0x0000), "34"},
+ {"foreground magenta", uint16(0x0005 | 0x0000), "35"},
+ {"foreground cyan ", uint16(0x0003 | 0x0000), "36"},
+ {"foreground white ", uint16(0x0007 | 0x0000), "37"},
+ {"foreground default", defaultFgColor | 0x0000, "39"},
+ {"foreground light gray ", uint16(0x0000 | 0x0008 | 0x0000), "90"},
+ {"foreground light red ", uint16(0x0004 | 0x0008 | 0x0000), "91"},
+ {"foreground light green ", uint16(0x0002 | 0x0008 | 0x0000), "92"},
+ {"foreground light yellow ", uint16(0x0006 | 0x0008 | 0x0000), "93"},
+ {"foreground light blue ", uint16(0x0001 | 0x0008 | 0x0000), "94"},
+ {"foreground light magenta", uint16(0x0005 | 0x0008 | 0x0000), "95"},
+ {"foreground light cyan ", uint16(0x0003 | 0x0008 | 0x0000), "96"},
+ {"foreground light white ", uint16(0x0007 | 0x0008 | 0x0000), "97"},
+ }
+
+ bgParam := []testParam{
+ {"background black ", uint16(0x0007 | 0x0000), "40"},
+ {"background red ", uint16(0x0007 | 0x0040), "41"},
+ {"background green ", uint16(0x0007 | 0x0020), "42"},
+ {"background yellow ", uint16(0x0007 | 0x0060), "43"},
+ {"background blue ", uint16(0x0007 | 0x0010), "44"},
+ {"background magenta", uint16(0x0007 | 0x0050), "45"},
+ {"background cyan ", uint16(0x0007 | 0x0030), "46"},
+ {"background white ", uint16(0x0007 | 0x0070), "47"},
+ {"background default", uint16(0x0007) | defaultBgColor, "49"},
+ {"background light gray ", uint16(0x0007 | 0x0000 | 0x0080), "100"},
+ {"background light red ", uint16(0x0007 | 0x0040 | 0x0080), "101"},
+ {"background light green ", uint16(0x0007 | 0x0020 | 0x0080), "102"},
+ {"background light yellow ", uint16(0x0007 | 0x0060 | 0x0080), "103"},
+ {"background light blue ", uint16(0x0007 | 0x0010 | 0x0080), "104"},
+ {"background light magenta", uint16(0x0007 | 0x0050 | 0x0080), "105"},
+ {"background light cyan ", uint16(0x0007 | 0x0030 | 0x0080), "106"},
+ {"background light white ", uint16(0x0007 | 0x0070 | 0x0080), "107"},
+ }
+
+ resetParam := []testParam{
+ {"all reset", defaultFgColor | defaultBgColor | defaultFgIntensity | defaultBgIntensity, "0"},
+ {"all reset", defaultFgColor | defaultBgColor | defaultFgIntensity | defaultBgIntensity, ""},
+ }
+
+ boldParam := []testParam{
+ {"bold on", uint16(0x0007 | 0x0008), "1"},
+ {"bold off", uint16(0x0007), "21"},
+ }
+
+ underscoreParam := []testParam{
+ {"underscore on", uint16(0x0007 | 0x8000), "4"},
+ {"underscore off", uint16(0x0007), "24"},
+ }
+
+ blinkParam := []testParam{
+ {"blink on", uint16(0x0007 | 0x0080), "5"},
+ {"blink off", uint16(0x0007), "25"},
+ }
+
+ mixedParam := []testParam{
+ {"both black, bold, underline, blink", uint16(0x0000 | 0x0000 | 0x0008 | 0x8000 | 0x0080), "30;40;1;4;5"},
+ {"both red, bold, underline, blink", uint16(0x0004 | 0x0040 | 0x0008 | 0x8000 | 0x0080), "31;41;1;4;5"},
+ {"both green, bold, underline, blink", uint16(0x0002 | 0x0020 | 0x0008 | 0x8000 | 0x0080), "32;42;1;4;5"},
+ {"both yellow, bold, underline, blink", uint16(0x0006 | 0x0060 | 0x0008 | 0x8000 | 0x0080), "33;43;1;4;5"},
+ {"both blue, bold, underline, blink", uint16(0x0001 | 0x0010 | 0x0008 | 0x8000 | 0x0080), "34;44;1;4;5"},
+ {"both magenta, bold, underline, blink", uint16(0x0005 | 0x0050 | 0x0008 | 0x8000 | 0x0080), "35;45;1;4;5"},
+ {"both cyan, bold, underline, blink", uint16(0x0003 | 0x0030 | 0x0008 | 0x8000 | 0x0080), "36;46;1;4;5"},
+ {"both white, bold, underline, blink", uint16(0x0007 | 0x0070 | 0x0008 | 0x8000 | 0x0080), "37;47;1;4;5"},
+ {"both default, bold, underline, blink", uint16(defaultFgColor | defaultBgColor | 0x0008 | 0x8000 | 0x0080), "39;49;1;4;5"},
+ }
+
+ assertTextAttribute := func(expectedText string, expectedAttributes uint16, ansiColor string) {
+ actualText, actualAttributes, err := writeAnsiColor(expectedText, ansiColor)
+ if actualText != expectedText {
+ t.Errorf("Get %s, want %s", actualText, expectedText)
+ }
+ if err != nil {
+ t.Fatal("Could not get ConsoleScreenBufferInfo")
+ }
+ if actualAttributes != expectedAttributes {
+ t.Errorf("Text: %s, Get 0x%04x, want 0x%04x", expectedText, actualAttributes, expectedAttributes)
+ }
+ }
+
+ for _, v := range fgParam {
+ ResetColor()
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+
+ for _, v := range bgParam {
+ ChangeColor(uint16(0x0070 | 0x0007))
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+
+ for _, v := range resetParam {
+ ChangeColor(uint16(0x0000 | 0x0070 | 0x0008))
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+
+ ResetColor()
+ for _, v := range boldParam {
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+
+ ResetColor()
+ for _, v := range underscoreParam {
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+
+ ResetColor()
+ for _, v := range blinkParam {
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+
+ for _, v := range mixedParam {
+ ResetColor()
+ assertTextAttribute(v.text, v.attributes, v.ansiColor)
+ }
+}
diff --git a/vendor/github.com/shiena/ansicolor/example_test.go b/vendor/github.com/shiena/ansicolor/example_test.go
new file mode 100644
index 00000000..f2ac67c1
--- /dev/null
+++ b/vendor/github.com/shiena/ansicolor/example_test.go
@@ -0,0 +1,24 @@
+// Copyright 2014 shiena Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package ansicolor_test
+
+import (
+ "fmt"
+ "os"
+
+ "github.com/shiena/ansicolor"
+)
+
+func ExampleNewAnsiColorWriter() {
+ w := ansicolor.NewAnsiColorWriter(os.Stdout)
+ text := "%sforeground %sbold%s %sbackground%s\n"
+ fmt.Fprintf(w, text, "\x1b[31m", "\x1b[1m", "\x1b[21m", "\x1b[41;32m", "\x1b[0m")
+ fmt.Fprintf(w, text, "\x1b[32m", "\x1b[1m", "\x1b[21m", "\x1b[42;31m", "\x1b[0m")
+ fmt.Fprintf(w, text, "\x1b[33m", "\x1b[1m", "\x1b[21m", "\x1b[43;34m", "\x1b[0m")
+ fmt.Fprintf(w, text, "\x1b[34m", "\x1b[1m", "\x1b[21m", "\x1b[44;33m", "\x1b[0m")
+ fmt.Fprintf(w, text, "\x1b[35m", "\x1b[1m", "\x1b[21m", "\x1b[45;36m", "\x1b[0m")
+ fmt.Fprintf(w, text, "\x1b[36m", "\x1b[1m", "\x1b[21m", "\x1b[46;35m", "\x1b[0m")
+ fmt.Fprintf(w, text, "\x1b[37m", "\x1b[1m", "\x1b[21m", "\x1b[47;30m", "\x1b[0m")
+}
diff --git a/vendor/github.com/shiena/ansicolor/export_test.go b/vendor/github.com/shiena/ansicolor/export_test.go
new file mode 100644
index 00000000..6d2f7c07
--- /dev/null
+++ b/vendor/github.com/shiena/ansicolor/export_test.go
@@ -0,0 +1,19 @@
+// Copyright 2014 shiena Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+// +build windows
+
+package ansicolor
+
+import "syscall"
+
+var GetConsoleScreenBufferInfo = getConsoleScreenBufferInfo
+
+func ChangeColor(color uint16) {
+ setConsoleTextAttribute(uintptr(syscall.Stdout), color)
+}
+
+func ResetColor() {
+ ChangeColor(uint16(0x0007))
+}
diff --git a/internal/github.com/tchap/go-patricia/patricia/children.go b/vendor/github.com/tchap/go-patricia/patricia/children.go
similarity index 100%
rename from internal/github.com/tchap/go-patricia/patricia/children.go
rename to vendor/github.com/tchap/go-patricia/patricia/children.go
diff --git a/internal/github.com/tchap/go-patricia/patricia/patricia.go b/vendor/github.com/tchap/go-patricia/patricia/patricia.go
similarity index 100%
rename from internal/github.com/tchap/go-patricia/patricia/patricia.go
rename to vendor/github.com/tchap/go-patricia/patricia/patricia.go
diff --git a/vendor/github.com/tchap/go-patricia/patricia/patricia_dense_test.go b/vendor/github.com/tchap/go-patricia/patricia/patricia_dense_test.go
new file mode 100644
index 00000000..96089fce
--- /dev/null
+++ b/vendor/github.com/tchap/go-patricia/patricia/patricia_dense_test.go
@@ -0,0 +1,161 @@
+// Copyright (c) 2014 The go-patricia AUTHORS
+//
+// Use of this source code is governed by The MIT License
+// that can be found in the LICENSE file.
+
+package patricia
+
+import (
+ "testing"
+)
+
+// Tests -----------------------------------------------------------------------
+
+func TestTrie_InsertDense(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"aba", 0, success},
+ {"abb", 1, success},
+ {"abc", 2, success},
+ {"abd", 3, success},
+ {"abe", 4, success},
+ {"abf", 5, success},
+ {"abg", 6, success},
+ {"abh", 7, success},
+ {"abi", 8, success},
+ {"abj", 9, success},
+ {"abk", 0, success},
+ {"abl", 1, success},
+ {"abm", 2, success},
+ {"abn", 3, success},
+ {"abo", 4, success},
+ {"abp", 5, success},
+ {"abq", 6, success},
+ {"abr", 7, success},
+ {"abs", 8, success},
+ {"abt", 9, success},
+ {"abu", 0, success},
+ {"abv", 1, success},
+ {"abw", 2, success},
+ {"abx", 3, success},
+ {"aby", 4, success},
+ {"abz", 5, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestTrie_InsertDensePreceeding(t *testing.T) {
+ trie := NewTrie()
+ start := byte(70)
+ // create a dense node
+ for i := byte(0); i <= DefaultMaxChildrenPerSparseNode; i++ {
+ if !trie.Insert(Prefix([]byte{start + i}), true) {
+ t.Errorf("insert failed, prefix=%v", start+i)
+ }
+ }
+ // insert some preceeding keys
+ for i := byte(1); i < start; i *= i + 1 {
+ if !trie.Insert(Prefix([]byte{start - i}), true) {
+ t.Errorf("insert failed, prefix=%v", start-i)
+ }
+ }
+}
+
+func TestTrie_InsertDenseDuplicatePrefixes(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"aba", 0, success},
+ {"abb", 1, success},
+ {"abc", 2, success},
+ {"abd", 3, success},
+ {"abe", 4, success},
+ {"abf", 5, success},
+ {"abg", 6, success},
+ {"abh", 7, success},
+ {"abi", 8, success},
+ {"abj", 9, success},
+ {"abk", 0, success},
+ {"abl", 1, success},
+ {"abm", 2, success},
+ {"abn", 3, success},
+ {"abo", 4, success},
+ {"abp", 5, success},
+ {"abq", 6, success},
+ {"abr", 7, success},
+ {"abs", 8, success},
+ {"abt", 9, success},
+ {"abu", 0, success},
+ {"abv", 1, success},
+ {"abw", 2, success},
+ {"abx", 3, success},
+ {"aby", 4, success},
+ {"abz", 5, success},
+ {"aba", 0, failure},
+ {"abb", 1, failure},
+ {"abc", 2, failure},
+ {"abd", 3, failure},
+ {"abe", 4, failure},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestTrie_DeleteDense(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"aba", 0, success},
+ {"abb", 1, success},
+ {"abc", 2, success},
+ {"abd", 3, success},
+ {"abe", 4, success},
+ {"abf", 5, success},
+ {"abg", 6, success},
+ {"abh", 7, success},
+ {"abi", 8, success},
+ {"abj", 9, success},
+ {"abk", 0, success},
+ {"abl", 1, success},
+ {"abm", 2, success},
+ {"abn", 3, success},
+ {"abo", 4, success},
+ {"abp", 5, success},
+ {"abq", 6, success},
+ {"abr", 7, success},
+ {"abs", 8, success},
+ {"abt", 9, success},
+ {"abu", 0, success},
+ {"abv", 1, success},
+ {"abw", 2, success},
+ {"abx", 3, success},
+ {"aby", 4, success},
+ {"abz", 5, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range data {
+ t.Logf("DELETE word=%v, success=%v", v.key, v.retVal)
+ if ok := trie.Delete([]byte(v.key)); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
diff --git a/vendor/github.com/tchap/go-patricia/patricia/patricia_sparse_test.go b/vendor/github.com/tchap/go-patricia/patricia/patricia_sparse_test.go
new file mode 100644
index 00000000..ab97d1e5
--- /dev/null
+++ b/vendor/github.com/tchap/go-patricia/patricia/patricia_sparse_test.go
@@ -0,0 +1,659 @@
+// Copyright (c) 2014 The go-patricia AUTHORS
+//
+// Use of this source code is governed by The MIT License
+// that can be found in the LICENSE file.
+
+package patricia
+
+import (
+ "bytes"
+ "errors"
+ "fmt"
+ "strings"
+ "testing"
+)
+
+const (
+ success = true
+ failure = false
+)
+
+type testData struct {
+ key string
+ value interface{}
+ retVal bool
+}
+
+// Tests -----------------------------------------------------------------------
+
+func TestTrie_InsertDifferentPrefixes(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepaneeeeeeeeeeeeee", "Pepan Zdepan", success},
+ {"Honzooooooooooooooo", "Honza Novak", success},
+ {"Jenikuuuuuuuuuuuuuu", "Jenik Poustevnicek", success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestTrie_InsertDuplicatePrefixes(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Pepan", "Pepan Zdepan", failure},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestTrie_InsertVariousPrefixes(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Pepin", "Pepin Omacka", success},
+ {"Honza", "Honza Novak", success},
+ {"Jenik", "Jenik Poustevnicek", success},
+ {"Pepan", "Pepan Dupan", failure},
+ {"Karel", "Karel Pekar", success},
+ {"Jenik", "Jenik Poustevnicek", failure},
+ {"Pepanek", "Pepanek Zemlicka", success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestTrie_InsertAndMatchPrefix(t *testing.T) {
+ trie := NewTrie()
+ t.Log("INSERT prefix=by week")
+ trie.Insert(Prefix("by week"), 2)
+ t.Log("INSERT prefix=by")
+ trie.Insert(Prefix("by"), 1)
+
+ if !trie.Match(Prefix("by")) {
+ t.Error("MATCH prefix=by, expected=true, got=false")
+ }
+}
+
+func TestTrie_SetGet(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Pepin", "Pepin Omacka", success},
+ {"Honza", "Honza Novak", success},
+ {"Jenik", "Jenik Poustevnicek", success},
+ {"Pepan", "Pepan Dupan", failure},
+ {"Karel", "Karel Pekar", success},
+ {"Jenik", "Jenik Poustevnicek", failure},
+ {"Pepanek", "Pepanek Zemlicka", success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range data {
+ t.Logf("SET %q to 10", v.key)
+ trie.Set(Prefix(v.key), 10)
+ }
+
+ for _, v := range data {
+ value := trie.Get(Prefix(v.key))
+ t.Logf("GET %q => %v", v.key, value)
+ if value.(int) != 10 {
+ t.Errorf("Unexpected return value, %v != 10", value)
+ }
+ }
+
+ if value := trie.Get(Prefix("random crap")); value != nil {
+ t.Errorf("Unexpected return value, %v != ", value)
+ }
+}
+
+func TestTrie_Match(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Pepin", "Pepin Omacka", success},
+ {"Honza", "Honza Novak", success},
+ {"Jenik", "Jenik Poustevnicek", success},
+ {"Pepan", "Pepan Dupan", failure},
+ {"Karel", "Karel Pekar", success},
+ {"Jenik", "Jenik Poustevnicek", failure},
+ {"Pepanek", "Pepanek Zemlicka", success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range data {
+ matched := trie.Match(Prefix(v.key))
+ t.Logf("MATCH %q => %v", v.key, matched)
+ if !matched {
+ t.Errorf("Inserted key %q was not matched", v.key)
+ }
+ }
+
+ if trie.Match(Prefix("random crap")) {
+ t.Errorf("Key that was not inserted matched: %q", "random crap")
+ }
+}
+
+func TestTrie_MatchFalsePositive(t *testing.T) {
+ trie := NewTrie()
+
+ if ok := trie.Insert(Prefix("A"), 1); !ok {
+ t.Fatal("INSERT prefix=A, item=1 not ok")
+ }
+
+ resultMatchSubtree := trie.MatchSubtree(Prefix("A extra"))
+ resultMatch := trie.Match(Prefix("A extra"))
+
+ if resultMatchSubtree != false {
+ t.Error("MatchSubtree returned false positive")
+ }
+
+ if resultMatch != false {
+ t.Error("Match returned false positive")
+ }
+}
+
+func TestTrie_MatchSubtree(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Pepin", "Pepin Omacka", success},
+ {"Honza", "Honza Novak", success},
+ {"Jenik", "Jenik Poustevnicek", success},
+ {"Pepan", "Pepan Dupan", failure},
+ {"Karel", "Karel Pekar", success},
+ {"Jenik", "Jenik Poustevnicek", failure},
+ {"Pepanek", "Pepanek Zemlicka", success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range data {
+ key := Prefix(v.key[:3])
+ matched := trie.MatchSubtree(key)
+ t.Logf("MATCH_SUBTREE %q => %v", key, matched)
+ if !matched {
+ t.Errorf("Subtree %q was not matched", v.key)
+ }
+ }
+}
+
+func TestTrie_Visit(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepa", 0, success},
+ {"Pepa Zdepa", 1, success},
+ {"Pepa Kuchar", 2, success},
+ {"Honza", 3, success},
+ {"Jenik", 4, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ if err := trie.Visit(func(prefix Prefix, item Item) error {
+ name := data[item.(int)].key
+ t.Logf("VISITING prefix=%q, item=%v", prefix, item)
+ if !strings.HasPrefix(string(prefix), name) {
+ t.Errorf("Unexpected prefix encountered, %q not a prefix of %q", prefix, name)
+ }
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestTrie_VisitSkipSubtree(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepa", 0, success},
+ {"Pepa Zdepa", 1, success},
+ {"Pepa Kuchar", 2, success},
+ {"Honza", 3, success},
+ {"Jenik", 4, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ if err := trie.Visit(func(prefix Prefix, item Item) error {
+ t.Logf("VISITING prefix=%q, item=%v", prefix, item)
+ if item.(int) == 0 {
+ t.Logf("SKIP %q", prefix)
+ return SkipSubtree
+ }
+ if strings.HasPrefix(string(prefix), "Pepa") {
+ t.Errorf("Unexpected prefix encountered, %q", prefix)
+ }
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestTrie_VisitReturnError(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepa", 0, success},
+ {"Pepa Zdepa", 1, success},
+ {"Pepa Kuchar", 2, success},
+ {"Honza", 3, success},
+ {"Jenik", 4, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ someErr := errors.New("Something exploded")
+ if err := trie.Visit(func(prefix Prefix, item Item) error {
+ t.Logf("VISITING prefix=%q, item=%v", prefix, item)
+ if item.(int) == 3 {
+ return someErr
+ }
+ if item.(int) != 3 {
+ t.Errorf("Unexpected prefix encountered, %q", prefix)
+ }
+ return nil
+ }); err != nil && err != someErr {
+ t.Fatal(err)
+ }
+}
+
+func TestTrie_VisitSubtree(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepa", 0, success},
+ {"Pepa Zdepa", 1, success},
+ {"Pepa Kuchar", 2, success},
+ {"Honza", 3, success},
+ {"Jenik", 4, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ var counter int
+ subtreePrefix := []byte("Pep")
+ t.Log("VISIT Pep")
+ if err := trie.VisitSubtree(subtreePrefix, func(prefix Prefix, item Item) error {
+ t.Logf("VISITING prefix=%q, item=%v", prefix, item)
+ if !bytes.HasPrefix(prefix, subtreePrefix) {
+ t.Errorf("Unexpected prefix encountered, %q does not extend %q",
+ prefix, subtreePrefix)
+ }
+ if len(prefix) > len(data[item.(int)].key) {
+ t.Fatalf("Something is rather fishy here, prefix=%q", prefix)
+ }
+ counter++
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+
+ if counter != 3 {
+ t.Error("Unexpected number of nodes visited")
+ }
+}
+
+func TestTrie_VisitPrefixes(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"P", 0, success},
+ {"Pe", 1, success},
+ {"Pep", 2, success},
+ {"Pepa", 3, success},
+ {"Pepa Zdepa", 4, success},
+ {"Pepa Kuchar", 5, success},
+ {"Honza", 6, success},
+ {"Jenik", 7, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ var counter int
+ word := []byte("Pepa")
+ if err := trie.VisitPrefixes(word, func(prefix Prefix, item Item) error {
+ t.Logf("VISITING prefix=%q, item=%v", prefix, item)
+ if !bytes.HasPrefix(word, prefix) {
+ t.Errorf("Unexpected prefix encountered, %q is not a prefix of %q",
+ prefix, word)
+ }
+ counter++
+ return nil
+ }); err != nil {
+ t.Fatal(err)
+ }
+
+ if counter != 4 {
+ t.Error("Unexpected number of nodes visited")
+ }
+}
+
+func TestParticiaTrie_Delete(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Honza", "Honza Novak", success},
+ {"Jenik", "Jenik Poustevnicek", success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range data {
+ t.Logf("DELETE word=%v, success=%v", v.key, v.retVal)
+ if ok := trie.Delete([]byte(v.key)); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestParticiaTrie_DeleteNonExistent(t *testing.T) {
+ trie := NewTrie()
+
+ insertData := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Honza", "Honza Novak", success},
+ {"Jenik", "Jenik Poustevnicek", success},
+ }
+ deleteData := []testData{
+ {"Pepan", "Pepan Zdepan", success},
+ {"Honza", "Honza Novak", success},
+ {"Pepan", "Pepan Zdepan", failure},
+ {"Jenik", "Jenik Poustevnicek", success},
+ {"Honza", "Honza Novak", failure},
+ }
+
+ for _, v := range insertData {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range deleteData {
+ t.Logf("DELETE word=%v, success=%v", v.key, v.retVal)
+ if ok := trie.Delete([]byte(v.key)); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+func TestParticiaTrie_DeleteSubtree(t *testing.T) {
+ trie := NewTrie()
+
+ insertData := []testData{
+ {"P", 0, success},
+ {"Pe", 1, success},
+ {"Pep", 2, success},
+ {"Pepa", 3, success},
+ {"Pepa Zdepa", 4, success},
+ {"Pepa Kuchar", 5, success},
+ {"Honza", 6, success},
+ {"Jenik", 7, success},
+ }
+ deleteData := []testData{
+ {"Pe", -1, success},
+ {"Pe", -1, failure},
+ {"Honzik", -1, failure},
+ {"Honza", -1, success},
+ {"Honza", -1, failure},
+ {"Pep", -1, failure},
+ {"P", -1, success},
+ {"Nobody", -1, failure},
+ {"", -1, success},
+ }
+
+ for _, v := range insertData {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ for _, v := range deleteData {
+ t.Logf("DELETE_SUBTREE prefix=%v, success=%v", v.key, v.retVal)
+ if ok := trie.DeleteSubtree([]byte(v.key)); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+}
+
+/*
+func TestTrie_Dump(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"Honda", nil, success},
+ {"Honza", nil, success},
+ {"Jenik", nil, success},
+ {"Pepan", nil, success},
+ {"Pepin", nil, success},
+ }
+
+ for i, v := range data {
+ if _, ok := trie.Insert([]byte(v.key), v.value); ok != v.retVal {
+ t.Logf("INSERT %v %v", v.key, v.value)
+ t.Fatalf("Unexpected return value, expected=%v, got=%v", i, ok)
+ }
+ }
+
+ dump := `
++--+--+ Hon +--+--+ da
+ | |
+ | +--+ za
+ |
+ +--+ Jenik
+ |
+ +--+ Pep +--+--+ an
+ |
+ +--+ in
+`
+
+ var buf bytes.Buffer
+ trie.Dump(buf)
+
+ if !bytes.Equal(buf.Bytes(), dump) {
+ t.Logf("DUMP")
+ t.Fatalf("Unexpected dump generated, expected\n\n%v\ngot\n\n%v", dump, buf.String())
+ }
+}
+*/
+
+func TestTrie_compact(t *testing.T) {
+ trie := NewTrie()
+
+ trie.Insert(Prefix("a"), 0)
+ trie.Insert(Prefix("ab"), 0)
+ trie.Insert(Prefix("abc"), 0)
+ trie.Insert(Prefix("abcd"), 0)
+ trie.Insert(Prefix("abcde"), 0)
+ trie.Insert(Prefix("abcdef"), 0)
+ trie.Insert(Prefix("abcdefg"), 0)
+ trie.Insert(Prefix("abcdefgi"), 0)
+ trie.Insert(Prefix("abcdefgij"), 0)
+ trie.Insert(Prefix("abcdefgijk"), 0)
+
+ trie.Delete(Prefix("abcdef"))
+ trie.Delete(Prefix("abcde"))
+ trie.Delete(Prefix("abcdefg"))
+
+ trie.Delete(Prefix("a"))
+ trie.Delete(Prefix("abc"))
+ trie.Delete(Prefix("ab"))
+
+ trie.Visit(func(prefix Prefix, item Item) error {
+ // 97 ~~ 'a',
+ for ch := byte(97); ch <= 107; ch++ {
+ if c := bytes.Count(prefix, []byte{ch}); c > 1 {
+ t.Errorf("%q appeared in %q %v times", ch, prefix, c)
+ }
+ }
+ return nil
+ })
+}
+
+func TestTrie_longestCommonPrefixLenght(t *testing.T) {
+ trie := NewTrie()
+ trie.prefix = []byte("1234567890")
+
+ switch {
+ case trie.longestCommonPrefixLength([]byte("")) != 0:
+ t.Fail()
+ case trie.longestCommonPrefixLength([]byte("12345")) != 5:
+ t.Fail()
+ case trie.longestCommonPrefixLength([]byte("123789")) != 3:
+ t.Fail()
+ case trie.longestCommonPrefixLength([]byte("12345678901")) != 10:
+ t.Fail()
+ }
+}
+
+// Examples --------------------------------------------------------------------
+
+func ExampleTrie() {
+ // Create a new tree.
+ trie := NewTrie()
+
+ // Insert some items.
+ trie.Insert(Prefix("Pepa Novak"), 1)
+ trie.Insert(Prefix("Pepa Sindelar"), 2)
+ trie.Insert(Prefix("Karel Macha"), 3)
+ trie.Insert(Prefix("Karel Hynek Macha"), 4)
+
+ // Just check if some things are present in the tree.
+ key := Prefix("Pepa Novak")
+ fmt.Printf("%q present? %v\n", key, trie.Match(key))
+ key = Prefix("Karel")
+ fmt.Printf("Anybody called %q here? %v\n", key, trie.MatchSubtree(key))
+
+ // Walk the tree.
+ trie.Visit(printItem)
+ // "Karel Hynek Macha": 4
+ // "Karel Macha": 3
+ // "Pepa Novak": 1
+ // "Pepa Sindelar": 2
+
+ // Walk a subtree.
+ trie.VisitSubtree(Prefix("Pepa"), printItem)
+ // "Pepa Novak": 1
+ // "Pepa Sindelar": 2
+
+ // Modify an item, then fetch it from the tree.
+ trie.Set(Prefix("Karel Hynek Macha"), 10)
+ key = Prefix("Karel Hynek Macha")
+ fmt.Printf("%q: %v\n", key, trie.Get(key))
+ // "Karel Hynek Macha": 10
+
+ // Walk prefixes.
+ prefix := Prefix("Karel Hynek Macha je kouzelnik")
+ trie.VisitPrefixes(prefix, printItem)
+ // "Karel Hynek Macha": 10
+
+ // Delete some items.
+ trie.Delete(Prefix("Pepa Novak"))
+ trie.Delete(Prefix("Karel Macha"))
+
+ // Walk again.
+ trie.Visit(printItem)
+ // "Karel Hynek Macha": 10
+ // "Pepa Sindelar": 2
+
+ // Delete a subtree.
+ trie.DeleteSubtree(Prefix("Pepa"))
+
+ // Print what is left.
+ trie.Visit(printItem)
+ // "Karel Hynek Macha": 10
+
+ // Output:
+ // "Pepa Novak" present? true
+ // Anybody called "Karel" here? true
+ // "Karel Hynek Macha": 4
+ // "Karel Macha": 3
+ // "Pepa Novak": 1
+ // "Pepa Sindelar": 2
+ // "Pepa Novak": 1
+ // "Pepa Sindelar": 2
+ // "Karel Hynek Macha": 10
+ // "Karel Hynek Macha": 10
+ // "Karel Hynek Macha": 10
+ // "Pepa Sindelar": 2
+ // "Karel Hynek Macha": 10
+}
+
+// Helpers ---------------------------------------------------------------------
+
+func printItem(prefix Prefix, item Item) error {
+ fmt.Printf("%q: %v\n", prefix, item)
+ return nil
+}
diff --git a/vendor/github.com/tchap/go-patricia/patricia/patricia_test.go b/vendor/github.com/tchap/go-patricia/patricia/patricia_test.go
new file mode 100644
index 00000000..12c441b6
--- /dev/null
+++ b/vendor/github.com/tchap/go-patricia/patricia/patricia_test.go
@@ -0,0 +1,92 @@
+// Copyright (c) 2014 The go-patricia AUTHORS
+//
+// Use of this source code is governed by The MIT License
+// that can be found in the LICENSE file.
+
+package patricia
+
+import (
+ "crypto/rand"
+ "reflect"
+ "testing"
+)
+
+// Tests -----------------------------------------------------------------------
+
+func TestTrie_ConstructorOptions(t *testing.T) {
+ trie := NewTrie(MaxPrefixPerNode(16), MaxChildrenPerSparseNode(10))
+
+ if trie.maxPrefixPerNode != 16 {
+ t.Errorf("Unexpected trie.maxPrefixPerNode value, expected=%v, got=%v",
+ 16, trie.maxPrefixPerNode)
+ }
+
+ if trie.maxChildrenPerSparseNode != 10 {
+ t.Errorf("Unexpected trie.maxChildrenPerSparseNode value, expected=%v, got=%v",
+ 10, trie.maxChildrenPerSparseNode)
+ }
+}
+
+func TestTrie_GetNonexistentPrefix(t *testing.T) {
+ trie := NewTrie()
+
+ data := []testData{
+ {"aba", 0, success},
+ }
+
+ for _, v := range data {
+ t.Logf("INSERT prefix=%v, item=%v, success=%v", v.key, v.value, v.retVal)
+ if ok := trie.Insert(Prefix(v.key), v.value); ok != v.retVal {
+ t.Errorf("Unexpected return value, expected=%v, got=%v", v.retVal, ok)
+ }
+ }
+
+ t.Logf("GET prefix=baa, expect item=nil")
+ if item := trie.Get(Prefix("baa")); item != nil {
+ t.Errorf("Unexpected return value, expected=, got=%v", item)
+ }
+}
+
+func TestTrie_RandomKitchenSink(t *testing.T) {
+ if testing.Short() {
+ t.Skip()
+ }
+ const count, size = 750000, 16
+ b := make([]byte, count+size+1)
+ if _, err := rand.Read(b); err != nil {
+ t.Fatal("error generating random bytes", err)
+ }
+ m := make(map[string]string)
+ for i := 0; i < count; i++ {
+ m[string(b[i:i+size])] = string(b[i+1 : i+size+1])
+ }
+ trie := NewTrie()
+ getAndDelete := func(k, v string) {
+ i := trie.Get(Prefix(k))
+ if i == nil {
+ t.Fatalf("item not found, prefix=%v", []byte(k))
+ } else if s, ok := i.(string); !ok {
+ t.Fatalf("unexpected item type, expecting=%v, got=%v", reflect.TypeOf(k), reflect.TypeOf(i))
+ } else if s != v {
+ t.Fatalf("unexpected item, expecting=%v, got=%v", []byte(k), []byte(s))
+ } else if !trie.Delete(Prefix(k)) {
+ t.Fatalf("delete failed, prefix=%v", []byte(k))
+ } else if i = trie.Get(Prefix(k)); i != nil {
+ t.Fatalf("unexpected item, expecting=, got=%v", i)
+ } else if trie.Delete(Prefix(k)) {
+ t.Fatalf("extra delete succeeded, prefix=%v", []byte(k))
+ }
+ }
+ for k, v := range m {
+ if !trie.Insert(Prefix(k), v) {
+ t.Fatalf("insert failed, prefix=%v", []byte(k))
+ }
+ if byte(k[size/2]) < 128 {
+ getAndDelete(k, v)
+ delete(m, k)
+ }
+ }
+ for k, v := range m {
+ getAndDelete(k, v)
+ }
+}
diff --git a/internal/gopkg.in/check.v1/LICENSE b/vendor/gopkg.in/check.v1/LICENSE
similarity index 100%
rename from internal/gopkg.in/check.v1/LICENSE
rename to vendor/gopkg.in/check.v1/LICENSE
diff --git a/internal/gopkg.in/check.v1/README.md b/vendor/gopkg.in/check.v1/README.md
similarity index 100%
rename from internal/gopkg.in/check.v1/README.md
rename to vendor/gopkg.in/check.v1/README.md
diff --git a/internal/gopkg.in/check.v1/TODO b/vendor/gopkg.in/check.v1/TODO
similarity index 100%
rename from internal/gopkg.in/check.v1/TODO
rename to vendor/gopkg.in/check.v1/TODO
diff --git a/internal/gopkg.in/check.v1/benchmark.go b/vendor/gopkg.in/check.v1/benchmark.go
similarity index 100%
rename from internal/gopkg.in/check.v1/benchmark.go
rename to vendor/gopkg.in/check.v1/benchmark.go
diff --git a/vendor/gopkg.in/check.v1/benchmark_test.go b/vendor/gopkg.in/check.v1/benchmark_test.go
new file mode 100644
index 00000000..4dd827c1
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/benchmark_test.go
@@ -0,0 +1,91 @@
+// These tests verify the test running logic.
+
+package check_test
+
+import (
+ "time"
+ . "gopkg.in/check.v1"
+)
+
+var benchmarkS = Suite(&BenchmarkS{})
+
+type BenchmarkS struct{}
+
+func (s *BenchmarkS) TestCountSuite(c *C) {
+ suitesRun += 1
+}
+
+func (s *BenchmarkS) TestBasicTestTiming(c *C) {
+ helper := FixtureHelper{sleepOn: "Test1", sleep: 1000000 * time.Nanosecond}
+ output := String{}
+ runConf := RunConf{Output: &output, Verbose: true}
+ Run(&helper, &runConf)
+
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t0\\.001s\n" +
+ "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t0\\.000s\n"
+ c.Assert(output.value, Matches, expected)
+}
+
+func (s *BenchmarkS) TestStreamTestTiming(c *C) {
+ helper := FixtureHelper{sleepOn: "SetUpSuite", sleep: 1000000 * time.Nanosecond}
+ output := String{}
+ runConf := RunConf{Output: &output, Stream: true}
+ Run(&helper, &runConf)
+
+ expected := "(?s).*\nPASS: check_test\\.go:[0-9]+: FixtureHelper\\.SetUpSuite\t *0\\.001s\n.*"
+ c.Assert(output.value, Matches, expected)
+}
+
+func (s *BenchmarkS) TestBenchmark(c *C) {
+ helper := FixtureHelper{sleep: 100000}
+ output := String{}
+ runConf := RunConf{
+ Output: &output,
+ Benchmark: true,
+ BenchmarkTime: 10000000,
+ Filter: "Benchmark1",
+ }
+ Run(&helper, &runConf)
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Benchmark1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "SetUpTest")
+ c.Check(helper.calls[5], Equals, "Benchmark1")
+ c.Check(helper.calls[6], Equals, "TearDownTest")
+ // ... and more.
+
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark1\t *100\t *[12][0-9]{5} ns/op\n"
+ c.Assert(output.value, Matches, expected)
+}
+
+func (s *BenchmarkS) TestBenchmarkBytes(c *C) {
+ helper := FixtureHelper{sleep: 100000}
+ output := String{}
+ runConf := RunConf{
+ Output: &output,
+ Benchmark: true,
+ BenchmarkTime: 10000000,
+ Filter: "Benchmark2",
+ }
+ Run(&helper, &runConf)
+
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark2\t *100\t *[12][0-9]{5} ns/op\t *[4-9]\\.[0-9]{2} MB/s\n"
+ c.Assert(output.value, Matches, expected)
+}
+
+func (s *BenchmarkS) TestBenchmarkMem(c *C) {
+ helper := FixtureHelper{sleep: 100000}
+ output := String{}
+ runConf := RunConf{
+ Output: &output,
+ Benchmark: true,
+ BenchmarkMem: true,
+ BenchmarkTime: 10000000,
+ Filter: "Benchmark3",
+ }
+ Run(&helper, &runConf)
+
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Benchmark3\t *100\t *[12][0-9]{5} ns/op\t *[0-9]+ B/op\t *[1-9] allocs/op\n"
+ c.Assert(output.value, Matches, expected)
+}
diff --git a/vendor/gopkg.in/check.v1/bootstrap_test.go b/vendor/gopkg.in/check.v1/bootstrap_test.go
new file mode 100644
index 00000000..e55f327c
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/bootstrap_test.go
@@ -0,0 +1,82 @@
+// These initial tests are for bootstrapping. They verify that we can
+// basically use the testing infrastructure itself to check if the test
+// system is working.
+//
+// These tests use will break down the test runner badly in case of
+// errors because if they simply fail, we can't be sure the developer
+// will ever see anything (because failing means the failing system
+// somehow isn't working! :-)
+//
+// Do not assume *any* internal functionality works as expected besides
+// what's actually tested here.
+
+package check_test
+
+import (
+ "fmt"
+ "gopkg.in/check.v1"
+ "strings"
+)
+
+type BootstrapS struct{}
+
+var boostrapS = check.Suite(&BootstrapS{})
+
+func (s *BootstrapS) TestCountSuite(c *check.C) {
+ suitesRun += 1
+}
+
+func (s *BootstrapS) TestFailedAndFail(c *check.C) {
+ if c.Failed() {
+ critical("c.Failed() must be false first!")
+ }
+ c.Fail()
+ if !c.Failed() {
+ critical("c.Fail() didn't put the test in a failed state!")
+ }
+ c.Succeed()
+}
+
+func (s *BootstrapS) TestFailedAndSucceed(c *check.C) {
+ c.Fail()
+ c.Succeed()
+ if c.Failed() {
+ critical("c.Succeed() didn't put the test back in a non-failed state")
+ }
+}
+
+func (s *BootstrapS) TestLogAndGetTestLog(c *check.C) {
+ c.Log("Hello there!")
+ log := c.GetTestLog()
+ if log != "Hello there!\n" {
+ critical(fmt.Sprintf("Log() or GetTestLog() is not working! Got: %#v", log))
+ }
+}
+
+func (s *BootstrapS) TestLogfAndGetTestLog(c *check.C) {
+ c.Logf("Hello %v", "there!")
+ log := c.GetTestLog()
+ if log != "Hello there!\n" {
+ critical(fmt.Sprintf("Logf() or GetTestLog() is not working! Got: %#v", log))
+ }
+}
+
+func (s *BootstrapS) TestRunShowsErrors(c *check.C) {
+ output := String{}
+ check.Run(&FailHelper{}, &check.RunConf{Output: &output})
+ if strings.Index(output.value, "Expected failure!") == -1 {
+ critical(fmt.Sprintf("RunWithWriter() output did not contain the "+
+ "expected failure! Got: %#v",
+ output.value))
+ }
+}
+
+func (s *BootstrapS) TestRunDoesntShowSuccesses(c *check.C) {
+ output := String{}
+ check.Run(&SuccessHelper{}, &check.RunConf{Output: &output})
+ if strings.Index(output.value, "Expected success!") != -1 {
+ critical(fmt.Sprintf("RunWithWriter() output contained a successful "+
+ "test! Got: %#v",
+ output.value))
+ }
+}
diff --git a/internal/gopkg.in/check.v1/check.go b/vendor/gopkg.in/check.v1/check.go
similarity index 100%
rename from internal/gopkg.in/check.v1/check.go
rename to vendor/gopkg.in/check.v1/check.go
diff --git a/vendor/gopkg.in/check.v1/check_test.go b/vendor/gopkg.in/check.v1/check_test.go
new file mode 100644
index 00000000..871b3252
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/check_test.go
@@ -0,0 +1,207 @@
+// This file contains just a few generic helpers which are used by the
+// other test files.
+
+package check_test
+
+import (
+ "flag"
+ "fmt"
+ "os"
+ "regexp"
+ "runtime"
+ "testing"
+ "time"
+
+ "gopkg.in/check.v1"
+)
+
+// We count the number of suites run at least to get a vague hint that the
+// test suite is behaving as it should. Otherwise a bug introduced at the
+// very core of the system could go unperceived.
+const suitesRunExpected = 8
+
+var suitesRun int = 0
+
+func Test(t *testing.T) {
+ check.TestingT(t)
+ if suitesRun != suitesRunExpected && flag.Lookup("check.f").Value.String() == "" {
+ critical(fmt.Sprintf("Expected %d suites to run rather than %d",
+ suitesRunExpected, suitesRun))
+ }
+}
+
+// -----------------------------------------------------------------------
+// Helper functions.
+
+// Break down badly. This is used in test cases which can't yet assume
+// that the fundamental bits are working.
+func critical(error string) {
+ fmt.Fprintln(os.Stderr, "CRITICAL: "+error)
+ os.Exit(1)
+}
+
+// Return the file line where it's called.
+func getMyLine() int {
+ if _, _, line, ok := runtime.Caller(1); ok {
+ return line
+ }
+ return -1
+}
+
+// -----------------------------------------------------------------------
+// Helper type implementing a basic io.Writer for testing output.
+
+// Type implementing the io.Writer interface for analyzing output.
+type String struct {
+ value string
+}
+
+// The only function required by the io.Writer interface. Will append
+// written data to the String.value string.
+func (s *String) Write(p []byte) (n int, err error) {
+ s.value += string(p)
+ return len(p), nil
+}
+
+// Trivial wrapper to test errors happening on a different file
+// than the test itself.
+func checkEqualWrapper(c *check.C, obtained, expected interface{}) (result bool, line int) {
+ return c.Check(obtained, check.Equals, expected), getMyLine()
+}
+
+// -----------------------------------------------------------------------
+// Helper suite for testing basic fail behavior.
+
+type FailHelper struct {
+ testLine int
+}
+
+func (s *FailHelper) TestLogAndFail(c *check.C) {
+ s.testLine = getMyLine() - 1
+ c.Log("Expected failure!")
+ c.Fail()
+}
+
+// -----------------------------------------------------------------------
+// Helper suite for testing basic success behavior.
+
+type SuccessHelper struct{}
+
+func (s *SuccessHelper) TestLogAndSucceed(c *check.C) {
+ c.Log("Expected success!")
+}
+
+// -----------------------------------------------------------------------
+// Helper suite for testing ordering and behavior of fixture.
+
+type FixtureHelper struct {
+ calls []string
+ panicOn string
+ skip bool
+ skipOnN int
+ sleepOn string
+ sleep time.Duration
+ bytes int64
+}
+
+func (s *FixtureHelper) trace(name string, c *check.C) {
+ s.calls = append(s.calls, name)
+ if name == s.panicOn {
+ panic(name)
+ }
+ if s.sleep > 0 && s.sleepOn == name {
+ time.Sleep(s.sleep)
+ }
+ if s.skip && s.skipOnN == len(s.calls)-1 {
+ c.Skip("skipOnN == n")
+ }
+}
+
+func (s *FixtureHelper) SetUpSuite(c *check.C) {
+ s.trace("SetUpSuite", c)
+}
+
+func (s *FixtureHelper) TearDownSuite(c *check.C) {
+ s.trace("TearDownSuite", c)
+}
+
+func (s *FixtureHelper) SetUpTest(c *check.C) {
+ s.trace("SetUpTest", c)
+}
+
+func (s *FixtureHelper) TearDownTest(c *check.C) {
+ s.trace("TearDownTest", c)
+}
+
+func (s *FixtureHelper) Test1(c *check.C) {
+ s.trace("Test1", c)
+}
+
+func (s *FixtureHelper) Test2(c *check.C) {
+ s.trace("Test2", c)
+}
+
+func (s *FixtureHelper) Benchmark1(c *check.C) {
+ s.trace("Benchmark1", c)
+ for i := 0; i < c.N; i++ {
+ time.Sleep(s.sleep)
+ }
+}
+
+func (s *FixtureHelper) Benchmark2(c *check.C) {
+ s.trace("Benchmark2", c)
+ c.SetBytes(1024)
+ for i := 0; i < c.N; i++ {
+ time.Sleep(s.sleep)
+ }
+}
+
+func (s *FixtureHelper) Benchmark3(c *check.C) {
+ var x []int64
+ s.trace("Benchmark3", c)
+ for i := 0; i < c.N; i++ {
+ time.Sleep(s.sleep)
+ x = make([]int64, 5)
+ _ = x
+ }
+}
+
+// -----------------------------------------------------------------------
+// Helper which checks the state of the test and ensures that it matches
+// the given expectations. Depends on c.Errorf() working, so shouldn't
+// be used to test this one function.
+
+type expectedState struct {
+ name string
+ result interface{}
+ failed bool
+ log string
+}
+
+// Verify the state of the test. Note that since this also verifies if
+// the test is supposed to be in a failed state, no other checks should
+// be done in addition to what is being tested.
+func checkState(c *check.C, result interface{}, expected *expectedState) {
+ failed := c.Failed()
+ c.Succeed()
+ log := c.GetTestLog()
+ matched, matchError := regexp.MatchString("^"+expected.log+"$", log)
+ if matchError != nil {
+ c.Errorf("Error in matching expression used in testing %s",
+ expected.name)
+ } else if !matched {
+ c.Errorf("%s logged:\n----------\n%s----------\n\nExpected:\n----------\n%s\n----------",
+ expected.name, log, expected.log)
+ }
+ if result != expected.result {
+ c.Errorf("%s returned %#v rather than %#v",
+ expected.name, result, expected.result)
+ }
+ if failed != expected.failed {
+ if failed {
+ c.Errorf("%s has failed when it shouldn't", expected.name)
+ } else {
+ c.Errorf("%s has not failed when it should", expected.name)
+ }
+ }
+}
diff --git a/internal/gopkg.in/check.v1/checkers.go b/vendor/gopkg.in/check.v1/checkers.go
similarity index 100%
rename from internal/gopkg.in/check.v1/checkers.go
rename to vendor/gopkg.in/check.v1/checkers.go
diff --git a/vendor/gopkg.in/check.v1/checkers_test.go b/vendor/gopkg.in/check.v1/checkers_test.go
new file mode 100644
index 00000000..5c697474
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/checkers_test.go
@@ -0,0 +1,272 @@
+package check_test
+
+import (
+ "errors"
+ "gopkg.in/check.v1"
+ "reflect"
+ "runtime"
+)
+
+type CheckersS struct{}
+
+var _ = check.Suite(&CheckersS{})
+
+func testInfo(c *check.C, checker check.Checker, name string, paramNames []string) {
+ info := checker.Info()
+ if info.Name != name {
+ c.Fatalf("Got name %s, expected %s", info.Name, name)
+ }
+ if !reflect.DeepEqual(info.Params, paramNames) {
+ c.Fatalf("Got param names %#v, expected %#v", info.Params, paramNames)
+ }
+}
+
+func testCheck(c *check.C, checker check.Checker, result bool, error string, params ...interface{}) ([]interface{}, []string) {
+ info := checker.Info()
+ if len(params) != len(info.Params) {
+ c.Fatalf("unexpected param count in test; expected %d got %d", len(info.Params), len(params))
+ }
+ names := append([]string{}, info.Params...)
+ result_, error_ := checker.Check(params, names)
+ if result_ != result || error_ != error {
+ c.Fatalf("%s.Check(%#v) returned (%#v, %#v) rather than (%#v, %#v)",
+ info.Name, params, result_, error_, result, error)
+ }
+ return params, names
+}
+
+func (s *CheckersS) TestComment(c *check.C) {
+ bug := check.Commentf("a %d bc", 42)
+ comment := bug.CheckCommentString()
+ if comment != "a 42 bc" {
+ c.Fatalf("Commentf returned %#v", comment)
+ }
+}
+
+func (s *CheckersS) TestIsNil(c *check.C) {
+ testInfo(c, check.IsNil, "IsNil", []string{"value"})
+
+ testCheck(c, check.IsNil, true, "", nil)
+ testCheck(c, check.IsNil, false, "", "a")
+
+ testCheck(c, check.IsNil, true, "", (chan int)(nil))
+ testCheck(c, check.IsNil, false, "", make(chan int))
+ testCheck(c, check.IsNil, true, "", (error)(nil))
+ testCheck(c, check.IsNil, false, "", errors.New(""))
+ testCheck(c, check.IsNil, true, "", ([]int)(nil))
+ testCheck(c, check.IsNil, false, "", make([]int, 1))
+ testCheck(c, check.IsNil, false, "", int(0))
+}
+
+func (s *CheckersS) TestNotNil(c *check.C) {
+ testInfo(c, check.NotNil, "NotNil", []string{"value"})
+
+ testCheck(c, check.NotNil, false, "", nil)
+ testCheck(c, check.NotNil, true, "", "a")
+
+ testCheck(c, check.NotNil, false, "", (chan int)(nil))
+ testCheck(c, check.NotNil, true, "", make(chan int))
+ testCheck(c, check.NotNil, false, "", (error)(nil))
+ testCheck(c, check.NotNil, true, "", errors.New(""))
+ testCheck(c, check.NotNil, false, "", ([]int)(nil))
+ testCheck(c, check.NotNil, true, "", make([]int, 1))
+}
+
+func (s *CheckersS) TestNot(c *check.C) {
+ testInfo(c, check.Not(check.IsNil), "Not(IsNil)", []string{"value"})
+
+ testCheck(c, check.Not(check.IsNil), false, "", nil)
+ testCheck(c, check.Not(check.IsNil), true, "", "a")
+}
+
+type simpleStruct struct {
+ i int
+}
+
+func (s *CheckersS) TestEquals(c *check.C) {
+ testInfo(c, check.Equals, "Equals", []string{"obtained", "expected"})
+
+ // The simplest.
+ testCheck(c, check.Equals, true, "", 42, 42)
+ testCheck(c, check.Equals, false, "", 42, 43)
+
+ // Different native types.
+ testCheck(c, check.Equals, false, "", int32(42), int64(42))
+
+ // With nil.
+ testCheck(c, check.Equals, false, "", 42, nil)
+
+ // Slices
+ testCheck(c, check.Equals, false, "runtime error: comparing uncomparable type []uint8", []byte{1, 2}, []byte{1, 2})
+
+ // Struct values
+ testCheck(c, check.Equals, true, "", simpleStruct{1}, simpleStruct{1})
+ testCheck(c, check.Equals, false, "", simpleStruct{1}, simpleStruct{2})
+
+ // Struct pointers
+ testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{1})
+ testCheck(c, check.Equals, false, "", &simpleStruct{1}, &simpleStruct{2})
+}
+
+func (s *CheckersS) TestDeepEquals(c *check.C) {
+ testInfo(c, check.DeepEquals, "DeepEquals", []string{"obtained", "expected"})
+
+ // The simplest.
+ testCheck(c, check.DeepEquals, true, "", 42, 42)
+ testCheck(c, check.DeepEquals, false, "", 42, 43)
+
+ // Different native types.
+ testCheck(c, check.DeepEquals, false, "", int32(42), int64(42))
+
+ // With nil.
+ testCheck(c, check.DeepEquals, false, "", 42, nil)
+
+ // Slices
+ testCheck(c, check.DeepEquals, true, "", []byte{1, 2}, []byte{1, 2})
+ testCheck(c, check.DeepEquals, false, "", []byte{1, 2}, []byte{1, 3})
+
+ // Struct values
+ testCheck(c, check.DeepEquals, true, "", simpleStruct{1}, simpleStruct{1})
+ testCheck(c, check.DeepEquals, false, "", simpleStruct{1}, simpleStruct{2})
+
+ // Struct pointers
+ testCheck(c, check.DeepEquals, true, "", &simpleStruct{1}, &simpleStruct{1})
+ testCheck(c, check.DeepEquals, false, "", &simpleStruct{1}, &simpleStruct{2})
+}
+
+func (s *CheckersS) TestHasLen(c *check.C) {
+ testInfo(c, check.HasLen, "HasLen", []string{"obtained", "n"})
+
+ testCheck(c, check.HasLen, true, "", "abcd", 4)
+ testCheck(c, check.HasLen, true, "", []int{1, 2}, 2)
+ testCheck(c, check.HasLen, false, "", []int{1, 2}, 3)
+
+ testCheck(c, check.HasLen, false, "n must be an int", []int{1, 2}, "2")
+ testCheck(c, check.HasLen, false, "obtained value type has no length", nil, 2)
+}
+
+func (s *CheckersS) TestErrorMatches(c *check.C) {
+ testInfo(c, check.ErrorMatches, "ErrorMatches", []string{"value", "regex"})
+
+ testCheck(c, check.ErrorMatches, false, "Error value is nil", nil, "some error")
+ testCheck(c, check.ErrorMatches, false, "Value is not an error", 1, "some error")
+ testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "some error")
+ testCheck(c, check.ErrorMatches, true, "", errors.New("some error"), "so.*or")
+
+ // Verify params mutation
+ params, names := testCheck(c, check.ErrorMatches, false, "", errors.New("some error"), "other error")
+ c.Assert(params[0], check.Equals, "some error")
+ c.Assert(names[0], check.Equals, "error")
+}
+
+func (s *CheckersS) TestMatches(c *check.C) {
+ testInfo(c, check.Matches, "Matches", []string{"value", "regex"})
+
+ // Simple matching
+ testCheck(c, check.Matches, true, "", "abc", "abc")
+ testCheck(c, check.Matches, true, "", "abc", "a.c")
+
+ // Must match fully
+ testCheck(c, check.Matches, false, "", "abc", "ab")
+ testCheck(c, check.Matches, false, "", "abc", "bc")
+
+ // String()-enabled values accepted
+ testCheck(c, check.Matches, true, "", reflect.ValueOf("abc"), "a.c")
+ testCheck(c, check.Matches, false, "", reflect.ValueOf("abc"), "a.d")
+
+ // Some error conditions.
+ testCheck(c, check.Matches, false, "Obtained value is not a string and has no .String()", 1, "a.c")
+ testCheck(c, check.Matches, false, "Can't compile regex: error parsing regexp: missing closing ]: `[c$`", "abc", "a[c")
+}
+
+func (s *CheckersS) TestPanics(c *check.C) {
+ testInfo(c, check.Panics, "Panics", []string{"function", "expected"})
+
+ // Some errors.
+ testCheck(c, check.Panics, false, "Function has not panicked", func() bool { return false }, "BOOM")
+ testCheck(c, check.Panics, false, "Function must take zero arguments", 1, "BOOM")
+
+ // Plain strings.
+ testCheck(c, check.Panics, true, "", func() { panic("BOOM") }, "BOOM")
+ testCheck(c, check.Panics, false, "", func() { panic("KABOOM") }, "BOOM")
+ testCheck(c, check.Panics, true, "", func() bool { panic("BOOM") }, "BOOM")
+
+ // Error values.
+ testCheck(c, check.Panics, true, "", func() { panic(errors.New("BOOM")) }, errors.New("BOOM"))
+ testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM"))
+
+ type deep struct{ i int }
+ // Deep value
+ testCheck(c, check.Panics, true, "", func() { panic(&deep{99}) }, &deep{99})
+
+ // Verify params/names mutation
+ params, names := testCheck(c, check.Panics, false, "", func() { panic(errors.New("KABOOM")) }, errors.New("BOOM"))
+ c.Assert(params[0], check.ErrorMatches, "KABOOM")
+ c.Assert(names[0], check.Equals, "panic")
+
+ // Verify a nil panic
+ testCheck(c, check.Panics, true, "", func() { panic(nil) }, nil)
+ testCheck(c, check.Panics, false, "", func() { panic(nil) }, "NOPE")
+}
+
+func (s *CheckersS) TestPanicMatches(c *check.C) {
+ testInfo(c, check.PanicMatches, "PanicMatches", []string{"function", "expected"})
+
+ // Error matching.
+ testCheck(c, check.PanicMatches, true, "", func() { panic(errors.New("BOOM")) }, "BO.M")
+ testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BO.M")
+
+ // Some errors.
+ testCheck(c, check.PanicMatches, false, "Function has not panicked", func() bool { return false }, "BOOM")
+ testCheck(c, check.PanicMatches, false, "Function must take zero arguments", 1, "BOOM")
+
+ // Plain strings.
+ testCheck(c, check.PanicMatches, true, "", func() { panic("BOOM") }, "BO.M")
+ testCheck(c, check.PanicMatches, false, "", func() { panic("KABOOM") }, "BOOM")
+ testCheck(c, check.PanicMatches, true, "", func() bool { panic("BOOM") }, "BO.M")
+
+ // Verify params/names mutation
+ params, names := testCheck(c, check.PanicMatches, false, "", func() { panic(errors.New("KABOOM")) }, "BOOM")
+ c.Assert(params[0], check.Equals, "KABOOM")
+ c.Assert(names[0], check.Equals, "panic")
+
+ // Verify a nil panic
+ testCheck(c, check.PanicMatches, false, "Panic value is not a string or an error", func() { panic(nil) }, "")
+}
+
+func (s *CheckersS) TestFitsTypeOf(c *check.C) {
+ testInfo(c, check.FitsTypeOf, "FitsTypeOf", []string{"obtained", "sample"})
+
+ // Basic types
+ testCheck(c, check.FitsTypeOf, true, "", 1, 0)
+ testCheck(c, check.FitsTypeOf, false, "", 1, int64(0))
+
+ // Aliases
+ testCheck(c, check.FitsTypeOf, false, "", 1, errors.New(""))
+ testCheck(c, check.FitsTypeOf, false, "", "error", errors.New(""))
+ testCheck(c, check.FitsTypeOf, true, "", errors.New("error"), errors.New(""))
+
+ // Structures
+ testCheck(c, check.FitsTypeOf, false, "", 1, simpleStruct{})
+ testCheck(c, check.FitsTypeOf, false, "", simpleStruct{42}, &simpleStruct{})
+ testCheck(c, check.FitsTypeOf, true, "", simpleStruct{42}, simpleStruct{})
+ testCheck(c, check.FitsTypeOf, true, "", &simpleStruct{42}, &simpleStruct{})
+
+ // Some bad values
+ testCheck(c, check.FitsTypeOf, false, "Invalid sample value", 1, interface{}(nil))
+ testCheck(c, check.FitsTypeOf, false, "", interface{}(nil), 0)
+}
+
+func (s *CheckersS) TestImplements(c *check.C) {
+ testInfo(c, check.Implements, "Implements", []string{"obtained", "ifaceptr"})
+
+ var e error
+ var re runtime.Error
+ testCheck(c, check.Implements, true, "", errors.New(""), &e)
+ testCheck(c, check.Implements, false, "", errors.New(""), &re)
+
+ // Some bad values
+ testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, errors.New(""))
+ testCheck(c, check.Implements, false, "ifaceptr should be a pointer to an interface variable", 0, interface{}(nil))
+ testCheck(c, check.Implements, false, "", interface{}(nil), &e)
+}
diff --git a/vendor/gopkg.in/check.v1/export_test.go b/vendor/gopkg.in/check.v1/export_test.go
new file mode 100644
index 00000000..0e6cfe0f
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/export_test.go
@@ -0,0 +1,9 @@
+package check
+
+func PrintLine(filename string, line int) (string, error) {
+ return printLine(filename, line)
+}
+
+func Indent(s, with string) string {
+ return indent(s, with)
+}
diff --git a/vendor/gopkg.in/check.v1/fixture_test.go b/vendor/gopkg.in/check.v1/fixture_test.go
new file mode 100644
index 00000000..2bff9e16
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/fixture_test.go
@@ -0,0 +1,484 @@
+// Tests for the behavior of the test fixture system.
+
+package check_test
+
+import (
+ . "gopkg.in/check.v1"
+)
+
+// -----------------------------------------------------------------------
+// Fixture test suite.
+
+type FixtureS struct{}
+
+var fixtureS = Suite(&FixtureS{})
+
+func (s *FixtureS) TestCountSuite(c *C) {
+ suitesRun += 1
+}
+
+// -----------------------------------------------------------------------
+// Basic fixture ordering verification.
+
+func (s *FixtureS) TestOrder(c *C) {
+ helper := FixtureHelper{}
+ Run(&helper, nil)
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "SetUpTest")
+ c.Check(helper.calls[5], Equals, "Test2")
+ c.Check(helper.calls[6], Equals, "TearDownTest")
+ c.Check(helper.calls[7], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 8)
+}
+
+// -----------------------------------------------------------------------
+// Check the behavior when panics occur within tests and fixtures.
+
+func (s *FixtureS) TestPanicOnTest(c *C) {
+ helper := FixtureHelper{panicOn: "Test1"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "SetUpTest")
+ c.Check(helper.calls[5], Equals, "Test2")
+ c.Check(helper.calls[6], Equals, "TearDownTest")
+ c.Check(helper.calls[7], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 8)
+
+ expected := "^\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: FixtureHelper.Test1\n\n" +
+ "\\.\\.\\. Panic: Test1 \\(PC=[xA-F0-9]+\\)\n\n" +
+ ".+:[0-9]+\n" +
+ " in (go)?panic\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.trace\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.Test1\n" +
+ "(.|\n)*$"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnSetUpTest(c *C) {
+ helper := FixtureHelper{panicOn: "SetUpTest"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "TearDownTest")
+ c.Check(helper.calls[3], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 4)
+
+ expected := "^\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: " +
+ "FixtureHelper\\.SetUpTest\n\n" +
+ "\\.\\.\\. Panic: SetUpTest \\(PC=[xA-F0-9]+\\)\n\n" +
+ ".+:[0-9]+\n" +
+ " in (go)?panic\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.trace\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.SetUpTest\n" +
+ "(.|\n)*" +
+ "\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: " +
+ "FixtureHelper\\.Test1\n\n" +
+ "\\.\\.\\. Panic: Fixture has panicked " +
+ "\\(see related PANIC\\)\n$"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnTearDownTest(c *C) {
+ helper := FixtureHelper{panicOn: "TearDownTest"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 5)
+
+ expected := "^\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: " +
+ "FixtureHelper.TearDownTest\n\n" +
+ "\\.\\.\\. Panic: TearDownTest \\(PC=[xA-F0-9]+\\)\n\n" +
+ ".+:[0-9]+\n" +
+ " in (go)?panic\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.trace\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.TearDownTest\n" +
+ "(.|\n)*" +
+ "\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: " +
+ "FixtureHelper\\.Test1\n\n" +
+ "\\.\\.\\. Panic: Fixture has panicked " +
+ "\\(see related PANIC\\)\n$"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnSetUpSuite(c *C) {
+ helper := FixtureHelper{panicOn: "SetUpSuite"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 2)
+
+ expected := "^\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: " +
+ "FixtureHelper.SetUpSuite\n\n" +
+ "\\.\\.\\. Panic: SetUpSuite \\(PC=[xA-F0-9]+\\)\n\n" +
+ ".+:[0-9]+\n" +
+ " in (go)?panic\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.trace\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.SetUpSuite\n" +
+ "(.|\n)*$"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnTearDownSuite(c *C) {
+ helper := FixtureHelper{panicOn: "TearDownSuite"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "SetUpTest")
+ c.Check(helper.calls[5], Equals, "Test2")
+ c.Check(helper.calls[6], Equals, "TearDownTest")
+ c.Check(helper.calls[7], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 8)
+
+ expected := "^\n-+\n" +
+ "PANIC: check_test\\.go:[0-9]+: " +
+ "FixtureHelper.TearDownSuite\n\n" +
+ "\\.\\.\\. Panic: TearDownSuite \\(PC=[xA-F0-9]+\\)\n\n" +
+ ".+:[0-9]+\n" +
+ " in (go)?panic\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.trace\n" +
+ ".*check_test.go:[0-9]+\n" +
+ " in FixtureHelper.TearDownSuite\n" +
+ "(.|\n)*$"
+
+ c.Check(output.value, Matches, expected)
+}
+
+// -----------------------------------------------------------------------
+// A wrong argument on a test or fixture will produce a nice error.
+
+func (s *FixtureS) TestPanicOnWrongTestArg(c *C) {
+ helper := WrongTestArgHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "TearDownTest")
+ c.Check(helper.calls[3], Equals, "SetUpTest")
+ c.Check(helper.calls[4], Equals, "Test2")
+ c.Check(helper.calls[5], Equals, "TearDownTest")
+ c.Check(helper.calls[6], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 7)
+
+ expected := "^\n-+\n" +
+ "PANIC: fixture_test\\.go:[0-9]+: " +
+ "WrongTestArgHelper\\.Test1\n\n" +
+ "\\.\\.\\. Panic: WrongTestArgHelper\\.Test1 argument " +
+ "should be \\*check\\.C\n"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnWrongSetUpTestArg(c *C) {
+ helper := WrongSetUpTestArgHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(len(helper.calls), Equals, 0)
+
+ expected :=
+ "^\n-+\n" +
+ "PANIC: fixture_test\\.go:[0-9]+: " +
+ "WrongSetUpTestArgHelper\\.SetUpTest\n\n" +
+ "\\.\\.\\. Panic: WrongSetUpTestArgHelper\\.SetUpTest argument " +
+ "should be \\*check\\.C\n"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnWrongSetUpSuiteArg(c *C) {
+ helper := WrongSetUpSuiteArgHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(len(helper.calls), Equals, 0)
+
+ expected :=
+ "^\n-+\n" +
+ "PANIC: fixture_test\\.go:[0-9]+: " +
+ "WrongSetUpSuiteArgHelper\\.SetUpSuite\n\n" +
+ "\\.\\.\\. Panic: WrongSetUpSuiteArgHelper\\.SetUpSuite argument " +
+ "should be \\*check\\.C\n"
+
+ c.Check(output.value, Matches, expected)
+}
+
+// -----------------------------------------------------------------------
+// Nice errors also when tests or fixture have wrong arg count.
+
+func (s *FixtureS) TestPanicOnWrongTestArgCount(c *C) {
+ helper := WrongTestArgCountHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "TearDownTest")
+ c.Check(helper.calls[3], Equals, "SetUpTest")
+ c.Check(helper.calls[4], Equals, "Test2")
+ c.Check(helper.calls[5], Equals, "TearDownTest")
+ c.Check(helper.calls[6], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 7)
+
+ expected := "^\n-+\n" +
+ "PANIC: fixture_test\\.go:[0-9]+: " +
+ "WrongTestArgCountHelper\\.Test1\n\n" +
+ "\\.\\.\\. Panic: WrongTestArgCountHelper\\.Test1 argument " +
+ "should be \\*check\\.C\n"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnWrongSetUpTestArgCount(c *C) {
+ helper := WrongSetUpTestArgCountHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(len(helper.calls), Equals, 0)
+
+ expected :=
+ "^\n-+\n" +
+ "PANIC: fixture_test\\.go:[0-9]+: " +
+ "WrongSetUpTestArgCountHelper\\.SetUpTest\n\n" +
+ "\\.\\.\\. Panic: WrongSetUpTestArgCountHelper\\.SetUpTest argument " +
+ "should be \\*check\\.C\n"
+
+ c.Check(output.value, Matches, expected)
+}
+
+func (s *FixtureS) TestPanicOnWrongSetUpSuiteArgCount(c *C) {
+ helper := WrongSetUpSuiteArgCountHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(len(helper.calls), Equals, 0)
+
+ expected :=
+ "^\n-+\n" +
+ "PANIC: fixture_test\\.go:[0-9]+: " +
+ "WrongSetUpSuiteArgCountHelper\\.SetUpSuite\n\n" +
+ "\\.\\.\\. Panic: WrongSetUpSuiteArgCountHelper" +
+ "\\.SetUpSuite argument should be \\*check\\.C\n"
+
+ c.Check(output.value, Matches, expected)
+}
+
+// -----------------------------------------------------------------------
+// Helper test suites with wrong function arguments.
+
+type WrongTestArgHelper struct {
+ FixtureHelper
+}
+
+func (s *WrongTestArgHelper) Test1(t int) {
+}
+
+type WrongSetUpTestArgHelper struct {
+ FixtureHelper
+}
+
+func (s *WrongSetUpTestArgHelper) SetUpTest(t int) {
+}
+
+type WrongSetUpSuiteArgHelper struct {
+ FixtureHelper
+}
+
+func (s *WrongSetUpSuiteArgHelper) SetUpSuite(t int) {
+}
+
+type WrongTestArgCountHelper struct {
+ FixtureHelper
+}
+
+func (s *WrongTestArgCountHelper) Test1(c *C, i int) {
+}
+
+type WrongSetUpTestArgCountHelper struct {
+ FixtureHelper
+}
+
+func (s *WrongSetUpTestArgCountHelper) SetUpTest(c *C, i int) {
+}
+
+type WrongSetUpSuiteArgCountHelper struct {
+ FixtureHelper
+}
+
+func (s *WrongSetUpSuiteArgCountHelper) SetUpSuite(c *C, i int) {
+}
+
+// -----------------------------------------------------------------------
+// Ensure fixture doesn't run without tests.
+
+type NoTestsHelper struct {
+ hasRun bool
+}
+
+func (s *NoTestsHelper) SetUpSuite(c *C) {
+ s.hasRun = true
+}
+
+func (s *NoTestsHelper) TearDownSuite(c *C) {
+ s.hasRun = true
+}
+
+func (s *FixtureS) TestFixtureDoesntRunWithoutTests(c *C) {
+ helper := NoTestsHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Check(helper.hasRun, Equals, false)
+}
+
+// -----------------------------------------------------------------------
+// Verify that checks and assertions work correctly inside the fixture.
+
+type FixtureCheckHelper struct {
+ fail string
+ completed bool
+}
+
+func (s *FixtureCheckHelper) SetUpSuite(c *C) {
+ switch s.fail {
+ case "SetUpSuiteAssert":
+ c.Assert(false, Equals, true)
+ case "SetUpSuiteCheck":
+ c.Check(false, Equals, true)
+ }
+ s.completed = true
+}
+
+func (s *FixtureCheckHelper) SetUpTest(c *C) {
+ switch s.fail {
+ case "SetUpTestAssert":
+ c.Assert(false, Equals, true)
+ case "SetUpTestCheck":
+ c.Check(false, Equals, true)
+ }
+ s.completed = true
+}
+
+func (s *FixtureCheckHelper) Test(c *C) {
+ // Do nothing.
+}
+
+func (s *FixtureS) TestSetUpSuiteCheck(c *C) {
+ helper := FixtureCheckHelper{fail: "SetUpSuiteCheck"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Assert(output.value, Matches,
+ "\n---+\n"+
+ "FAIL: fixture_test\\.go:[0-9]+: "+
+ "FixtureCheckHelper\\.SetUpSuite\n\n"+
+ "fixture_test\\.go:[0-9]+:\n"+
+ " c\\.Check\\(false, Equals, true\\)\n"+
+ "\\.+ obtained bool = false\n"+
+ "\\.+ expected bool = true\n\n")
+ c.Assert(helper.completed, Equals, true)
+}
+
+func (s *FixtureS) TestSetUpSuiteAssert(c *C) {
+ helper := FixtureCheckHelper{fail: "SetUpSuiteAssert"}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Assert(output.value, Matches,
+ "\n---+\n"+
+ "FAIL: fixture_test\\.go:[0-9]+: "+
+ "FixtureCheckHelper\\.SetUpSuite\n\n"+
+ "fixture_test\\.go:[0-9]+:\n"+
+ " c\\.Assert\\(false, Equals, true\\)\n"+
+ "\\.+ obtained bool = false\n"+
+ "\\.+ expected bool = true\n\n")
+ c.Assert(helper.completed, Equals, false)
+}
+
+// -----------------------------------------------------------------------
+// Verify that logging within SetUpTest() persists within the test log itself.
+
+type FixtureLogHelper struct {
+ c *C
+}
+
+func (s *FixtureLogHelper) SetUpTest(c *C) {
+ s.c = c
+ c.Log("1")
+}
+
+func (s *FixtureLogHelper) Test(c *C) {
+ c.Log("2")
+ s.c.Log("3")
+ c.Log("4")
+ c.Fail()
+}
+
+func (s *FixtureLogHelper) TearDownTest(c *C) {
+ s.c.Log("5")
+}
+
+func (s *FixtureS) TestFixtureLogging(c *C) {
+ helper := FixtureLogHelper{}
+ output := String{}
+ Run(&helper, &RunConf{Output: &output})
+ c.Assert(output.value, Matches,
+ "\n---+\n"+
+ "FAIL: fixture_test\\.go:[0-9]+: "+
+ "FixtureLogHelper\\.Test\n\n"+
+ "1\n2\n3\n4\n5\n")
+}
+
+// -----------------------------------------------------------------------
+// Skip() within fixture methods.
+
+func (s *FixtureS) TestSkipSuite(c *C) {
+ helper := FixtureHelper{skip: true, skipOnN: 0}
+ output := String{}
+ result := Run(&helper, &RunConf{Output: &output})
+ c.Assert(output.value, Equals, "")
+ c.Assert(helper.calls[0], Equals, "SetUpSuite")
+ c.Assert(helper.calls[1], Equals, "TearDownSuite")
+ c.Assert(len(helper.calls), Equals, 2)
+ c.Assert(result.Skipped, Equals, 2)
+}
+
+func (s *FixtureS) TestSkipTest(c *C) {
+ helper := FixtureHelper{skip: true, skipOnN: 1}
+ output := String{}
+ result := Run(&helper, &RunConf{Output: &output})
+ c.Assert(helper.calls[0], Equals, "SetUpSuite")
+ c.Assert(helper.calls[1], Equals, "SetUpTest")
+ c.Assert(helper.calls[2], Equals, "SetUpTest")
+ c.Assert(helper.calls[3], Equals, "Test2")
+ c.Assert(helper.calls[4], Equals, "TearDownTest")
+ c.Assert(helper.calls[5], Equals, "TearDownSuite")
+ c.Assert(len(helper.calls), Equals, 6)
+ c.Assert(result.Skipped, Equals, 1)
+}
diff --git a/vendor/gopkg.in/check.v1/foundation_test.go b/vendor/gopkg.in/check.v1/foundation_test.go
new file mode 100644
index 00000000..8ecf7915
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/foundation_test.go
@@ -0,0 +1,335 @@
+// These tests check that the foundations of gocheck are working properly.
+// They already assume that fundamental failing is working already, though,
+// since this was tested in bootstrap_test.go. Even then, some care may
+// still have to be taken when using external functions, since they should
+// of course not rely on functionality tested here.
+
+package check_test
+
+import (
+ "fmt"
+ "gopkg.in/check.v1"
+ "log"
+ "os"
+ "regexp"
+ "strings"
+)
+
+// -----------------------------------------------------------------------
+// Foundation test suite.
+
+type FoundationS struct{}
+
+var foundationS = check.Suite(&FoundationS{})
+
+func (s *FoundationS) TestCountSuite(c *check.C) {
+ suitesRun += 1
+}
+
+func (s *FoundationS) TestErrorf(c *check.C) {
+ // Do not use checkState() here. It depends on Errorf() working.
+ expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
+ " c.Errorf(\"Error %%v!\", \"message\")\n"+
+ "... Error: Error message!\n\n",
+ getMyLine()+1)
+ c.Errorf("Error %v!", "message")
+ failed := c.Failed()
+ c.Succeed()
+ if log := c.GetTestLog(); log != expectedLog {
+ c.Logf("Errorf() logged %#v rather than %#v", log, expectedLog)
+ c.Fail()
+ }
+ if !failed {
+ c.Logf("Errorf() didn't put the test in a failed state")
+ c.Fail()
+ }
+}
+
+func (s *FoundationS) TestError(c *check.C) {
+ expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
+ " c\\.Error\\(\"Error \", \"message!\"\\)\n"+
+ "\\.\\.\\. Error: Error message!\n\n",
+ getMyLine()+1)
+ c.Error("Error ", "message!")
+ checkState(c, nil,
+ &expectedState{
+ name: "Error(`Error `, `message!`)",
+ failed: true,
+ log: expectedLog,
+ })
+}
+
+func (s *FoundationS) TestFailNow(c *check.C) {
+ defer (func() {
+ if !c.Failed() {
+ c.Error("FailNow() didn't fail the test")
+ } else {
+ c.Succeed()
+ if c.GetTestLog() != "" {
+ c.Error("Something got logged:\n" + c.GetTestLog())
+ }
+ }
+ })()
+
+ c.FailNow()
+ c.Log("FailNow() didn't stop the test")
+}
+
+func (s *FoundationS) TestSucceedNow(c *check.C) {
+ defer (func() {
+ if c.Failed() {
+ c.Error("SucceedNow() didn't succeed the test")
+ }
+ if c.GetTestLog() != "" {
+ c.Error("Something got logged:\n" + c.GetTestLog())
+ }
+ })()
+
+ c.Fail()
+ c.SucceedNow()
+ c.Log("SucceedNow() didn't stop the test")
+}
+
+func (s *FoundationS) TestFailureHeader(c *check.C) {
+ output := String{}
+ failHelper := FailHelper{}
+ check.Run(&failHelper, &check.RunConf{Output: &output})
+ header := fmt.Sprintf(""+
+ "\n-----------------------------------"+
+ "-----------------------------------\n"+
+ "FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n",
+ failHelper.testLine)
+ if strings.Index(output.value, header) == -1 {
+ c.Errorf(""+
+ "Failure didn't print a proper header.\n"+
+ "... Got:\n%s... Expected something with:\n%s",
+ output.value, header)
+ }
+}
+
+func (s *FoundationS) TestFatal(c *check.C) {
+ var line int
+ defer (func() {
+ if !c.Failed() {
+ c.Error("Fatal() didn't fail the test")
+ } else {
+ c.Succeed()
+ expected := fmt.Sprintf("foundation_test.go:%d:\n"+
+ " c.Fatal(\"Die \", \"now!\")\n"+
+ "... Error: Die now!\n\n",
+ line)
+ if c.GetTestLog() != expected {
+ c.Error("Incorrect log:", c.GetTestLog())
+ }
+ }
+ })()
+
+ line = getMyLine() + 1
+ c.Fatal("Die ", "now!")
+ c.Log("Fatal() didn't stop the test")
+}
+
+func (s *FoundationS) TestFatalf(c *check.C) {
+ var line int
+ defer (func() {
+ if !c.Failed() {
+ c.Error("Fatalf() didn't fail the test")
+ } else {
+ c.Succeed()
+ expected := fmt.Sprintf("foundation_test.go:%d:\n"+
+ " c.Fatalf(\"Die %%s!\", \"now\")\n"+
+ "... Error: Die now!\n\n",
+ line)
+ if c.GetTestLog() != expected {
+ c.Error("Incorrect log:", c.GetTestLog())
+ }
+ }
+ })()
+
+ line = getMyLine() + 1
+ c.Fatalf("Die %s!", "now")
+ c.Log("Fatalf() didn't stop the test")
+}
+
+func (s *FoundationS) TestCallerLoggingInsideTest(c *check.C) {
+ log := fmt.Sprintf(""+
+ "foundation_test.go:%d:\n"+
+ " result := c.Check\\(10, check.Equals, 20\\)\n"+
+ "\\.\\.\\. obtained int = 10\n"+
+ "\\.\\.\\. expected int = 20\n\n",
+ getMyLine()+1)
+ result := c.Check(10, check.Equals, 20)
+ checkState(c, result,
+ &expectedState{
+ name: "Check(10, Equals, 20)",
+ result: false,
+ failed: true,
+ log: log,
+ })
+}
+
+func (s *FoundationS) TestCallerLoggingInDifferentFile(c *check.C) {
+ result, line := checkEqualWrapper(c, 10, 20)
+ testLine := getMyLine() - 1
+ log := fmt.Sprintf(""+
+ "foundation_test.go:%d:\n"+
+ " result, line := checkEqualWrapper\\(c, 10, 20\\)\n"+
+ "check_test.go:%d:\n"+
+ " return c.Check\\(obtained, check.Equals, expected\\), getMyLine\\(\\)\n"+
+ "\\.\\.\\. obtained int = 10\n"+
+ "\\.\\.\\. expected int = 20\n\n",
+ testLine, line)
+ checkState(c, result,
+ &expectedState{
+ name: "Check(10, Equals, 20)",
+ result: false,
+ failed: true,
+ log: log,
+ })
+}
+
+// -----------------------------------------------------------------------
+// ExpectFailure() inverts the logic of failure.
+
+type ExpectFailureSucceedHelper struct{}
+
+func (s *ExpectFailureSucceedHelper) TestSucceed(c *check.C) {
+ c.ExpectFailure("It booms!")
+ c.Error("Boom!")
+}
+
+type ExpectFailureFailHelper struct{}
+
+func (s *ExpectFailureFailHelper) TestFail(c *check.C) {
+ c.ExpectFailure("Bug #XYZ")
+}
+
+func (s *FoundationS) TestExpectFailureFail(c *check.C) {
+ helper := ExpectFailureFailHelper{}
+ output := String{}
+ result := check.Run(&helper, &check.RunConf{Output: &output})
+
+ expected := "" +
+ "^\n-+\n" +
+ "FAIL: foundation_test\\.go:[0-9]+:" +
+ " ExpectFailureFailHelper\\.TestFail\n\n" +
+ "\\.\\.\\. Error: Test succeeded, but was expected to fail\n" +
+ "\\.\\.\\. Reason: Bug #XYZ\n$"
+
+ matched, err := regexp.MatchString(expected, output.value)
+ if err != nil {
+ c.Error("Bad expression: ", expected)
+ } else if !matched {
+ c.Error("ExpectFailure() didn't log properly:\n", output.value)
+ }
+
+ c.Assert(result.ExpectedFailures, check.Equals, 0)
+}
+
+func (s *FoundationS) TestExpectFailureSucceed(c *check.C) {
+ helper := ExpectFailureSucceedHelper{}
+ output := String{}
+ result := check.Run(&helper, &check.RunConf{Output: &output})
+
+ c.Assert(output.value, check.Equals, "")
+ c.Assert(result.ExpectedFailures, check.Equals, 1)
+}
+
+func (s *FoundationS) TestExpectFailureSucceedVerbose(c *check.C) {
+ helper := ExpectFailureSucceedHelper{}
+ output := String{}
+ result := check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})
+
+ expected := "" +
+ "FAIL EXPECTED: foundation_test\\.go:[0-9]+:" +
+ " ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n"
+
+ matched, err := regexp.MatchString(expected, output.value)
+ if err != nil {
+ c.Error("Bad expression: ", expected)
+ } else if !matched {
+ c.Error("ExpectFailure() didn't log properly:\n", output.value)
+ }
+
+ c.Assert(result.ExpectedFailures, check.Equals, 1)
+}
+
+// -----------------------------------------------------------------------
+// Skip() allows stopping a test without positive/negative results.
+
+type SkipTestHelper struct{}
+
+func (s *SkipTestHelper) TestFail(c *check.C) {
+ c.Skip("Wrong platform or whatever")
+ c.Error("Boom!")
+}
+
+func (s *FoundationS) TestSkip(c *check.C) {
+ helper := SkipTestHelper{}
+ output := String{}
+ check.Run(&helper, &check.RunConf{Output: &output})
+
+ if output.value != "" {
+ c.Error("Skip() logged something:\n", output.value)
+ }
+}
+
+func (s *FoundationS) TestSkipVerbose(c *check.C) {
+ helper := SkipTestHelper{}
+ output := String{}
+ check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})
+
+ expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" +
+ " \\(Wrong platform or whatever\\)"
+ matched, err := regexp.MatchString(expected, output.value)
+ if err != nil {
+ c.Error("Bad expression: ", expected)
+ } else if !matched {
+ c.Error("Skip() didn't log properly:\n", output.value)
+ }
+}
+
+// -----------------------------------------------------------------------
+// Check minimum *log.Logger interface provided by *check.C.
+
+type minLogger interface {
+ Output(calldepth int, s string) error
+}
+
+func (s *BootstrapS) TestMinLogger(c *check.C) {
+ var logger minLogger
+ logger = log.New(os.Stderr, "", 0)
+ logger = c
+ logger.Output(0, "Hello there")
+ expected := `\[LOG\] [0-9]+:[0-9][0-9]\.[0-9][0-9][0-9] +Hello there\n`
+ output := c.GetTestLog()
+ c.Assert(output, check.Matches, expected)
+}
+
+// -----------------------------------------------------------------------
+// Ensure that suites with embedded types are working fine, including the
+// the workaround for issue 906.
+
+type EmbeddedInternalS struct {
+ called bool
+}
+
+type EmbeddedS struct {
+ EmbeddedInternalS
+}
+
+var embeddedS = check.Suite(&EmbeddedS{})
+
+func (s *EmbeddedS) TestCountSuite(c *check.C) {
+ suitesRun += 1
+}
+
+func (s *EmbeddedInternalS) TestMethod(c *check.C) {
+ c.Error("TestMethod() of the embedded type was called!?")
+}
+
+func (s *EmbeddedS) TestMethod(c *check.C) {
+ // http://code.google.com/p/go/issues/detail?id=906
+ c.Check(s.called, check.Equals, false) // Go issue 906 is affecting the runner?
+ s.called = true
+}
diff --git a/internal/gopkg.in/check.v1/helpers.go b/vendor/gopkg.in/check.v1/helpers.go
similarity index 100%
rename from internal/gopkg.in/check.v1/helpers.go
rename to vendor/gopkg.in/check.v1/helpers.go
diff --git a/vendor/gopkg.in/check.v1/helpers_test.go b/vendor/gopkg.in/check.v1/helpers_test.go
new file mode 100644
index 00000000..4baa656b
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/helpers_test.go
@@ -0,0 +1,519 @@
+// These tests verify the inner workings of the helper methods associated
+// with check.T.
+
+package check_test
+
+import (
+ "gopkg.in/check.v1"
+ "os"
+ "reflect"
+ "runtime"
+ "sync"
+)
+
+var helpersS = check.Suite(&HelpersS{})
+
+type HelpersS struct{}
+
+func (s *HelpersS) TestCountSuite(c *check.C) {
+ suitesRun += 1
+}
+
+// -----------------------------------------------------------------------
+// Fake checker and bug info to verify the behavior of Assert() and Check().
+
+type MyChecker struct {
+ info *check.CheckerInfo
+ params []interface{}
+ names []string
+ result bool
+ error string
+}
+
+func (checker *MyChecker) Info() *check.CheckerInfo {
+ if checker.info == nil {
+ return &check.CheckerInfo{Name: "MyChecker", Params: []string{"myobtained", "myexpected"}}
+ }
+ return checker.info
+}
+
+func (checker *MyChecker) Check(params []interface{}, names []string) (bool, string) {
+ rparams := checker.params
+ rnames := checker.names
+ checker.params = append([]interface{}{}, params...)
+ checker.names = append([]string{}, names...)
+ if rparams != nil {
+ copy(params, rparams)
+ }
+ if rnames != nil {
+ copy(names, rnames)
+ }
+ return checker.result, checker.error
+}
+
+type myCommentType string
+
+func (c myCommentType) CheckCommentString() string {
+ return string(c)
+}
+
+func myComment(s string) myCommentType {
+ return myCommentType(s)
+}
+
+// -----------------------------------------------------------------------
+// Ensure a real checker actually works fine.
+
+func (s *HelpersS) TestCheckerInterface(c *check.C) {
+ testHelperSuccess(c, "Check(1, Equals, 1)", true, func() interface{} {
+ return c.Check(1, check.Equals, 1)
+ })
+}
+
+// -----------------------------------------------------------------------
+// Tests for Check(), mostly the same as for Assert() following these.
+
+func (s *HelpersS) TestCheckSucceedWithExpected(c *check.C) {
+ checker := &MyChecker{result: true}
+ testHelperSuccess(c, "Check(1, checker, 2)", true, func() interface{} {
+ return c.Check(1, checker, 2)
+ })
+ if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) {
+ c.Fatalf("Bad params for check: %#v", checker.params)
+ }
+}
+
+func (s *HelpersS) TestCheckSucceedWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
+ testHelperSuccess(c, "Check(1, checker)", true, func() interface{} {
+ return c.Check(1, checker)
+ })
+ if !reflect.DeepEqual(checker.params, []interface{}{1}) {
+ c.Fatalf("Bad params for check: %#v", checker.params)
+ }
+}
+
+func (s *HelpersS) TestCheckFailWithExpected(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker, 2\\)\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n\n"
+ testHelperFailure(c, "Check(1, checker, 2)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker, 2)
+ })
+}
+
+func (s *HelpersS) TestCheckFailWithExpectedAndComment(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n" +
+ "\\.+ Hello world!\n\n"
+ testHelperFailure(c, "Check(1, checker, 2, msg)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker, 2, myComment("Hello world!"))
+ })
+}
+
+func (s *HelpersS) TestCheckFailWithExpectedAndStaticComment(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " // Nice leading comment\\.\n" +
+ " return c\\.Check\\(1, checker, 2\\) // Hello there\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n\n"
+ testHelperFailure(c, "Check(1, checker, 2, msg)", false, false, log,
+ func() interface{} {
+ // Nice leading comment.
+ return c.Check(1, checker, 2) // Hello there
+ })
+}
+
+func (s *HelpersS) TestCheckFailWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker\\)\n" +
+ "\\.+ myvalue int = 1\n\n"
+ testHelperFailure(c, "Check(1, checker)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker)
+ })
+}
+
+func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" +
+ "\\.+ myvalue int = 1\n" +
+ "\\.+ Hello world!\n\n"
+ testHelperFailure(c, "Check(1, checker, msg)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker, myComment("Hello world!"))
+ })
+}
+
+func (s *HelpersS) TestCheckWithMissingExpected(c *check.C) {
+ checker := &MyChecker{result: true}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker\\)\n" +
+ "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" +
+ "\\.+ Wrong number of parameters for MyChecker: " +
+ "want 3, got 2\n\n"
+ testHelperFailure(c, "Check(1, checker, !?)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker)
+ })
+}
+
+func (s *HelpersS) TestCheckWithTooManyExpected(c *check.C) {
+ checker := &MyChecker{result: true}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker, 2, 3\\)\n" +
+ "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" +
+ "\\.+ Wrong number of parameters for MyChecker: " +
+ "want 3, got 4\n\n"
+ testHelperFailure(c, "Check(1, checker, 2, 3)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker, 2, 3)
+ })
+}
+
+func (s *HelpersS) TestCheckWithError(c *check.C) {
+ checker := &MyChecker{result: false, error: "Some not so cool data provided!"}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker, 2\\)\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n" +
+ "\\.+ Some not so cool data provided!\n\n"
+ testHelperFailure(c, "Check(1, checker, 2)", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker, 2)
+ })
+}
+
+func (s *HelpersS) TestCheckWithNilChecker(c *check.C) {
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, nil\\)\n" +
+ "\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
+ "\\.+ Oops\\.\\. you've provided a nil checker!\n\n"
+ testHelperFailure(c, "Check(obtained, nil)", false, false, log,
+ func() interface{} {
+ return c.Check(1, nil)
+ })
+}
+
+func (s *HelpersS) TestCheckWithParamsAndNamesMutation(c *check.C) {
+ checker := &MyChecker{result: false, params: []interface{}{3, 4}, names: []string{"newobtained", "newexpected"}}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " return c\\.Check\\(1, checker, 2\\)\n" +
+ "\\.+ newobtained int = 3\n" +
+ "\\.+ newexpected int = 4\n\n"
+ testHelperFailure(c, "Check(1, checker, 2) with mutation", false, false, log,
+ func() interface{} {
+ return c.Check(1, checker, 2)
+ })
+}
+
+// -----------------------------------------------------------------------
+// Tests for Assert(), mostly the same as for Check() above.
+
+func (s *HelpersS) TestAssertSucceedWithExpected(c *check.C) {
+ checker := &MyChecker{result: true}
+ testHelperSuccess(c, "Assert(1, checker, 2)", nil, func() interface{} {
+ c.Assert(1, checker, 2)
+ return nil
+ })
+ if !reflect.DeepEqual(checker.params, []interface{}{1, 2}) {
+ c.Fatalf("Bad params for check: %#v", checker.params)
+ }
+}
+
+func (s *HelpersS) TestAssertSucceedWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: true, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
+ testHelperSuccess(c, "Assert(1, checker)", nil, func() interface{} {
+ c.Assert(1, checker)
+ return nil
+ })
+ if !reflect.DeepEqual(checker.params, []interface{}{1}) {
+ c.Fatalf("Bad params for check: %#v", checker.params)
+ }
+}
+
+func (s *HelpersS) TestAssertFailWithExpected(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, checker, 2\\)\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n\n"
+ testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, checker, 2)
+ return nil
+ })
+}
+
+func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, checker, 2, myComment\\(\"Hello world!\"\\)\\)\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n" +
+ "\\.+ Hello world!\n\n"
+ testHelperFailure(c, "Assert(1, checker, 2, msg)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, checker, 2, myComment("Hello world!"))
+ return nil
+ })
+}
+
+func (s *HelpersS) TestAssertFailWithoutExpected(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, checker\\)\n" +
+ "\\.+ myvalue int = 1\n\n"
+ testHelperFailure(c, "Assert(1, checker)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, checker)
+ return nil
+ })
+}
+
+func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *check.C) {
+ checker := &MyChecker{result: false, info: &check.CheckerInfo{Params: []string{"myvalue"}}}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, checker, myComment\\(\"Hello world!\"\\)\\)\n" +
+ "\\.+ myvalue int = 1\n" +
+ "\\.+ Hello world!\n\n"
+ testHelperFailure(c, "Assert(1, checker, msg)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, checker, myComment("Hello world!"))
+ return nil
+ })
+}
+
+func (s *HelpersS) TestAssertWithMissingExpected(c *check.C) {
+ checker := &MyChecker{result: true}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, checker\\)\n" +
+ "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" +
+ "\\.+ Wrong number of parameters for MyChecker: " +
+ "want 3, got 2\n\n"
+ testHelperFailure(c, "Assert(1, checker, !?)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, checker)
+ return nil
+ })
+}
+
+func (s *HelpersS) TestAssertWithError(c *check.C) {
+ checker := &MyChecker{result: false, error: "Some not so cool data provided!"}
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, checker, 2\\)\n" +
+ "\\.+ myobtained int = 1\n" +
+ "\\.+ myexpected int = 2\n" +
+ "\\.+ Some not so cool data provided!\n\n"
+ testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, checker, 2)
+ return nil
+ })
+}
+
+func (s *HelpersS) TestAssertWithNilChecker(c *check.C) {
+ log := "(?s)helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+ " c\\.Assert\\(1, nil\\)\n" +
+ "\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
+ "\\.+ Oops\\.\\. you've provided a nil checker!\n\n"
+ testHelperFailure(c, "Assert(obtained, nil)", nil, true, log,
+ func() interface{} {
+ c.Assert(1, nil)
+ return nil
+ })
+}
+
+// -----------------------------------------------------------------------
+// Ensure that values logged work properly in some interesting cases.
+
+func (s *HelpersS) TestValueLoggingWithArrays(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
+ " return c\\.Check\\(\\[\\]byte{1, 2}, checker, \\[\\]byte{1, 3}\\)\n" +
+ "\\.+ myobtained \\[\\]uint8 = \\[\\]byte{0x1, 0x2}\n" +
+ "\\.+ myexpected \\[\\]uint8 = \\[\\]byte{0x1, 0x3}\n\n"
+ testHelperFailure(c, "Check([]byte{1}, chk, []byte{3})", false, false, log,
+ func() interface{} {
+ return c.Check([]byte{1, 2}, checker, []byte{1, 3})
+ })
+}
+
+func (s *HelpersS) TestValueLoggingWithMultiLine(c *check.C) {
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
+ " return c\\.Check\\(\"a\\\\nb\\\\n\", checker, \"a\\\\nb\\\\nc\"\\)\n" +
+ "\\.+ myobtained string = \"\" \\+\n" +
+ "\\.+ \"a\\\\n\" \\+\n" +
+ "\\.+ \"b\\\\n\"\n" +
+ "\\.+ myexpected string = \"\" \\+\n" +
+ "\\.+ \"a\\\\n\" \\+\n" +
+ "\\.+ \"b\\\\n\" \\+\n" +
+ "\\.+ \"c\"\n\n"
+ testHelperFailure(c, `Check("a\nb\n", chk, "a\nb\nc")`, false, false, log,
+ func() interface{} {
+ return c.Check("a\nb\n", checker, "a\nb\nc")
+ })
+}
+
+func (s *HelpersS) TestValueLoggingWithMultiLineException(c *check.C) {
+ // If the newline is at the end of the string, don't log as multi-line.
+ checker := &MyChecker{result: false}
+ log := "(?s)helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
+ " return c\\.Check\\(\"a b\\\\n\", checker, \"a\\\\nb\"\\)\n" +
+ "\\.+ myobtained string = \"a b\\\\n\"\n" +
+ "\\.+ myexpected string = \"\" \\+\n" +
+ "\\.+ \"a\\\\n\" \\+\n" +
+ "\\.+ \"b\"\n\n"
+ testHelperFailure(c, `Check("a b\n", chk, "a\nb")`, false, false, log,
+ func() interface{} {
+ return c.Check("a b\n", checker, "a\nb")
+ })
+}
+
+// -----------------------------------------------------------------------
+// MakeDir() tests.
+
+type MkDirHelper struct {
+ path1 string
+ path2 string
+ isDir1 bool
+ isDir2 bool
+ isDir3 bool
+ isDir4 bool
+}
+
+func (s *MkDirHelper) SetUpSuite(c *check.C) {
+ s.path1 = c.MkDir()
+ s.isDir1 = isDir(s.path1)
+}
+
+func (s *MkDirHelper) Test(c *check.C) {
+ s.path2 = c.MkDir()
+ s.isDir2 = isDir(s.path2)
+}
+
+func (s *MkDirHelper) TearDownSuite(c *check.C) {
+ s.isDir3 = isDir(s.path1)
+ s.isDir4 = isDir(s.path2)
+}
+
+func (s *HelpersS) TestMkDir(c *check.C) {
+ helper := MkDirHelper{}
+ output := String{}
+ check.Run(&helper, &check.RunConf{Output: &output})
+ c.Assert(output.value, check.Equals, "")
+ c.Check(helper.isDir1, check.Equals, true)
+ c.Check(helper.isDir2, check.Equals, true)
+ c.Check(helper.isDir3, check.Equals, true)
+ c.Check(helper.isDir4, check.Equals, true)
+ c.Check(helper.path1, check.Not(check.Equals),
+ helper.path2)
+ c.Check(isDir(helper.path1), check.Equals, false)
+ c.Check(isDir(helper.path2), check.Equals, false)
+}
+
+func isDir(path string) bool {
+ if stat, err := os.Stat(path); err == nil {
+ return stat.IsDir()
+ }
+ return false
+}
+
+// Concurrent logging should not corrupt the underling buffer.
+// Use go test -race to detect the race in this test.
+func (s *HelpersS) TestConcurrentLogging(c *check.C) {
+ defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(runtime.NumCPU()))
+ var start, stop sync.WaitGroup
+ start.Add(1)
+ for i, n := 0, runtime.NumCPU()*2; i < n; i++ {
+ stop.Add(1)
+ go func(i int) {
+ start.Wait()
+ for j := 0; j < 30; j++ {
+ c.Logf("Worker %d: line %d", i, j)
+ }
+ stop.Done()
+ }(i)
+ }
+ start.Done()
+ stop.Wait()
+}
+
+// -----------------------------------------------------------------------
+// Test the TestName function
+
+type TestNameHelper struct {
+ name1 string
+ name2 string
+ name3 string
+ name4 string
+ name5 string
+}
+
+func (s *TestNameHelper) SetUpSuite(c *check.C) { s.name1 = c.TestName() }
+func (s *TestNameHelper) SetUpTest(c *check.C) { s.name2 = c.TestName() }
+func (s *TestNameHelper) Test(c *check.C) { s.name3 = c.TestName() }
+func (s *TestNameHelper) TearDownTest(c *check.C) { s.name4 = c.TestName() }
+func (s *TestNameHelper) TearDownSuite(c *check.C) { s.name5 = c.TestName() }
+
+func (s *HelpersS) TestTestName(c *check.C) {
+ helper := TestNameHelper{}
+ output := String{}
+ check.Run(&helper, &check.RunConf{Output: &output})
+ c.Check(helper.name1, check.Equals, "")
+ c.Check(helper.name2, check.Equals, "TestNameHelper.Test")
+ c.Check(helper.name3, check.Equals, "TestNameHelper.Test")
+ c.Check(helper.name4, check.Equals, "TestNameHelper.Test")
+ c.Check(helper.name5, check.Equals, "")
+}
+
+// -----------------------------------------------------------------------
+// A couple of helper functions to test helper functions. :-)
+
+func testHelperSuccess(c *check.C, name string, expectedResult interface{}, closure func() interface{}) {
+ var result interface{}
+ defer (func() {
+ if err := recover(); err != nil {
+ panic(err)
+ }
+ checkState(c, result,
+ &expectedState{
+ name: name,
+ result: expectedResult,
+ failed: false,
+ log: "",
+ })
+ })()
+ result = closure()
+}
+
+func testHelperFailure(c *check.C, name string, expectedResult interface{}, shouldStop bool, log string, closure func() interface{}) {
+ var result interface{}
+ defer (func() {
+ if err := recover(); err != nil {
+ panic(err)
+ }
+ checkState(c, result,
+ &expectedState{
+ name: name,
+ result: expectedResult,
+ failed: true,
+ log: log,
+ })
+ })()
+ result = closure()
+ if shouldStop {
+ c.Logf("%s didn't stop when it should", name)
+ }
+}
diff --git a/internal/gopkg.in/check.v1/printer.go b/vendor/gopkg.in/check.v1/printer.go
similarity index 100%
rename from internal/gopkg.in/check.v1/printer.go
rename to vendor/gopkg.in/check.v1/printer.go
diff --git a/vendor/gopkg.in/check.v1/printer_test.go b/vendor/gopkg.in/check.v1/printer_test.go
new file mode 100644
index 00000000..538b2d52
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/printer_test.go
@@ -0,0 +1,104 @@
+package check_test
+
+import (
+ . "gopkg.in/check.v1"
+)
+
+var _ = Suite(&PrinterS{})
+
+type PrinterS struct{}
+
+func (s *PrinterS) TestCountSuite(c *C) {
+ suitesRun += 1
+}
+
+var printTestFuncLine int
+
+func init() {
+ printTestFuncLine = getMyLine() + 3
+}
+
+func printTestFunc() {
+ println(1) // Comment1
+ if 2 == 2 { // Comment2
+ println(3) // Comment3
+ }
+ switch 5 {
+ case 6: println(6) // Comment6
+ println(7)
+ }
+ switch interface{}(9).(type) {// Comment9
+ case int: println(10)
+ println(11)
+ }
+ select {
+ case <-(chan bool)(nil): println(14)
+ println(15)
+ default: println(16)
+ println(17)
+ }
+ println(19,
+ 20)
+ _ = func() { println(21)
+ println(22)
+ }
+ println(24, func() {
+ println(25)
+ })
+ // Leading comment
+ // with multiple lines.
+ println(29) // Comment29
+}
+
+var printLineTests = []struct {
+ line int
+ output string
+}{
+ {1, "println(1) // Comment1"},
+ {2, "if 2 == 2 { // Comment2\n ...\n}"},
+ {3, "println(3) // Comment3"},
+ {5, "switch 5 {\n...\n}"},
+ {6, "case 6:\n println(6) // Comment6\n ..."},
+ {7, "println(7)"},
+ {9, "switch interface{}(9).(type) { // Comment9\n...\n}"},
+ {10, "case int:\n println(10)\n ..."},
+ {14, "case <-(chan bool)(nil):\n println(14)\n ..."},
+ {15, "println(15)"},
+ {16, "default:\n println(16)\n ..."},
+ {17, "println(17)"},
+ {19, "println(19,\n 20)"},
+ {20, "println(19,\n 20)"},
+ {21, "_ = func() {\n println(21)\n println(22)\n}"},
+ {22, "println(22)"},
+ {24, "println(24, func() {\n println(25)\n})"},
+ {25, "println(25)"},
+ {26, "println(24, func() {\n println(25)\n})"},
+ {29, "// Leading comment\n// with multiple lines.\nprintln(29) // Comment29"},
+}
+
+func (s *PrinterS) TestPrintLine(c *C) {
+ for _, test := range printLineTests {
+ output, err := PrintLine("printer_test.go", printTestFuncLine+test.line)
+ c.Assert(err, IsNil)
+ c.Assert(output, Equals, test.output)
+ }
+}
+
+var indentTests = []struct {
+ in, out string
+}{
+ {"", ""},
+ {"\n", "\n"},
+ {"a", ">>>a"},
+ {"a\n", ">>>a\n"},
+ {"a\nb", ">>>a\n>>>b"},
+ {" ", ">>> "},
+}
+
+func (s *PrinterS) TestIndent(c *C) {
+ for _, test := range indentTests {
+ out := Indent(test.in, ">>>")
+ c.Assert(out, Equals, test.out)
+ }
+
+}
diff --git a/internal/gopkg.in/check.v1/run.go b/vendor/gopkg.in/check.v1/run.go
similarity index 100%
rename from internal/gopkg.in/check.v1/run.go
rename to vendor/gopkg.in/check.v1/run.go
diff --git a/vendor/gopkg.in/check.v1/run_test.go b/vendor/gopkg.in/check.v1/run_test.go
new file mode 100644
index 00000000..f41fffc3
--- /dev/null
+++ b/vendor/gopkg.in/check.v1/run_test.go
@@ -0,0 +1,419 @@
+// These tests verify the test running logic.
+
+package check_test
+
+import (
+ "errors"
+ . "gopkg.in/check.v1"
+ "os"
+ "sync"
+)
+
+var runnerS = Suite(&RunS{})
+
+type RunS struct{}
+
+func (s *RunS) TestCountSuite(c *C) {
+ suitesRun += 1
+}
+
+// -----------------------------------------------------------------------
+// Tests ensuring result counting works properly.
+
+func (s *RunS) TestSuccess(c *C) {
+ output := String{}
+ result := Run(&SuccessHelper{}, &RunConf{Output: &output})
+ c.Check(result.Succeeded, Equals, 1)
+ c.Check(result.Failed, Equals, 0)
+ c.Check(result.Skipped, Equals, 0)
+ c.Check(result.Panicked, Equals, 0)
+ c.Check(result.FixturePanicked, Equals, 0)
+ c.Check(result.Missed, Equals, 0)
+ c.Check(result.RunError, IsNil)
+}
+
+func (s *RunS) TestFailure(c *C) {
+ output := String{}
+ result := Run(&FailHelper{}, &RunConf{Output: &output})
+ c.Check(result.Succeeded, Equals, 0)
+ c.Check(result.Failed, Equals, 1)
+ c.Check(result.Skipped, Equals, 0)
+ c.Check(result.Panicked, Equals, 0)
+ c.Check(result.FixturePanicked, Equals, 0)
+ c.Check(result.Missed, Equals, 0)
+ c.Check(result.RunError, IsNil)
+}
+
+func (s *RunS) TestFixture(c *C) {
+ output := String{}
+ result := Run(&FixtureHelper{}, &RunConf{Output: &output})
+ c.Check(result.Succeeded, Equals, 2)
+ c.Check(result.Failed, Equals, 0)
+ c.Check(result.Skipped, Equals, 0)
+ c.Check(result.Panicked, Equals, 0)
+ c.Check(result.FixturePanicked, Equals, 0)
+ c.Check(result.Missed, Equals, 0)
+ c.Check(result.RunError, IsNil)
+}
+
+func (s *RunS) TestPanicOnTest(c *C) {
+ output := String{}
+ helper := &FixtureHelper{panicOn: "Test1"}
+ result := Run(helper, &RunConf{Output: &output})
+ c.Check(result.Succeeded, Equals, 1)
+ c.Check(result.Failed, Equals, 0)
+ c.Check(result.Skipped, Equals, 0)
+ c.Check(result.Panicked, Equals, 1)
+ c.Check(result.FixturePanicked, Equals, 0)
+ c.Check(result.Missed, Equals, 0)
+ c.Check(result.RunError, IsNil)
+}
+
+func (s *RunS) TestPanicOnSetUpTest(c *C) {
+ output := String{}
+ helper := &FixtureHelper{panicOn: "SetUpTest"}
+ result := Run(helper, &RunConf{Output: &output})
+ c.Check(result.Succeeded, Equals, 0)
+ c.Check(result.Failed, Equals, 0)
+ c.Check(result.Skipped, Equals, 0)
+ c.Check(result.Panicked, Equals, 0)
+ c.Check(result.FixturePanicked, Equals, 1)
+ c.Check(result.Missed, Equals, 2)
+ c.Check(result.RunError, IsNil)
+}
+
+func (s *RunS) TestPanicOnSetUpSuite(c *C) {
+ output := String{}
+ helper := &FixtureHelper{panicOn: "SetUpSuite"}
+ result := Run(helper, &RunConf{Output: &output})
+ c.Check(result.Succeeded, Equals, 0)
+ c.Check(result.Failed, Equals, 0)
+ c.Check(result.Skipped, Equals, 0)
+ c.Check(result.Panicked, Equals, 0)
+ c.Check(result.FixturePanicked, Equals, 1)
+ c.Check(result.Missed, Equals, 2)
+ c.Check(result.RunError, IsNil)
+}
+
+// -----------------------------------------------------------------------
+// Check result aggregation.
+
+func (s *RunS) TestAdd(c *C) {
+ result := &Result{
+ Succeeded: 1,
+ Skipped: 2,
+ Failed: 3,
+ Panicked: 4,
+ FixturePanicked: 5,
+ Missed: 6,
+ ExpectedFailures: 7,
+ }
+ result.Add(&Result{
+ Succeeded: 10,
+ Skipped: 20,
+ Failed: 30,
+ Panicked: 40,
+ FixturePanicked: 50,
+ Missed: 60,
+ ExpectedFailures: 70,
+ })
+ c.Check(result.Succeeded, Equals, 11)
+ c.Check(result.Skipped, Equals, 22)
+ c.Check(result.Failed, Equals, 33)
+ c.Check(result.Panicked, Equals, 44)
+ c.Check(result.FixturePanicked, Equals, 55)
+ c.Check(result.Missed, Equals, 66)
+ c.Check(result.ExpectedFailures, Equals, 77)
+ c.Check(result.RunError, IsNil)
+}
+
+// -----------------------------------------------------------------------
+// Check the Passed() method.
+
+func (s *RunS) TestPassed(c *C) {
+ c.Assert((&Result{}).Passed(), Equals, true)
+ c.Assert((&Result{Succeeded: 1}).Passed(), Equals, true)
+ c.Assert((&Result{Skipped: 1}).Passed(), Equals, true)
+ c.Assert((&Result{Failed: 1}).Passed(), Equals, false)
+ c.Assert((&Result{Panicked: 1}).Passed(), Equals, false)
+ c.Assert((&Result{FixturePanicked: 1}).Passed(), Equals, false)
+ c.Assert((&Result{Missed: 1}).Passed(), Equals, false)
+ c.Assert((&Result{RunError: errors.New("!")}).Passed(), Equals, false)
+}
+
+// -----------------------------------------------------------------------
+// Check that result printing is working correctly.
+
+func (s *RunS) TestPrintSuccess(c *C) {
+ result := &Result{Succeeded: 5}
+ c.Check(result.String(), Equals, "OK: 5 passed")
+}
+
+func (s *RunS) TestPrintFailure(c *C) {
+ result := &Result{Failed: 5}
+ c.Check(result.String(), Equals, "OOPS: 0 passed, 5 FAILED")
+}
+
+func (s *RunS) TestPrintSkipped(c *C) {
+ result := &Result{Skipped: 5}
+ c.Check(result.String(), Equals, "OK: 0 passed, 5 skipped")
+}
+
+func (s *RunS) TestPrintExpectedFailures(c *C) {
+ result := &Result{ExpectedFailures: 5}
+ c.Check(result.String(), Equals, "OK: 0 passed, 5 expected failures")
+}
+
+func (s *RunS) TestPrintPanicked(c *C) {
+ result := &Result{Panicked: 5}
+ c.Check(result.String(), Equals, "OOPS: 0 passed, 5 PANICKED")
+}
+
+func (s *RunS) TestPrintFixturePanicked(c *C) {
+ result := &Result{FixturePanicked: 5}
+ c.Check(result.String(), Equals, "OOPS: 0 passed, 5 FIXTURE-PANICKED")
+}
+
+func (s *RunS) TestPrintMissed(c *C) {
+ result := &Result{Missed: 5}
+ c.Check(result.String(), Equals, "OOPS: 0 passed, 5 MISSED")
+}
+
+func (s *RunS) TestPrintAll(c *C) {
+ result := &Result{Succeeded: 1, Skipped: 2, ExpectedFailures: 3,
+ Panicked: 4, FixturePanicked: 5, Missed: 6}
+ c.Check(result.String(), Equals,
+ "OOPS: 1 passed, 2 skipped, 3 expected failures, 4 PANICKED, "+
+ "5 FIXTURE-PANICKED, 6 MISSED")
+}
+
+func (s *RunS) TestPrintRunError(c *C) {
+ result := &Result{Succeeded: 1, Failed: 1,
+ RunError: errors.New("Kaboom!")}
+ c.Check(result.String(), Equals, "ERROR: Kaboom!")
+}
+
+// -----------------------------------------------------------------------
+// Verify that the method pattern flag works correctly.
+
+func (s *RunS) TestFilterTestName(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: "Test[91]"}
+ Run(&helper, &runConf)
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 5)
+}
+
+func (s *RunS) TestFilterTestNameWithAll(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: ".*"}
+ Run(&helper, &runConf)
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "SetUpTest")
+ c.Check(helper.calls[5], Equals, "Test2")
+ c.Check(helper.calls[6], Equals, "TearDownTest")
+ c.Check(helper.calls[7], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 8)
+}
+
+func (s *RunS) TestFilterSuiteName(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: "FixtureHelper"}
+ Run(&helper, &runConf)
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test1")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "SetUpTest")
+ c.Check(helper.calls[5], Equals, "Test2")
+ c.Check(helper.calls[6], Equals, "TearDownTest")
+ c.Check(helper.calls[7], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 8)
+}
+
+func (s *RunS) TestFilterSuiteNameAndTestName(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: "FixtureHelper\\.Test2"}
+ Run(&helper, &runConf)
+ c.Check(helper.calls[0], Equals, "SetUpSuite")
+ c.Check(helper.calls[1], Equals, "SetUpTest")
+ c.Check(helper.calls[2], Equals, "Test2")
+ c.Check(helper.calls[3], Equals, "TearDownTest")
+ c.Check(helper.calls[4], Equals, "TearDownSuite")
+ c.Check(len(helper.calls), Equals, 5)
+}
+
+func (s *RunS) TestFilterAllOut(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: "NotFound"}
+ Run(&helper, &runConf)
+ c.Check(len(helper.calls), Equals, 0)
+}
+
+func (s *RunS) TestRequirePartialMatch(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: "est"}
+ Run(&helper, &runConf)
+ c.Check(len(helper.calls), Equals, 8)
+}
+
+func (s *RunS) TestFilterError(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Filter: "]["}
+ result := Run(&helper, &runConf)
+ c.Check(result.String(), Equals,
+ "ERROR: Bad filter expression: error parsing regexp: missing closing ]: `[`")
+ c.Check(len(helper.calls), Equals, 0)
+}
+
+// -----------------------------------------------------------------------
+// Verify that List works correctly.
+
+func (s *RunS) TestListFiltered(c *C) {
+ names := List(&FixtureHelper{}, &RunConf{Filter: "1"})
+ c.Assert(names, DeepEquals, []string{
+ "FixtureHelper.Test1",
+ })
+}
+
+func (s *RunS) TestList(c *C) {
+ names := List(&FixtureHelper{}, &RunConf{})
+ c.Assert(names, DeepEquals, []string{
+ "FixtureHelper.Test1",
+ "FixtureHelper.Test2",
+ })
+}
+
+// -----------------------------------------------------------------------
+// Verify that verbose mode prints tests which pass as well.
+
+func (s *RunS) TestVerboseMode(c *C) {
+ helper := FixtureHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Verbose: true}
+ Run(&helper, &runConf)
+
+ expected := "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test1\t *[.0-9]+s\n" +
+ "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n"
+
+ c.Assert(output.value, Matches, expected)
+}
+
+func (s *RunS) TestVerboseModeWithFailBeforePass(c *C) {
+ helper := FixtureHelper{panicOn: "Test1"}
+ output := String{}
+ runConf := RunConf{Output: &output, Verbose: true}
+ Run(&helper, &runConf)
+
+ expected := "(?s).*PANIC.*\n-+\n" + // Should have an extra line.
+ "PASS: check_test\\.go:[0-9]+: FixtureHelper\\.Test2\t *[.0-9]+s\n"
+
+ c.Assert(output.value, Matches, expected)
+}
+
+// -----------------------------------------------------------------------
+// Verify the stream output mode. In this mode there's no output caching.
+
+type StreamHelper struct {
+ l2 sync.Mutex
+ l3 sync.Mutex
+}
+
+func (s *StreamHelper) SetUpSuite(c *C) {
+ c.Log("0")
+}
+
+func (s *StreamHelper) Test1(c *C) {
+ c.Log("1")
+ s.l2.Lock()
+ s.l3.Lock()
+ go func() {
+ s.l2.Lock() // Wait for "2".
+ c.Log("3")
+ s.l3.Unlock()
+ }()
+}
+
+func (s *StreamHelper) Test2(c *C) {
+ c.Log("2")
+ s.l2.Unlock()
+ s.l3.Lock() // Wait for "3".
+ c.Fail()
+ c.Log("4")
+}
+
+func (s *RunS) TestStreamMode(c *C) {
+ helper := &StreamHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Stream: true}
+ Run(helper, &runConf)
+
+ expected := "START: run_test\\.go:[0-9]+: StreamHelper\\.SetUpSuite\n0\n" +
+ "PASS: run_test\\.go:[0-9]+: StreamHelper\\.SetUpSuite\t *[.0-9]+s\n\n" +
+ "START: run_test\\.go:[0-9]+: StreamHelper\\.Test1\n1\n" +
+ "PASS: run_test\\.go:[0-9]+: StreamHelper\\.Test1\t *[.0-9]+s\n\n" +
+ "START: run_test\\.go:[0-9]+: StreamHelper\\.Test2\n2\n3\n4\n" +
+ "FAIL: run_test\\.go:[0-9]+: StreamHelper\\.Test2\n\n"
+
+ c.Assert(output.value, Matches, expected)
+}
+
+type StreamMissHelper struct{}
+
+func (s *StreamMissHelper) SetUpSuite(c *C) {
+ c.Log("0")
+ c.Fail()
+}
+
+func (s *StreamMissHelper) Test1(c *C) {
+ c.Log("1")
+}
+
+func (s *RunS) TestStreamModeWithMiss(c *C) {
+ helper := &StreamMissHelper{}
+ output := String{}
+ runConf := RunConf{Output: &output, Stream: true}
+ Run(helper, &runConf)
+
+ expected := "START: run_test\\.go:[0-9]+: StreamMissHelper\\.SetUpSuite\n0\n" +
+ "FAIL: run_test\\.go:[0-9]+: StreamMissHelper\\.SetUpSuite\n\n" +
+ "START: run_test\\.go:[0-9]+: StreamMissHelper\\.Test1\n" +
+ "MISS: run_test\\.go:[0-9]+: StreamMissHelper\\.Test1\n\n"
+
+ c.Assert(output.value, Matches, expected)
+}
+
+// -----------------------------------------------------------------------
+// Verify that that the keep work dir request indeed does so.
+
+type WorkDirSuite struct {}
+
+func (s *WorkDirSuite) Test(c *C) {
+ c.MkDir()
+}
+
+func (s *RunS) TestKeepWorkDir(c *C) {
+ output := String{}
+ runConf := RunConf{Output: &output, Verbose: true, KeepWorkDir: true}
+ result := Run(&WorkDirSuite{}, &runConf)
+
+ c.Assert(result.String(), Matches, ".*\nWORK=" + result.WorkDir)
+
+ stat, err := os.Stat(result.WorkDir)
+ c.Assert(err, IsNil)
+ c.Assert(stat.IsDir(), Equals, true)
+}
diff --git a/version-main.go b/version-main.go
index 351d17a3..851b7c9d 100644
--- a/version-main.go
+++ b/version-main.go
@@ -21,9 +21,9 @@ import (
"net/http"
"time"
- "github.com/minio/mc/internal/github.com/minio/cli"
- "github.com/minio/mc/internal/github.com/minio/minio/pkg/probe"
+ "github.com/minio/cli"
"github.com/minio/mc/pkg/console"
+ "github.com/minio/minio/pkg/probe"
)
var versionCmd = cli.Command{