예제 #1
0
파일: utils_test.go 프로젝트: bac/juju
func (s *UtilsSuite) TestFingerprintMatchesOpenFailed(c *gc.C) {
	_, expected := s.newReader(c, "spam")
	matcher := context.FingerprintMatcher{
		Open: s.matcher.Open,
	}
	failure := errors.New("<failed>")
	s.stub.SetErrors(failure)

	_, err := matcher.FingerprintMatches("some/filename.txt", expected)

	c.Check(errors.Cause(err), gc.Equals, failure)
	s.stub.CheckCallNames(c, "Open")
}
예제 #2
0
파일: utils_test.go 프로젝트: bac/juju
func (s *UtilsSuite) TestFingerprintMatchesNotFound(c *gc.C) {
	_, expected := s.newReader(c, "spam")
	matcher := context.FingerprintMatcher{
		Open: s.matcher.Open,
	}
	s.stub.SetErrors(os.ErrNotExist)

	matches, err := matcher.FingerprintMatches("some/filename.txt", expected)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(matches, jc.IsFalse)
	s.stub.CheckCallNames(c, "Open")
}
예제 #3
0
파일: utils_test.go 프로젝트: bac/juju
func (s *UtilsSuite) TestFingerprintMatchesOkay(c *gc.C) {
	r, expected := s.newReader(c, "spam")
	s.matcher.ReturnOpen = r
	s.matcher.ReturnGenerateFingerprint = expected
	matcher := context.FingerprintMatcher{
		Open:                s.matcher.Open,
		GenerateFingerprint: s.matcher.GenerateFingerprint,
	}

	matches, err := matcher.FingerprintMatches("some/filename.txt", expected)
	c.Assert(err, jc.ErrorIsNil)

	c.Check(matches, jc.IsTrue)
}
예제 #4
0
파일: utils_test.go 프로젝트: bac/juju
func (s *UtilsSuite) TestFingerprintMatchesGenerateFingerprintFailed(c *gc.C) {
	r, expected := s.newReader(c, "spam")
	s.matcher.ReturnOpen = r
	matcher := context.FingerprintMatcher{
		Open:                s.matcher.Open,
		GenerateFingerprint: s.matcher.GenerateFingerprint,
	}
	failure := errors.New("<failed>")
	s.stub.SetErrors(nil, failure)

	_, err := matcher.FingerprintMatches("some/filename.txt", expected)

	c.Check(errors.Cause(err), gc.Equals, failure)
	s.stub.CheckCallNames(c, "Open", "GenerateFingerprint", "Close")
}
예제 #5
0
파일: utils_test.go 프로젝트: bac/juju
func (s *UtilsSuite) TestFingerprintMatchesDepCalls(c *gc.C) {
	r, expected := s.newReader(c, "spam")
	s.matcher.ReturnOpen = r
	s.matcher.ReturnGenerateFingerprint = expected
	matcher := context.FingerprintMatcher{
		Open:                s.matcher.Open,
		GenerateFingerprint: s.matcher.GenerateFingerprint,
	}

	matches, err := matcher.FingerprintMatches("some/filename.txt", expected)
	c.Assert(matches, jc.IsTrue)
	c.Assert(err, jc.ErrorIsNil)

	s.stub.CheckCallNames(c, "Open", "GenerateFingerprint", "Close")
	s.stub.CheckCall(c, 0, "Open", "some/filename.txt")
	s.stub.CheckCall(c, 1, "GenerateFingerprint", r)
}