fix: storage tests

pull/1007/head
fibonacci1729 8 years ago
parent 3a6a9f2436
commit 3dca699410

@ -107,6 +107,7 @@ func (s *Storage) ListFilterAny(filters ...FilterFunc) ([]*rspb.Release, error)
// Init initializes a new storage backend with the driver d. // Init initializes a new storage backend with the driver d.
// If d is nil, the default in-memory driver is used. // If d is nil, the default in-memory driver is used.
func Init(d driver.Driver) *Storage { func Init(d driver.Driver) *Storage {
// default driver is in memory
if d == nil { if d == nil {
d = driver.NewMemory() d = driver.NewMemory()
} }

@ -25,9 +25,10 @@ import (
"k8s.io/helm/pkg/storage/driver" "k8s.io/helm/pkg/storage/driver"
) )
var storage = Init(driver.NewMemory())
func TestStorageCreate(t *testing.T) { func TestStorageCreate(t *testing.T) {
// initialize storage
storage := Init(driver.NewMemory())
// create fake release // create fake release
rls := ReleaseTestData{Name: "angry-beaver"}.ToRelease() rls := ReleaseTestData{Name: "angry-beaver"}.ToRelease()
assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease") assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease")
@ -43,6 +44,9 @@ func TestStorageCreate(t *testing.T) {
} }
func TestStorageUpdate(t *testing.T) { func TestStorageUpdate(t *testing.T) {
// initialize storage
storage := Init(driver.NewMemory())
// create fake release // create fake release
rls := ReleaseTestData{Name: "angry-beaver"}.ToRelease() rls := ReleaseTestData{Name: "angry-beaver"}.ToRelease()
assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease") assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease")
@ -63,6 +67,9 @@ func TestStorageUpdate(t *testing.T) {
} }
func TestStorageDelete(t *testing.T) { func TestStorageDelete(t *testing.T) {
// initialize storage
storage := Init(driver.NewMemory())
// create fake release // create fake release
rls := ReleaseTestData{Name: "angry-beaver"}.ToRelease() rls := ReleaseTestData{Name: "angry-beaver"}.ToRelease()
assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease") assertErrNil(t.Fatal, storage.Create(rls), "StoreRelease")
@ -78,6 +85,9 @@ func TestStorageDelete(t *testing.T) {
} }
func TestStorageList(t *testing.T) { func TestStorageList(t *testing.T) {
// initialize storage
storage := Init(driver.NewMemory())
// setup storage with test releases // setup storage with test releases
setup := func() { setup := func() {
// release records // release records

Loading…
Cancel
Save