images service v2 port from rackpsace/gophercloud (#171)
* CheckByteArrayEquals funcs
* direct port from rackspace/gophercloud with minor additions to get unit tests passing
* new package for uploading and downloading image data
* updates to make imageservice v2 consistent with the rest of gophercloud/gophercloud
* add image service v2 client
diff --git a/testhelper/convenience.go b/testhelper/convenience.go
index cf33e1a..f21c3f9 100644
--- a/testhelper/convenience.go
+++ b/testhelper/convenience.go
@@ -1,6 +1,7 @@
package testhelper
import (
+ "bytes"
"encoding/json"
"fmt"
"path/filepath"
@@ -256,6 +257,24 @@
})
}
+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 {