switch usage directly to errdefs.(ErrAlreadyExists and ErrNotFound)

Signed-off-by: Zou Nengren <zouyee1989@gmail.com>
This commit is contained in:
zounengren
2021-09-24 18:26:58 +08:00
parent 45e0e5a77e
commit fcffe0c83a
19 changed files with 87 additions and 91 deletions

View File

@@ -19,9 +19,8 @@ package snapshot
import (
"sync"
"github.com/containerd/containerd/errdefs"
snapshot "github.com/containerd/containerd/snapshots"
"github.com/containerd/containerd/pkg/cri/store"
)
// Snapshot contains the information about the snapshot.
@@ -65,7 +64,7 @@ func (s *Store) Get(key string) (Snapshot, error) {
if sn, ok := s.snapshots[key]; ok {
return sn, nil
}
return Snapshot{}, store.ErrNotExist
return Snapshot{}, errdefs.ErrNotFound
}
// List lists all snapshots.

View File

@@ -20,10 +20,10 @@ import (
"testing"
"time"
"github.com/containerd/containerd/errdefs"
snapshot "github.com/containerd/containerd/snapshots"
assertlib "github.com/stretchr/testify/assert"
"github.com/containerd/containerd/pkg/cri/store"
assertlib "github.com/stretchr/testify/assert"
)
func TestSnapshotStore(t *testing.T) {
@@ -80,5 +80,5 @@ func TestSnapshotStore(t *testing.T) {
t.Logf("get should return empty struct and ErrNotExist after deletion")
sn, err := s.Get(testKey)
assert.Equal(Snapshot{}, sn)
assert.Equal(store.ErrNotExist, err)
assert.Equal(errdefs.ErrNotFound, err)
}