From 8d3d0404fecfaf632cf6742b2e41f83dd408d3f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 10 May 2017 11:18:39 +0200 Subject: [PATCH] Clean up SigningSuite test initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move "skip if signing is not available" into the test, there may be tests which only need verification. Move GNUPGHOME creation from SetUpTest to SetUpSuite, sharing a single key is fine. We don’t change the GNUPGHOME contents at test runtime. --- integration/signing_test.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/integration/signing_test.go b/integration/signing_test.go index b3db0b9c..3375d905 100644 --- a/integration/signing_test.go +++ b/integration/signing_test.go @@ -39,15 +39,6 @@ func findFingerprint(lineBytes []byte) (string, error) { func (s *SigningSuite) SetUpSuite(c *check.C) { _, err := exec.LookPath(skopeoBinary) c.Assert(err, check.IsNil) -} - -func (s *SigningSuite) SetUpTest(c *check.C) { - mech, _, err := signature.NewEphemeralGPGSigningMechanism([]byte{}) - c.Assert(err, check.IsNil) - defer mech.Close() - if err := mech.SupportsSigning(); err != nil { // FIXME? Test that verification and policy enforcement works, using signatures from fixtures - c.Skip(fmt.Sprintf("Signing not supported: %v", err)) - } s.gpgHome, err = ioutil.TempDir("", "skopeo-gpg") c.Assert(err, check.IsNil) @@ -61,7 +52,7 @@ func (s *SigningSuite) SetUpTest(c *check.C) { c.Assert(err, check.IsNil) } -func (s *SigningSuite) TearDownTest(c *check.C) { +func (s *SigningSuite) TearDownSuite(c *check.C) { if s.gpgHome != "" { err := os.RemoveAll(s.gpgHome) c.Assert(err, check.IsNil) @@ -72,6 +63,13 @@ func (s *SigningSuite) TearDownTest(c *check.C) { } func (s *SigningSuite) TestSignVerifySmoke(c *check.C) { + mech, _, err := signature.NewEphemeralGPGSigningMechanism([]byte{}) + c.Assert(err, check.IsNil) + defer mech.Close() + if err := mech.SupportsSigning(); err != nil { // FIXME? Test that verification and policy enforcement works, using signatures from fixtures + c.Skip(fmt.Sprintf("Signing not supported: %v", err)) + } + manifestPath := "fixtures/image.manifest.json" dockerReference := "testing/smoketest"