ref(helm): rename FakeReleaseClient -> FakeClient

pull/2550/head
Michelle Noorali 8 years ago committed by Michelle Noorali
parent 70520efac4
commit 8a99a4aa6f

@ -62,7 +62,7 @@ func TestDelete(t *testing.T) {
err: true, err: true,
}, },
} }
runReleaseCases(t, tests, func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newDeleteCmd(c, out) return newDeleteCmd(c, out)
}) })
} }

@ -39,7 +39,7 @@ func TestGetHooks(t *testing.T) {
err: true, err: true,
}, },
} }
runReleaseCases(t, tests, func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newGetHooksCmd(c, out) return newGetHooksCmd(c, out)
}) })
} }

@ -39,7 +39,7 @@ func TestGetManifest(t *testing.T) {
err: true, err: true,
}, },
} }
runReleaseCases(t, tests, func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newGetManifestCmd(c, out) return newGetManifestCmd(c, out)
}) })
} }

@ -39,7 +39,7 @@ func TestGetCmd(t *testing.T) {
}, },
} }
cmd := func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { cmd := func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newGetCmd(c, out) return newGetCmd(c, out)
} }
runReleaseCases(t, tests, cmd) runReleaseCases(t, tests, cmd)

@ -38,7 +38,7 @@ func TestGetValuesCmd(t *testing.T) {
err: true, err: true,
}, },
} }
cmd := func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { cmd := func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newGetValuesCmd(c, out) return newGetValuesCmd(c, out)
} }
runReleaseCases(t, tests, cmd) runReleaseCases(t, tests, cmd)

