Commit 1d04646c authored by fibonacci1729's avatar fibonacci1729

update failing tests to use new storage / driver apis

parent cba0c661
...@@ -22,6 +22,8 @@ import ( ...@@ -22,6 +22,8 @@ import (
"testing" "testing"
"k8s.io/helm/pkg/chartutil" "k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/storage"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/proto/hapi/release"
) )
...@@ -38,12 +40,14 @@ type mockReleaseStorage struct { ...@@ -38,12 +40,14 @@ type mockReleaseStorage struct {
rel *release.Release rel *release.Release
} }
var _ driver.Driver = (*mockReleaseStorage)(nil)
func (r *mockReleaseStorage) Create(v *release.Release) error { func (r *mockReleaseStorage) Create(v *release.Release) error {
r.rel = v r.rel = v
return nil return nil
} }
func (r *mockReleaseStorage) Read(k string) (*release.Release, error) { func (r *mockReleaseStorage) Get(k string) (*release.Release, error) {
return r.rel, nil return r.rel, nil
} }
...@@ -56,7 +60,7 @@ func (r *mockReleaseStorage) Delete(k string) (*release.Release, error) { ...@@ -56,7 +60,7 @@ func (r *mockReleaseStorage) Delete(k string) (*release.Release, error) {
return r.rel, nil return r.rel, nil
} }
func (r *mockReleaseStorage) List() ([]*release.Release, error) { func (r *mockReleaseStorage) List(func(*release.Release) bool) ([]*release.Release, error) {
return []*release.Release{}, nil return []*release.Release{}, nil
} }
...@@ -66,7 +70,7 @@ func (r *mockReleaseStorage) Query(labels map[string]string) ([]*release.Release ...@@ -66,7 +70,7 @@ func (r *mockReleaseStorage) Query(labels map[string]string) ([]*release.Release
func (r *mockReleaseStorage) History(n string) ([]*release.Release, error) { func (r *mockReleaseStorage) History(n string) ([]*release.Release, error) {
res := []*release.Release{} res := []*release.Release{}
rel, err := r.Read(n) rel, err := r.Get(n)
if err != nil { if err != nil {
return res, err return res, err
} }
...@@ -88,7 +92,6 @@ func (k *mockKubeClient) WatchUntilReady(ns string, r io.Reader) error { ...@@ -88,7 +92,6 @@ func (k *mockKubeClient) WatchUntilReady(ns string, r io.Reader) error {
} }
var _ Engine = &mockEngine{} var _ Engine = &mockEngine{}
var _ ReleaseStorage = &mockReleaseStorage{}
var _ KubeClient = &mockKubeClient{} var _ KubeClient = &mockKubeClient{}
var _ KubeClient = &PrintingKubeClient{} var _ KubeClient = &PrintingKubeClient{}
...@@ -110,7 +113,7 @@ func TestEngine(t *testing.T) { ...@@ -110,7 +113,7 @@ func TestEngine(t *testing.T) {
func TestReleaseStorage(t *testing.T) { func TestReleaseStorage(t *testing.T) {
rs := &mockReleaseStorage{} rs := &mockReleaseStorage{}
env := New() env := New()
env.Releases = rs env.Releases = storage.Init(rs)
release := &release.Release{Name: "mariner"} release := &release.Release{Name: "mariner"}
...@@ -122,7 +125,7 @@ func TestReleaseStorage(t *testing.T) { ...@@ -122,7 +125,7 @@ func TestReleaseStorage(t *testing.T) {
t.Fatalf("failed to update release: %s", err) t.Fatalf("failed to update release: %s", err)
} }
if v, err := env.Releases.Read("albatross"); err != nil { if v, err := env.Releases.Get("albatross"); err != nil {
t.Errorf("Error fetching release: %s", err) t.Errorf("Error fetching release: %s", err)
} else if v.Name != "mariner" { } else if v.Name != "mariner" {
t.Errorf("Expected mariner, got %q", v.Name) t.Errorf("Expected mariner, got %q", v.Name)
......
...@@ -31,6 +31,7 @@ import ( ...@@ -31,6 +31,7 @@ import (
"k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/chart"
"k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/proto/hapi/release"
"k8s.io/helm/pkg/proto/hapi/services" "k8s.io/helm/pkg/proto/hapi/services"
"k8s.io/helm/pkg/storage/driver"
"k8s.io/helm/pkg/storage" "k8s.io/helm/pkg/storage"
) )
...@@ -487,7 +488,7 @@ func TestListReleasesFilter(t *testing.T) { ...@@ -487,7 +488,7 @@ func TestListReleasesFilter(t *testing.T) {
func mockEnvironment() *environment.Environment { func mockEnvironment() *environment.Environment {
e := environment.New() e := environment.New()
e.Releases = storage.NewMemory() e.Releases = storage.Init(driver.NewMemory())
e.KubeClient = &environment.PrintingKubeClient{Out: os.Stdout} e.KubeClient = &environment.PrintingKubeClient{Out: os.Stdout}
return e return e
} }
......
...@@ -21,13 +21,11 @@ import ( ...@@ -21,13 +21,11 @@ import (
"k8s.io/helm/cmd/tiller/environment" "k8s.io/helm/cmd/tiller/environment"
"k8s.io/helm/pkg/engine" "k8s.io/helm/pkg/engine"
"k8s.io/helm/pkg/storage"
) )
// These are canary tests to make sure that the default server actually // These are canary tests to make sure that the default server actually
// fulfills its requirements. // fulfills its requirements.
var _ environment.Engine = &engine.Engine{} var _ environment.Engine = &engine.Engine{}
var _ environment.ReleaseStorage = storage.NewMemory()
func TestInit(t *testing.T) { func TestInit(t *testing.T) {
defer func() { defer func() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment