func TestMultiStackSingleStack(t *testing.T) { frame := stack.Frame{Name: "42"} s := stack.Stack{frame} var multi stack.Multi multi.Add(s) ensure.DeepEqual(t, MultiStack(&singleStackError{stack: s}), &multi) }
func TestStackMultiStack(t *testing.T) { frame := stack.Frame{Name: "42"} s := stack.Stack{frame} var multi stack.Multi multi.Add(s) ensure.DeepEqual(t, Stack(&multiStackError{multiStack: &multi}), s) }
// MultiStack returns the best possible stack.Multi from the error or nil if // one isn't found. func MultiStack(err error) *stack.Multi { switch err := err.(type) { case *singleFrameError: var m stack.Multi m.Add(stack.Stack{err.frame}) return &m case *singleStackError: var m stack.Multi m.Add(err.stack) return &m case *multiStackError: return err.multiStack } return nil }
func TestMultiStackStringModeNone(t *testing.T) { err := errors.New("foo") var m stack.Multi m.Add(stack.Stack{ stack.Frame{ File: "f", Line: 1, Name: "n", }, }) ensure.DeepEqual( t, (&multiStackError{ underlying: err, config: Config{}, multiStack: &m, }).Error(), `foo`) }
func TestMultiStackSingleFrame(t *testing.T) { frame := stack.Frame{Name: "42"} var multi stack.Multi multi.Add(stack.Stack{frame}) ensure.DeepEqual(t, MultiStack(&singleFrameError{frame: frame}), &multi) }