Beispiel #1
0
func (s *FingerprintSuite) TestBytes(c *gc.C) {
	expected, _ := newFingerprint(c, "spamspamspam")
	fp, err := hash.NewFingerprint(expected, s.validate)
	c.Assert(err, jc.ErrorIsNil)

	sum := fp.Bytes()

	c.Check(sum, jc.DeepEquals, expected)
}
Beispiel #2
0
func (s *FingerprintSuite) TestValidateOkay(c *gc.C) {
	sum, _ := newFingerprint(c, "spamspamspam")
	fp, err := hash.NewFingerprint(sum, s.validate)
	c.Assert(err, jc.ErrorIsNil)

	err = fp.Validate()

	c.Check(err, jc.ErrorIsNil)
}
Beispiel #3
0
func (s *FingerprintSuite) TestHex(c *gc.C) {
	sum, expected := newFingerprint(c, "spamspamspam")
	fp, err := hash.NewFingerprint(sum, s.validate)
	c.Assert(err, jc.ErrorIsNil)

	hex := fp.String()

	c.Check(hex, gc.Equals, expected)
}
Beispiel #4
0
func (s *FingerprintSuite) TestNewFingerprintInvalid(c *gc.C) {
	expected, _ := newFingerprint(c, "spamspamspam")
	failure := errors.NewNotValid(nil, "bogus!!!")
	s.stub.SetErrors(failure)

	_, err := hash.NewFingerprint(expected, s.validate)

	s.stub.CheckCallNames(c, "validate")
	c.Check(errors.Cause(err), gc.Equals, failure)
}