From 1590f3ae77e60d45ffe4b3ef44b686edeaf20c08 Mon Sep 17 00:00:00 2001 From: lucklove Date: Tue, 3 Nov 2020 21:20:33 +0800 Subject: [PATCH] Test Signed-off-by: lucklove --- cmd/mirror.go | 4 ---- pkg/repository/mirror.go | 1 + pkg/repository/model/model.go | 11 +++++++---- pkg/repository/store/txn.go | 1 + 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/mirror.go b/cmd/mirror.go index 39e13ad888..ddffae4da4 100644 --- a/cmd/mirror.go +++ b/cmd/mirror.go @@ -140,14 +140,10 @@ func newMirrorIntroduceCmd() *cobra.Command { // the privPath can point to a public key becase the Public method of KeyInfo works on both priv and pub key privKey, err := loadPrivKey(privPath) if err != nil { - // For test, should remove before merge - panic(err) return err } pubKey, err := privKey.Public() if err != nil { - // For test, should remove before merge - panic(err) return err } diff --git a/pkg/repository/mirror.go b/pkg/repository/mirror.go index 6546e44bd7..a26c5f976a 100644 --- a/pkg/repository/mirror.go +++ b/pkg/repository/mirror.go @@ -175,6 +175,7 @@ func (l *localFilesystem) Introduce(id, name string, key *v1manifest.KeyInfo) er return err } + panic("For test") return nil } diff --git a/pkg/repository/model/model.go b/pkg/repository/model/model.go index 725d87f6ab..40a19bba70 100644 --- a/pkg/repository/model/model.go +++ b/pkg/repository/model/model.go @@ -49,12 +49,10 @@ func (m *model) Introduce(id, name string, key *v1manifest.KeyInfo) error { keyID, err := key.ID() if err != nil { - // For test, should remove before merge - panic(err) return err } - return utils.RetryUntil(func() error { + err = utils.RetryUntil(func() error { var indexFileVersion *v1manifest.FileVersion if err := m.updateIndexManifest(initTime, func(im *v1manifest.Manifest) (*v1manifest.Manifest, error) { signed := im.Signed.(*v1manifest.Index) @@ -115,10 +113,15 @@ func (m *model) Introduce(id, name string, key *v1manifest.KeyInfo) error { return err } - return m.txn.Commit() + err = m.txn.Commit() + panic(err) + return err }, func(err error) bool { return err == store.ErrorFsCommitConflict && m.txn.ResetManifest() == nil }) + + panic(err) + return err } // Publish implements Model diff --git a/pkg/repository/store/txn.go b/pkg/repository/store/txn.go index 60a469e7c5..5de31bdfb1 100644 --- a/pkg/repository/store/txn.go +++ b/pkg/repository/store/txn.go @@ -156,6 +156,7 @@ func (t *localTxn) Stat(filename string) (os.FileInfo, error) { func (t *localTxn) Commit() error { if err := t.store.lock(); err != nil { + panic(err) return err } defer t.store.unlock()