Пример #1
0
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)
}
Пример #2
0
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)
}
Пример #3
0
// 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
}
Пример #4
0
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`)
}
Пример #5
0
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)
}