Switch to github.com/golang/dep for vendoring

Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
Mrunal Patel 2017-01-31 16:45:59 -08:00
parent d6ab91be27
commit 8e5b17cf13
15431 changed files with 3971413 additions and 8881 deletions

82
vendor/gopkg.in/cheggaaa/pb.v1/example_copy_test.go generated vendored Normal file
View file

@ -0,0 +1,82 @@
package pb_test
import (
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
"gopkg.in/cheggaaa/pb.v1"
)
func Example_copy() {
// check args
if len(os.Args) < 3 {
printUsage()
return
}
sourceName, destName := os.Args[1], os.Args[2]
// check source
var source io.Reader
var sourceSize int64
if strings.HasPrefix(sourceName, "http://") {
// open as url
resp, err := http.Get(sourceName)
if err != nil {
fmt.Printf("Can't get %s: %v\n", sourceName, err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Printf("Server return non-200 status: %v\n", resp.Status)
return
}
i, _ := strconv.Atoi(resp.Header.Get("Content-Length"))
sourceSize = int64(i)
source = resp.Body
} else {
// open as file
s, err := os.Open(sourceName)
if err != nil {
fmt.Printf("Can't open %s: %v\n", sourceName, err)
return
}
defer s.Close()
// get source size
sourceStat, err := s.Stat()
if err != nil {
fmt.Printf("Can't stat %s: %v\n", sourceName, err)
return
}
sourceSize = sourceStat.Size()
source = s
}
// create dest
dest, err := os.Create(destName)
if err != nil {
fmt.Printf("Can't create %s: %v\n", destName, err)
return
}
defer dest.Close()
// create bar
bar := pb.New(int(sourceSize)).SetUnits(pb.U_BYTES).SetRefreshRate(time.Millisecond * 10)
bar.ShowSpeed = true
bar.Start()
// create proxy reader
reader := bar.NewProxyReader(source)
// and copy from reader
io.Copy(dest, reader)
bar.Finish()
}
func printUsage() {
fmt.Println("copy [source file or url] [dest file]")
}

View file

@ -0,0 +1,37 @@
package pb_test
import (
"math/rand"
"sync"
"time"
"gopkg.in/cheggaaa/pb.v1"
)
func Example_multiple() {
// create bars
first := pb.New(200).Prefix("First ")
second := pb.New(200).Prefix("Second ")
third := pb.New(200).Prefix("Third ")
// start pool
pool, err := pb.StartPool(first, second, third)
if err != nil {
panic(err)
}
// update bars
wg := new(sync.WaitGroup)
for _, bar := range []*pb.ProgressBar{first, second, third} {
wg.Add(1)
go func(cb *pb.ProgressBar) {
for n := 0; n < 200; n++ {
cb.Increment()
time.Sleep(time.Millisecond * time.Duration(rand.Intn(100)))
}
cb.Finish()
wg.Done()
}(bar)
}
wg.Wait()
// close pool
pool.Stop()
}

30
vendor/gopkg.in/cheggaaa/pb.v1/example_test.go generated vendored Normal file
View file

@ -0,0 +1,30 @@
package pb_test
import (
"time"
"gopkg.in/cheggaaa/pb.v1"
)
func Example() {
count := 5000
bar := pb.New(count)
// show percents (by default already true)
bar.ShowPercent = true
// show bar (by default already true)
bar.ShowBar = true
bar.ShowCounters = true
bar.ShowTimeLeft = true
// and start
bar.Start()
for i := 0; i < count; i++ {
bar.Increment()
time.Sleep(time.Millisecond)
}
bar.FinishPrint("The End!")
}

57
vendor/gopkg.in/cheggaaa/pb.v1/format_test.go generated vendored Normal file
View file

@ -0,0 +1,57 @@
package pb_test
import (
"fmt"
"gopkg.in/cheggaaa/pb.v1"
"strconv"
"testing"
"time"
)
func Test_DefaultsToInteger(t *testing.T) {
value := int64(1000)
expected := strconv.Itoa(int(value))
actual := pb.Format(value).String()
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 := pb.Format(value).To(pb.U_NO).String()
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 := pb.Format(value).To(pb.U_BYTES).String()
if actual != expected {
t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
}
}
func Test_CanFormatDuration(t *testing.T) {
value := 10 * time.Minute
expected := "10m0s"
actual := pb.Format(int64(value)).To(pb.U_DURATION).String()
if actual != expected {
t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
}
}
func Test_DefaultUnitsWidth(t *testing.T) {
value := 10
expected := " 10"
actual := pb.Format(int64(value)).Width(7).String()
if actual != expected {
t.Error(fmt.Sprintf("Expected {%s} was {%s}", expected, actual))
}
}

103
vendor/gopkg.in/cheggaaa/pb.v1/pb_test.go generated vendored Normal file
View file

@ -0,0 +1,103 @@
package pb
import (
"bytes"
"strings"
"testing"
"time"
"github.com/fatih/color"
"github.com/mattn/go-colorable"
)
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()
}
func Test_Format(t *testing.T) {
bar := New(5000).Format(strings.Join([]string{
color.GreenString("["),
color.New(color.BgGreen).SprintFunc()("o"),
color.New(color.BgHiGreen).SprintFunc()("o"),
color.New(color.BgRed).SprintFunc()("o"),
color.GreenString("]"),
}, "\x00"))
w := colorable.NewColorableStdout()
bar.Callback = func(out string) {
w.Write([]byte(out))
}
bar.Add(2000)
bar.Finish()
bar.Finish()
}
func Test_AutoStat(t *testing.T) {
bar := New(5)
bar.AutoStat = true
bar.Start()
time.Sleep(2 * time.Second)
//real start work
for i := 0; i < 5; i++ {
time.Sleep(500 * time.Millisecond)
bar.Increment()
}
//real finish work
time.Sleep(2 * time.Second)
bar.Finish()
}
func Test_Finish_PrintNewline(t *testing.T) {
bar := New(5)
buf := &bytes.Buffer{}
bar.Output = buf
bar.Finish()
expected := "\n"
actual := buf.String()
//Finish should write newline to bar.Output
if !strings.HasSuffix(actual, expected) {
t.Errorf("Expected %q to have suffix %q", expected, actual)
}
}
func Test_FinishPrint(t *testing.T) {
bar := New(5)
buf := &bytes.Buffer{}
bar.Output = buf
bar.FinishPrint("foo")
expected := "foo\n"
actual := buf.String()
//FinishPrint should write to bar.Output
if !strings.HasSuffix(actual, expected) {
t.Errorf("Expected %q to have suffix %q", expected, actual)
}
}

20
vendor/gopkg.in/cheggaaa/pb.v1/runecount_test.go generated vendored Normal file
View file

@ -0,0 +1,20 @@
package pb
import "testing"
func Test_RuneCount(t *testing.T) {
s := string([]byte{
27, 91, 51, 49, 109, // {Red}
72, 101, 108, 108, 111, // Hello
44, 32, // ,
112, 108, 97, 121, 103, 114, 111, 117, 110, 100, // Playground
27, 91, 48, 109, // {Reset}
})
if e, l := 17, escapeAwareRuneCountInString(s); l != e {
t.Errorf("Invalid length %d, expected %d", l, e)
}
s = "進捗 "
if e, l := 5, escapeAwareRuneCountInString(s); l != e {
t.Errorf("Invalid length %d, expected %d", l, e)
}
}