vendor: add qingstor-sdk-go for QingStor

This commit is contained in:
wuyu 2017-06-26 05:45:22 +08:00 committed by Nick Craig-Wood
parent f682002b84
commit 466dd22b44
136 changed files with 15952 additions and 1 deletions

21
vendor/github.com/pengsrc/go-shared/check/error.go generated vendored Normal file
View file

@ -0,0 +1,21 @@
package check
import (
"fmt"
"os"
)
// ErrorForExit check the error.
// If error is not nil, print the error message and exit the application.
// If error is nil, do nothing.
func ErrorForExit(name string, err error, code ...int) {
if err != nil {
exitCode := 1
if len(code) > 0 {
exitCode = code[0]
}
fmt.Fprintf(os.Stderr, "%s: %s (%d)\n", name, err.Error(), exitCode)
fmt.Fprintf(os.Stderr, "See \"%s --help\".\n", name)
os.Exit(exitCode)
}
}

View file

@ -0,0 +1,12 @@
package check
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCheckErrorForExit(t *testing.T) {
ErrorForExit("name", nil)
assert.True(t, true)
}

11
vendor/github.com/pengsrc/go-shared/check/host.go generated vendored Normal file
View file

@ -0,0 +1,11 @@
package check
import (
"regexp"
)
// HostAndPort checks whether a string contains host and port.
// It returns true if matched.
func HostAndPort(hostAndPort string) bool {
return regexp.MustCompile(`^[^:]+:[0-9]+$`).MatchString(hostAndPort)
}

16
vendor/github.com/pengsrc/go-shared/check/host_test.go generated vendored Normal file
View file

@ -0,0 +1,16 @@
package check
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestCheckHostAndPort(t *testing.T) {
assert.False(t, HostAndPort("127.0.0.1:80:90"))
assert.False(t, HostAndPort("127.0.0.1"))
assert.False(t, HostAndPort("mysql"))
assert.False(t, HostAndPort("mysql:mysql"))
assert.True(t, HostAndPort("mysql:3306"))
assert.True(t, HostAndPort("172.16.70.50:6379"))
}

41
vendor/github.com/pengsrc/go-shared/check/slice.go generated vendored Normal file
View file

@ -0,0 +1,41 @@
package check
// StringSliceContains iterates over the slice to find the target.
func StringSliceContains(slice []string, target string) bool {
for _, v := range slice {
if v == target {
return true
}
}
return false
}
// IntSliceContains iterates over the slice to find the target.
func IntSliceContains(slice []int, target int) bool {
for _, v := range slice {
if v == target {
return true
}
}
return false
}
// Int32SliceContains iterates over the slice to find the target.
func Int32SliceContains(slice []int32, target int32) bool {
for _, v := range slice {
if v == target {
return true
}
}
return false
}
// Int64SliceContains iterates over the slice to find the target.
func Int64SliceContains(slice []int64, target int64) bool {
for _, v := range slice {
if v == target {
return true
}
}
return false
}

View file

@ -0,0 +1,27 @@
package check
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestStringSliceContains(t *testing.T) {
assert.True(t, StringSliceContains([]string{"1", "2", "3"}, "2"))
assert.False(t, StringSliceContains([]string{"1", "2", "3"}, "4"))
}
func TestIntSliceContains(t *testing.T) {
assert.True(t, IntSliceContains([]int{1, 2, 3, 4, 5, 6}, 4))
assert.False(t, IntSliceContains([]int{1, 2, 3, 4, 5, 6}, 7))
}
func TestInt32SliceContains(t *testing.T) {
assert.True(t, Int32SliceContains([]int32{1, 2, 3, 4, 5, 6}, 4))
assert.False(t, Int32SliceContains([]int32{1, 2, 3, 4, 5, 6}, 7))
}
func TestInt64SliceContains(t *testing.T) {
assert.True(t, Int64SliceContains([]int64{1, 2, 3, 4, 5, 6}, 4))
assert.False(t, Int64SliceContains([]int64{1, 2, 3, 4, 5, 6}, 7))
}