summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/hashicorp/go-multierror/flatten_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-multierror/flatten_test.go')
-rw-r--r--vendor/github.com/hashicorp/go-multierror/flatten_test.go48
1 files changed, 48 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-multierror/flatten_test.go b/vendor/github.com/hashicorp/go-multierror/flatten_test.go
new file mode 100644
index 000000000..9fbacadca
--- /dev/null
+++ b/vendor/github.com/hashicorp/go-multierror/flatten_test.go
@@ -0,0 +1,48 @@
+package multierror
+
+import (
+ "errors"
+ "fmt"
+ "reflect"
+ "strings"
+ "testing"
+)
+
+func TestFlatten(t *testing.T) {
+ original := &Error{
+ Errors: []error{
+ errors.New("one"),
+ &Error{
+ Errors: []error{
+ errors.New("two"),
+ &Error{
+ Errors: []error{
+ errors.New("three"),
+ },
+ },
+ },
+ },
+ },
+ }
+
+ expected := strings.TrimSpace(`
+3 errors occurred:
+
+* one
+* two
+* three
+ `)
+ actual := fmt.Sprintf("%s", Flatten(original))
+
+ if expected != actual {
+ t.Fatalf("expected: %s, got: %s", expected, actual)
+ }
+}
+
+func TestFlatten_nonError(t *testing.T) {
+ err := errors.New("foo")
+ actual := Flatten(err)
+ if !reflect.DeepEqual(actual, err) {
+ t.Fatalf("bad: %#v", actual)
+ }
+}