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