bump(github.com/rackspace/gophercloud): e00690e87603abe613e9f02c816c7c4bef82e063

This commit is contained in:
Mathieu Velten
2016-09-06 16:52:42 +02:00
parent 92cb90fc5d
commit 8ea400b1bf
10 changed files with 590 additions and 221 deletions

View File

@@ -1,6 +1,7 @@
package testhelper
import (
"bytes"
"encoding/json"
"fmt"
"path/filepath"
@@ -224,6 +225,21 @@ func CheckEquals(t *testing.T, expected, actual interface{}) {
}
}
// AssertErr is a convenience function for checking that an error occurred
func AssertErr(t *testing.T, e error) {
if e == nil {
logFatal(t, fmt.Sprintf("expected an error but none occurred"))
}
}
// CheckErr is a convenience function for checking that an error occurred,
// except with a non-fatal error
func CheckErr(t *testing.T, e error) {
if e == nil {
logError(t, fmt.Sprintf("expected an error but none occurred"))
}
}
// AssertDeepEquals - like Equals - performs a comparison - but on more complex
// structures that requires deeper inspection
func AssertDeepEquals(t *testing.T, expected, actual interface{}) {
@@ -256,6 +272,24 @@ func CheckDeepEquals(t *testing.T, expected, actual interface{}) {
})
}
func isByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) bool {
return bytes.Equal(expectedBytes, actualBytes)
}
// AssertByteArrayEquals a convenience function for checking whether two byte arrays are equal
func AssertByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) {
if !isByteArrayEquals(t, expectedBytes, actualBytes) {
logFatal(t, "The bytes differed.")
}
}
// CheckByteArrayEquals a convenience function for silent checking whether two byte arrays are equal
func CheckByteArrayEquals(t *testing.T, expectedBytes []byte, actualBytes []byte) {
if !isByteArrayEquals(t, expectedBytes, actualBytes) {
logError(t, "The bytes differed.")
}
}
// isJSONEquals is a utility function that implements JSON comparison for AssertJSONEquals and
// CheckJSONEquals.
func isJSONEquals(t *testing.T, expectedJSON string, actual interface{}) bool {
@@ -321,6 +355,13 @@ func AssertNoErr(t *testing.T, e error) {
}
}
// AssertNotNil is a convenience function for checking whether given value is not nil
func AssertNotNil(t *testing.T, actual interface{}) {
if actual == nil || !reflect.ValueOf(actual).Elem().IsValid() {
logFatal(t, fmt.Sprintf("Not nil expexted, but was %v", actual))
}
}
// CheckNoErr is similar to AssertNoErr, except with a non-fatal error
func CheckNoErr(t *testing.T, e error) {
if e != nil {