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,
},
}
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)
})
}

@ -39,7 +39,7 @@ func TestGetHooks(t *testing.T) {
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)
})
}

@ -39,7 +39,7 @@ func TestGetManifest(t *testing.T) {
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)
})
}

@ -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)
}
runReleaseCases(t, tests, cmd)

@ -38,7 +38,7 @@ func TestGetValuesCmd(t *testing.T) {
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)
}
runReleaseCases(t, tests, cmd)

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

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

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

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

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

@ -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)
}
var buf bytes.Buffer
for _, tt := range tests {
c := &helm.FakeReleaseClient{
c := &helm.FakeClient{
Rels: []*release.Release{tt.rel},
}
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)
}

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

@ -26,18 +26,18 @@ import (
"k8s.io/helm/pkg/proto/hapi/version"
)
// FakeReleaseClient implements Interface
type FakeReleaseClient struct {
// FakeClient implements Interface
type FakeClient struct {
Rels []*release.Release
Responses map[string]release.TestRun_Status
Err error
}
var _ Interface = &FakeReleaseClient{}
var _ Interface = (*FakeReleaseClient)(nil)
var _ Interface = &FakeClient{}
var _ Interface = (*FakeClient)(nil)
// Listreleases lists the current releases
func (c *FakeReleaseClient) ListReleases(opts ...ReleaseListOption) (*rls.ListReleasesResponse, error) {
// ListReleases lists the current releases
func (c *FakeClient) ListReleases(opts ...ReleaseListOption) (*rls.ListReleasesResponse, error) {
resp := &rls.ListReleasesResponse{
Count: int64(len(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
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{
Release: c.Rels[0],
}, nil
}
// 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{
Release: c.Rels[0],
}, 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
}
// 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
}
// 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{
Version: &version.Version{
SemVer: "1.2.3-fakeclient+testonly",
@ -79,18 +79,18 @@ func (c *FakeReleaseClient) GetVersion(opts ...VersionOption) (*rls.GetVersionRe
}
// 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
}
// 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
}
// ReleaseStatus returns a release status response with info from the first release in the fake
// 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 {
return &rls.GetReleaseStatusResponse{
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
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 {
resp = &rls.GetReleaseContentResponse{
Release: c.Rels[0],
@ -112,12 +112,12 @@ func (c *FakeReleaseClient) ReleaseContent(rlsName string, opts ...ContentOption
}
// 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
}
// 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)
errc := make(chan error, 1)
@ -142,6 +142,6 @@ func (c *FakeReleaseClient) RunReleaseTest(rlsName string, opts ...ReleaseTestOp
}
// Option returns the fake release client
func (c *FakeReleaseClient) Option(opt ...Option) Interface {
func (c *FakeClient) Option(opt ...Option) Interface {
return c
}

Loading…
Cancel
Save