@ -120,14 +120,14 @@ func releaseMock(opts *releaseOptions) *release.Release {
} }
} }
// releaseCmd is a command that works with a FakeReleaseClient // releaseCmd is a command that works with a FakeClient
type releaseCmd func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command type releaseCmd func(c *helm.FakeClient, out io.Writer) *cobra.Command
// runReleaseCases runs a set of release cases through the given releaseCmd. // runReleaseCases runs a set of release cases through the given releaseCmd.
func runReleaseCases(t *testing.T, tests []releaseCase, rcmd releaseCmd) { func runReleaseCases(t *testing.T, tests []releaseCase, rcmd releaseCmd) {
var buf bytes.Buffer var buf bytes.Buffer
for _, tt := range tests { for _, tt := range tests {
c := &helm.FakeReleaseClient{ c := &helm.FakeClient{
Rels: []*release.Release{tt.resp}, Rels: []*release.Release{tt.resp},
} }
cmd := rcmd(c, &buf) cmd := rcmd(c, &buf)

@ -67,7 +67,7 @@ func TestHistoryCmd(t *testing.T) {
var buf bytes.Buffer var buf bytes.Buffer
for _, tt := range tests { for _, tt := range tests {
frc := &helm.FakeReleaseClient{Rels: tt.resp} frc := &helm.FakeClient{Rels: tt.resp}
cmd := newHistoryCmd(frc, &buf) cmd := newHistoryCmd(frc, &buf)
cmd.ParseFlags(tt.args) cmd.ParseFlags(tt.args)

@ -148,7 +148,7 @@ func TestInstall(t *testing.T) {
}, },
} }
runReleaseCases(t, tests, func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { runReleaseCases(t, tests, func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newInstallCmd(c, out) return newInstallCmd(c, out)
}) })
} }

@ -102,7 +102,7 @@ func TestListCmd(t *testing.T) {
var buf bytes.Buffer var buf bytes.Buffer
for _, tt := range tests { for _, tt := range tests {
c := &helm.FakeReleaseClient{ c := &helm.FakeClient{
Rels: tt.resp, Rels: tt.resp,
} }
cmd := newListCmd(c, &buf) cmd := newListCmd(c, &buf)

@ -83,7 +83,7 @@ func TestReleaseTesting(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
c := &helm.FakeReleaseClient{Responses: tt.responses} c := &helm.FakeClient{Responses: tt.responses}
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
cmd := newReleaseTestCmd(c, buf) cmd := newReleaseTestCmd(c, buf)

@ -39,7 +39,7 @@ func TestResetCmd(t *testing.T) {
defer os.Remove(home) defer os.Remove(home)
var buf bytes.Buffer var buf bytes.Buffer
c := &helm.FakeReleaseClient{} c := &helm.FakeClient{}
fc := fake.NewSimpleClientset() fc := fake.NewSimpleClientset()
cmd := &resetCmd{ cmd := &resetCmd{
out: &buf, out: &buf,
@ -72,7 +72,7 @@ func TestResetCmd_removeHelmHome(t *testing.T) {
defer os.Remove(home) defer os.Remove(home)
var buf bytes.Buffer var buf bytes.Buffer
c := &helm.FakeReleaseClient{} c := &helm.FakeClient{}
fc := fake.NewSimpleClientset() fc := fake.NewSimpleClientset()
cmd := &resetCmd{ cmd := &resetCmd{
removeHelmHome: true, removeHelmHome: true,
@ -109,7 +109,7 @@ func TestReset_deployedReleases(t *testing.T) {
resp := []*release.Release{ resp := []*release.Release{
releaseMock(&releaseOptions{name: "atlas-guide", statusCode: release.Status_DEPLOYED}), releaseMock(&releaseOptions{name: "atlas-guide", statusCode: release.Status_DEPLOYED}),
} }
c := &helm.FakeReleaseClient{ c := &helm.FakeClient{
Rels: resp, Rels: resp,
} }
fc := fake.NewSimpleClientset() fc := fake.NewSimpleClientset()
@ -141,7 +141,7 @@ func TestReset_forceFlag(t *testing.T) {
resp := []*release.Release{ resp := []*release.Release{
releaseMock(&releaseOptions{name: "atlas-guide", statusCode: release.Status_DEPLOYED}), releaseMock(&releaseOptions{name: "atlas-guide", statusCode: release.Status_DEPLOYED}),
} }
c := &helm.FakeReleaseClient{ c := &helm.FakeClient{
Rels: resp, Rels: resp,
} }
fc := fake.NewSimpleClientset() fc := fake.NewSimpleClientset()

@ -52,7 +52,7 @@ func TestRollbackCmd(t *testing.T) {
}, },
} }
cmd := func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { cmd := func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newRollbackCmd(c, out) return newRollbackCmd(c, out)
} }

@ -107,13 +107,13 @@ func TestStatusCmd(t *testing.T) {
}, },
} }
scmd := func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { scmd := func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newStatusCmd(c, out) return newStatusCmd(c, out)
} }
var buf bytes.Buffer var buf bytes.Buffer
for _, tt := range tests { for _, tt := range tests {
c := &helm.FakeReleaseClient{ c := &helm.FakeClient{
Rels: []*release.Release{tt.rel}, Rels: []*release.Release{tt.rel},
} }
cmd := scmd(c, &buf) cmd := scmd(c, &buf)

@ -153,7 +153,7 @@ func TestUpgradeCmd(t *testing.T) {
}, },
} }
cmd := func(c *helm.FakeReleaseClient, out io.Writer) *cobra.Command { cmd := func(c *helm.FakeClient, out io.Writer) *cobra.Command {
return newUpgradeCmd(c, out) return newUpgradeCmd(c, out)
} }

@ -43,7 +43,7 @@ func TestVersion(t *testing.T) {
settings.TillerHost = "fake-localhost" settings.TillerHost = "fake-localhost"
for _, tt := range tests { for _, tt := range tests {
b := new(bytes.Buffer) b := new(bytes.Buffer)
c := &helm.FakeReleaseClient{} c := &helm.FakeClient{}
cmd := newVersionCmd(c, b) cmd := newVersionCmd(c, b)
cmd.ParseFlags(tt.args) cmd.ParseFlags(tt.args)

@ -26,18 +26,18 @@ import (
"k8s.io/helm/pkg/proto/hapi/version" "k8s.io/helm/pkg/proto/hapi/version"
) )
// FakeReleaseClient implements Interface // FakeClient implements Interface
type FakeReleaseClient struct { type FakeClient struct {
Rels []*release.Release Rels []*release.Release
Responses map[string]release.TestRun_Status Responses map[string]release.TestRun_Status
Err error Err error
} }
var _ Interface = &FakeReleaseClient{} var _ Interface = &FakeClient{}
var _ Interface = (*FakeReleaseClient)(nil) var _ Interface = (*FakeClient)(nil)
// Listreleases lists the current releases // ListReleases lists the current releases
func (c *FakeReleaseClient) ListReleases(opts ...ReleaseListOption) (*rls.ListReleasesResponse, error) { func (c *FakeClient) ListReleases(opts ...ReleaseListOption) (*rls.ListReleasesResponse, error) {
resp := &rls.ListReleasesResponse{ resp := &rls.ListReleasesResponse{
Count: int64(len(c.Rels)), Count: int64(len(c.Rels)),
Releases: c.Rels, Releases: c.Rels,
@ -46,31 +46,31 @@ func (c *FakeReleaseClient) ListReleases(opts ...ReleaseListOption) (*rls.ListRe
} }
// InstallRelease returns a response with the first Release on the fake release client // InstallRelease returns a response with the first Release on the fake release client
func (c *FakeReleaseClient) InstallRelease(chStr, ns string, opts ...InstallOption) (*rls.InstallReleaseResponse, error) { func (c *FakeClient) InstallRelease(chStr, ns string, opts ...InstallOption) (*rls.InstallReleaseResponse, error) {
return &rls.InstallReleaseResponse{ return &rls.InstallReleaseResponse{
Release: c.Rels[0], Release: c.Rels[0],
}, nil }, nil
} }
// InstallReleaseFromChart returns a response with the first Release on the fake release client // InstallReleaseFromChart returns a response with the first Release on the fake release client
func (c *FakeReleaseClient) InstallReleaseFromChart(chart *chart.Chart, ns string, opts ...InstallOption) (*rls.InstallReleaseResponse, error) { func (c *FakeClient) InstallReleaseFromChart(chart *chart.Chart, ns string, opts ...InstallOption) (*rls.InstallReleaseResponse, error) {
return &rls.InstallReleaseResponse{ return &rls.InstallReleaseResponse{
Release: c.Rels[0], Release: c.Rels[0],
}, nil }, nil
} }
// DeleteRelease returns nil, nil // DeleteRelease returns nil, nil
func (c *FakeReleaseClient) DeleteRelease(rlsName string, opts ...DeleteOption) (*rls.UninstallReleaseResponse, error) { func (c *FakeClient) DeleteRelease(rlsName string, opts ...DeleteOption) (*rls.UninstallReleaseResponse, error) {
return nil, nil return nil, nil
} }
// UpdateRelease returns nil, nil // UpdateRelease returns nil, nil
func (c *FakeReleaseClient) UpdateRelease(rlsName string, chStr string, opts ...UpdateOption) (*rls.UpdateReleaseResponse, error) { func (c *FakeClient) UpdateRelease(rlsName string, chStr string, opts ...UpdateOption) (*rls.UpdateReleaseResponse, error) {
return nil, nil return nil, nil
} }
// GetVersion returns a fake version // GetVersion returns a fake version
func (c *FakeReleaseClient) GetVersion(opts ...VersionOption) (*rls.GetVersionResponse, error) { func (c *FakeClient) GetVersion(opts ...VersionOption) (*rls.GetVersionResponse, error) {
return &rls.GetVersionResponse{ return &rls.GetVersionResponse{
Version: &version.Version{ Version: &version.Version{
SemVer: "1.2.3-fakeclient+testonly", SemVer: "1.2.3-fakeclient+testonly",
@ -79,18 +79,18 @@ func (c *FakeReleaseClient) GetVersion(opts ...VersionOption) (*rls.GetVersionRe
} }
// UpdateReleaseFromChart returns nil, nil // UpdateReleaseFromChart returns nil, nil
func (c *FakeReleaseClient) UpdateReleaseFromChart(rlsName string, chart *chart.Chart, opts ...UpdateOption) (*rls.UpdateReleaseResponse, error) { func (c *FakeClient) UpdateReleaseFromChart(rlsName string, chart *chart.Chart, opts ...UpdateOption) (*rls.UpdateReleaseResponse, error) {
return nil, nil return nil, nil
} }
// RollbackRelease returns nil, nil // RollbackRelease returns nil, nil
func (c *FakeReleaseClient) RollbackRelease(rlsName string, opts ...RollbackOption) (*rls.RollbackReleaseResponse, error) { func (c *FakeClient) RollbackRelease(rlsName string, opts ...RollbackOption) (*rls.RollbackReleaseResponse, error) {
return nil, nil return nil, nil
} }
// ReleaseStatus returns a release status response with info from the first release in the fake // ReleaseStatus returns a release status response with info from the first release in the fake
// release client // release client
func (c *FakeReleaseClient) ReleaseStatus(rlsName string, opts ...StatusOption) (*rls.GetReleaseStatusResponse, error) { func (c *FakeClient) ReleaseStatus(rlsName string, opts ...StatusOption) (*rls.GetReleaseStatusResponse, error) {
if c.Rels[0] != nil { if c.Rels[0] != nil {
return &rls.GetReleaseStatusResponse{ return &rls.GetReleaseStatusResponse{
Name: c.Rels[0].Name, Name: c.Rels[0].Name,
@ -102,7 +102,7 @@ func (c *FakeReleaseClient) ReleaseStatus(rlsName string, opts ...StatusOption)
} }
// ReleaseContent returns the configuration for the first release in the fake release client // ReleaseContent returns the configuration for the first release in the fake release client
func (c *FakeReleaseClient) ReleaseContent(rlsName string, opts ...ContentOption) (resp *rls.GetReleaseContentResponse, err error) { func (c *FakeClient) ReleaseContent(rlsName string, opts ...ContentOption) (resp *rls.GetReleaseContentResponse, err error) {
if len(c.Rels) > 0 { if len(c.Rels) > 0 {
resp = &rls.GetReleaseContentResponse{ resp = &rls.GetReleaseContentResponse{
Release: c.Rels[0], Release: c.Rels[0],
@ -112,12 +112,12 @@ func (c *FakeReleaseClient) ReleaseContent(rlsName string, opts ...ContentOption
} }
// ReleaseHistory returns a release's revision history. // ReleaseHistory returns a release's revision history.
func (c *FakeReleaseClient) ReleaseHistory(rlsName string, opts ...HistoryOption) (*rls.GetHistoryResponse, error) { func (c *FakeClient) ReleaseHistory(rlsName string, opts ...HistoryOption) (*rls.GetHistoryResponse, error) {
return &rls.GetHistoryResponse{Releases: c.Rels}, c.Err return &rls.GetHistoryResponse{Releases: c.Rels}, c.Err
} }
// RunReleaseTest executes a pre-defined tests on a release // RunReleaseTest executes a pre-defined tests on a release
func (c *FakeReleaseClient) RunReleaseTest(rlsName string, opts ...ReleaseTestOption) (<-chan *rls.TestReleaseResponse, <-chan error) { func (c *FakeClient) RunReleaseTest(rlsName string, opts ...ReleaseTestOption) (<-chan *rls.TestReleaseResponse, <-chan error) {
results := make(chan *rls.TestReleaseResponse) results := make(chan *rls.TestReleaseResponse)
errc := make(chan error, 1) errc := make(chan error, 1)
@ -142,6 +142,6 @@ func (c *FakeReleaseClient) RunReleaseTest(rlsName string, opts ...ReleaseTestOp
} }
// Option returns the fake release client // Option returns the fake release client
func (c *FakeReleaseClient) Option(opt ...Option) Interface { func (c *FakeClient) Option(opt ...Option) Interface {
return c return c
} }

Loading…
Cancel
Save