使用github的七牛SDK,配置名称Kodo->Qiniu

This commit is contained in:
deepzz0
2017-11-05 12:27:22 +08:00
parent c9fc0cc75a
commit 360204995d
429 changed files with 26939 additions and 14206 deletions

View File

@@ -195,6 +195,28 @@ func TestEqual(t *testing.T) {
}
func TestFormatUnequalValues(t *testing.T) {
expected, actual := formatUnequalValues("foo", "bar")
Equal(t, `"foo"`, expected, "value should not include type")
Equal(t, `"bar"`, actual, "value should not include type")
expected, actual = formatUnequalValues(123, 123)
Equal(t, `123`, expected, "value should not include type")
Equal(t, `123`, actual, "value should not include type")
expected, actual = formatUnequalValues(int64(123), int32(123))
Equal(t, `int64(123)`, expected, "value should include type")
Equal(t, `int32(123)`, actual, "value should include type")
type testStructType struct {
Val string
}
expected, actual = formatUnequalValues(&testStructType{Val: "test"}, &testStructType{Val: "test"})
Equal(t, `&assert.testStructType{Val:"test"}`, expected, "value should not include type annotation")
Equal(t, `&assert.testStructType{Val:"test"}`, actual, "value should not include type annotation")
}
func TestNotNil(t *testing.T) {
mockT := new(testing.T)
@@ -523,8 +545,26 @@ func TestNoError(t *testing.T) {
False(t, NoError(mockT, err), "NoError with error should return False")
// returning an empty error interface
err = func() error {
var err *customError
if err != nil {
t.Fatal("err should be nil here")
}
return err
}()
if err == nil { // err is not nil here!
t.Errorf("Error should be nil due to empty interface", err)
}
False(t, NoError(mockT, err), "NoError should fail with empty error interface")
}
type customError struct{}
func (*customError) Error() string { return "fail" }
func TestError(t *testing.T) {
mockT := new(testing.T)
@@ -539,6 +579,20 @@ func TestError(t *testing.T) {
True(t, Error(mockT, err), "Error with error should return True")
// returning an empty error interface
err = func() error {
var err *customError
if err != nil {
t.Fatal("err should be nil here")
}
return err
}()
if err == nil { // err is not nil here!
t.Errorf("Error should be nil due to empty interface", err)
}
True(t, Error(mockT, err), "Error should pass with empty error interface")
}
func TestEqualError(t *testing.T) {
@@ -1093,6 +1147,40 @@ func TestDiffEmptyCases(t *testing.T) {
Equal(t, "", diff([]int{1}, []bool{true}))
}
// Ensure there are no data races
func TestDiffRace(t *testing.T) {
t.Parallel()
expected := map[string]string{
"a": "A",
"b": "B",
"c": "C",
}
actual := map[string]string{
"d": "D",
"e": "E",
"f": "F",
}
// run diffs in parallel simulating tests with t.Parallel()
numRoutines := 10
rChans := make([]chan string, numRoutines)
for idx := range rChans {
rChans[idx] = make(chan string)
go func(ch chan string) {
defer close(ch)
ch <- diff(expected, actual)
}(rChans[idx])
}
for _, ch := range rChans {
for msg := range ch {
NotZero(t, msg) // dummy assert
}
}
}
type mockTestingT struct {
}