No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

57 líneas
1.8 KiB

  1. // Copyright 2016 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package errorreporting
  15. import "testing"
  16. func TestChopStack(t *testing.T) {
  17. for _, test := range []struct {
  18. name string
  19. in []byte
  20. expected string
  21. }{
  22. {
  23. name: "Report",
  24. in: []byte(` goroutine 39 [running]:
  25. runtime/debug.Stack()
  26. /gopath/runtime/debug/stack.go:24 +0x79
  27. cloud.google.com/go/errorreporting.(*Client).logInternal()
  28. /gopath/cloud.google.com/go/errorreporting/errors.go:259 +0x18b
  29. cloud.google.com/go/errorreporting.(*Client).Report()
  30. /gopath/cloud.google.com/go/errorreporting/errors.go:248 +0x4ed
  31. cloud.google.com/go/errorreporting.TestReport()
  32. /gopath/cloud.google.com/go/errorreporting/errors_test.go:137 +0x2a1
  33. testing.tRunner()
  34. /gopath/testing/testing.go:610 +0x81
  35. created by testing.(*T).Run
  36. /gopath/testing/testing.go:646 +0x2ec
  37. `),
  38. expected: ` goroutine 39 [running]:
  39. cloud.google.com/go/errorreporting.TestReport()
  40. /gopath/cloud.google.com/go/errorreporting/errors_test.go:137 +0x2a1
  41. testing.tRunner()
  42. /gopath/testing/testing.go:610 +0x81
  43. created by testing.(*T).Run
  44. /gopath/testing/testing.go:646 +0x2ec
  45. `,
  46. },
  47. } {
  48. out := chopStack(test.in)
  49. if out != test.expected {
  50. t.Errorf("case %q: chopStack(%q): got %q want %q", test.name, test.in, out, test.expected)
  51. }
  52. }
  53. }