Пример #1
0
func (s *FoundationS) TestExpectFailureSucceed(c *check.C) {
	helper := ExpectFailureSucceedHelper{}
	output := String{}
	result := check.Run(&helper, &check.RunConf{Output: &output})

	c.Assert(output.value, check.Equals, "")
	c.Assert(result.ExpectedFailures, check.Equals, 1)
}
Пример #2
0
func (s *BootstrapS) TestRunDoesntShowSuccesses(c *check.C) {
	output := String{}
	check.Run(&SuccessHelper{}, &check.RunConf{Output: &output})
	if strings.Index(output.value, "Expected success!") != -1 {
		critical(fmt.Sprintf("RunWithWriter() output contained a successful "+
			"test! Got: %#v",
			output.value))
	}
}
Пример #3
0
func (s *BootstrapS) TestRunShowsErrors(c *check.C) {
	output := String{}
	check.Run(&FailHelper{}, &check.RunConf{Output: &output})
	if strings.Index(output.value, "Expected failure!") == -1 {
		critical(fmt.Sprintf("RunWithWriter() output did not contain the "+
			"expected failure! Got: %#v",
			output.value))
	}
}
Пример #4
0
func (s *FoundationS) TestSkip(c *check.C) {
	helper := SkipTestHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output})

	if output.value != "" {
		c.Error("Skip() logged something:\n", output.value)
	}
}
Пример #5
0
func (s *HelpersS) TestTestName(c *check.C) {
	helper := TestNameHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output})
	c.Check(helper.name1, check.Equals, "")
	c.Check(helper.name2, check.Equals, "TestNameHelper.Test")
	c.Check(helper.name3, check.Equals, "TestNameHelper.Test")
	c.Check(helper.name4, check.Equals, "TestNameHelper.Test")
	c.Check(helper.name5, check.Equals, "")
}
Пример #6
0
func (s *HelpersS) TestMkDir(c *check.C) {
	helper := MkDirHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output})
	c.Assert(output.value, check.Equals, "")
	c.Check(helper.isDir1, check.Equals, true)
	c.Check(helper.isDir2, check.Equals, true)
	c.Check(helper.isDir3, check.Equals, true)
	c.Check(helper.isDir4, check.Equals, true)
	c.Check(helper.path1, check.Not(check.Equals),
		helper.path2)
	c.Check(isDir(helper.path1), check.Equals, false)
	c.Check(isDir(helper.path2), check.Equals, false)
}
Пример #7
0
func (s *FoundationS) TestSkipVerbose(c *check.C) {
	helper := SkipTestHelper{}
	output := String{}
	check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})

	expected := "SKIP: foundation_test\\.go:[0-9]+: SkipTestHelper\\.TestFail" +
		" \\(Wrong platform or whatever\\)"
	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("Skip() didn't log properly:\n", output.value)
	}
}
Пример #8
0
func (s *FoundationS) TestFailureHeader(c *check.C) {
	output := String{}
	failHelper := FailHelper{}
	check.Run(&failHelper, &check.RunConf{Output: &output})
	header := fmt.Sprintf(""+
		"\n-----------------------------------"+
		"-----------------------------------\n"+
		"FAIL: check_test.go:%d: FailHelper.TestLogAndFail\n",
		failHelper.testLine)
	if strings.Index(output.value, header) == -1 {
		c.Errorf(""+
			"Failure didn't print a proper header.\n"+
			"... Got:\n%s... Expected something with:\n%s",
			output.value, header)
	}
}
Пример #9
0
func (s *FoundationS) TestExpectFailureSucceedVerbose(c *check.C) {
	helper := ExpectFailureSucceedHelper{}
	output := String{}
	result := check.Run(&helper, &check.RunConf{Output: &output, Verbose: true})

	expected := "" +
		"FAIL EXPECTED: foundation_test\\.go:[0-9]+:" +
		" ExpectFailureSucceedHelper\\.TestSucceed \\(It booms!\\)\t *[.0-9]+s\n"

	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("ExpectFailure() didn't log properly:\n", output.value)
	}

	c.Assert(result.ExpectedFailures, check.Equals, 1)
}
Пример #10
0
func (s *FoundationS) TestExpectFailureFail(c *check.C) {
	helper := ExpectFailureFailHelper{}
	output := String{}
	result := check.Run(&helper, &check.RunConf{Output: &output})

	expected := "" +
		"^\n-+\n" +
		"FAIL: foundation_test\\.go:[0-9]+:" +
		" ExpectFailureFailHelper\\.TestFail\n\n" +
		"\\.\\.\\. Error: Test succeeded, but was expected to fail\n" +
		"\\.\\.\\. Reason: Bug #XYZ\n$"

	matched, err := regexp.MatchString(expected, output.value)
	if err != nil {
		c.Error("Bad expression: ", expected)
	} else if !matched {
		c.Error("ExpectFailure() didn't log properly:\n", output.value)
	}

	c.Assert(result.ExpectedFailures, check.Equals, 0)
}