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) }
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) }
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) }
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) }