integration_test.go 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Integration tests
  2. package check_test
  3. import (
  4. . "gopkg.in/check.v1"
  5. )
  6. // -----------------------------------------------------------------------
  7. // Integration test suite.
  8. type integrationS struct{}
  9. var _ = Suite(&integrationS{})
  10. type integrationTestHelper struct{}
  11. func (s *integrationTestHelper) TestMultiLineStringEqualFails(c *C) {
  12. c.Check("foo\nbar\nbaz\nboom\n", Equals, "foo\nbaar\nbaz\nboom\n")
  13. }
  14. func (s *integrationTestHelper) TestStringEqualFails(c *C) {
  15. c.Check("foo", Equals, "bar")
  16. }
  17. func (s *integrationTestHelper) TestIntEqualFails(c *C) {
  18. c.Check(42, Equals, 43)
  19. }
  20. type complexStruct struct {
  21. r, i int
  22. }
  23. func (s *integrationTestHelper) TestStructEqualFails(c *C) {
  24. c.Check(complexStruct{1, 2}, Equals, complexStruct{3, 4})
  25. }
  26. func (s *integrationS) TestOutput(c *C) {
  27. helper := integrationTestHelper{}
  28. output := String{}
  29. Run(&helper, &RunConf{Output: &output})
  30. c.Assert(output.value, Equals, `
  31. ----------------------------------------------------------------------
  32. FAIL: integration_test.go:26: integrationTestHelper.TestIntEqualFails
  33. integration_test.go:27:
  34. c.Check(42, Equals, 43)
  35. ... obtained int = 42
  36. ... expected int = 43
  37. ----------------------------------------------------------------------
  38. FAIL: integration_test.go:18: integrationTestHelper.TestMultiLineStringEqualFails
  39. integration_test.go:19:
  40. c.Check("foo\nbar\nbaz\nboom\n", Equals, "foo\nbaar\nbaz\nboom\n")
  41. ... obtained string = "" +
  42. ... "foo\n" +
  43. ... "bar\n" +
  44. ... "baz\n" +
  45. ... "boom\n"
  46. ... expected string = "" +
  47. ... "foo\n" +
  48. ... "baar\n" +
  49. ... "baz\n" +
  50. ... "boom\n"
  51. ... String difference:
  52. ... [1]: "bar" != "baar"
  53. ----------------------------------------------------------------------
  54. FAIL: integration_test.go:22: integrationTestHelper.TestStringEqualFails
  55. integration_test.go:23:
  56. c.Check("foo", Equals, "bar")
  57. ... obtained string = "foo"
  58. ... expected string = "bar"
  59. ----------------------------------------------------------------------
  60. FAIL: integration_test.go:34: integrationTestHelper.TestStructEqualFails
  61. integration_test.go:35:
  62. c.Check(complexStruct{1, 2}, Equals, complexStruct{3, 4})
  63. ... obtained check_test.complexStruct = check_test.complexStruct{r:1, i:2}
  64. ... expected check_test.complexStruct = check_test.complexStruct{r:3, i:4}
  65. ... Difference:
  66. ... r: 1 != 3
  67. ... i: 2 != 4
  68. `)
  69. }