From 1d04646c857ba01d9bdda85ef7a804c462a91456 Mon Sep 17 00:00:00 2001 From: fibonacci1729 Date: Mon, 8 Aug 2016 14:12:58 -0600 Subject: [PATCH] update failing tests to use new storage / driver apis --- cmd/tiller/environment/environment_test.go | 15 +++++++++------ cmd/tiller/release_server_test.go | 3 ++- cmd/tiller/tiller_test.go | 2 -- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/cmd/tiller/environment/environment_test.go b/cmd/tiller/environment/environment_test.go index cfcbc8ca4..04b1585e5 100644 --- a/cmd/tiller/environment/environment_test.go +++ b/cmd/tiller/environment/environment_test.go @@ -22,6 +22,8 @@ import ( "testing" "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/release" ) @@ -38,12 +40,14 @@ type mockReleaseStorage struct { rel *release.Release } +var _ driver.Driver = (*mockReleaseStorage)(nil) + func (r *mockReleaseStorage) Create(v *release.Release) error { r.rel = v return nil } -func (r *mockReleaseStorage) Read(k string) (*release.Release, error) { +func (r *mockReleaseStorage) Get(k string) (*release.Release, error) { return r.rel, nil } @@ -56,7 +60,7 @@ func (r *mockReleaseStorage) Delete(k string) (*release.Release, error) { 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 } @@ -66,7 +70,7 @@ func (r *mockReleaseStorage) Query(labels map[string]string) ([]*release.Release func (r *mockReleaseStorage) History(n string) ([]*release.Release, error) { res := []*release.Release{} - rel, err := r.Read(n) + rel, err := r.Get(n) if err != nil { return res, err } @@ -88,7 +92,6 @@ func (k *mockKubeClient) WatchUntilReady(ns string, r io.Reader) error { } var _ Engine = &mockEngine{} -var _ ReleaseStorage = &mockReleaseStorage{} var _ KubeClient = &mockKubeClient{} var _ KubeClient = &PrintingKubeClient{} @@ -110,7 +113,7 @@ func TestEngine(t *testing.T) { func TestReleaseStorage(t *testing.T) { rs := &mockReleaseStorage{} env := New() - env.Releases = rs + env.Releases = storage.Init(rs) release := &release.Release{Name: "mariner"} @@ -122,7 +125,7 @@ func TestReleaseStorage(t *testing.T) { 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) } else if v.Name != "mariner" { t.Errorf("Expected mariner, got %q", v.Name) diff --git a/cmd/tiller/release_server_test.go b/cmd/tiller/release_server_test.go index d60856698..ffd0daa7c 100644 --- a/cmd/tiller/release_server_test.go +++ b/cmd/tiller/release_server_test.go @@ -31,6 +31,7 @@ import ( "k8s.io/helm/pkg/proto/hapi/chart" "k8s.io/helm/pkg/proto/hapi/release" "k8s.io/helm/pkg/proto/hapi/services" + "k8s.io/helm/pkg/storage/driver" "k8s.io/helm/pkg/storage" ) @@ -487,7 +488,7 @@ func TestListReleasesFilter(t *testing.T) { func mockEnvironment() *environment.Environment { e := environment.New() - e.Releases = storage.NewMemory() + e.Releases = storage.Init(driver.NewMemory()) e.KubeClient = &environment.PrintingKubeClient{Out: os.Stdout} return e } diff --git a/cmd/tiller/tiller_test.go b/cmd/tiller/tiller_test.go index 23a36ff2d..0618074d1 100644 --- a/cmd/tiller/tiller_test.go +++ b/cmd/tiller/tiller_test.go @@ -21,13 +21,11 @@ import ( "k8s.io/helm/cmd/tiller/environment" "k8s.io/helm/pkg/engine" - "k8s.io/helm/pkg/storage" ) // These are canary tests to make sure that the default server actually // fulfills its requirements. var _ environment.Engine = &engine.Engine{} -var _ environment.ReleaseStorage = storage.NewMemory() func TestInit(t *testing.T) { defer func() {