From d4e14beb57880f493438849b97d6ca92090333fb Mon Sep 17 00:00:00 2001 From: Gowtham Munukutla Date: Wed, 24 Feb 2021 10:14:31 +0530 Subject: [PATCH] remove unwanted tests and unwanted functionality --- pkg/cmd/gist/edit/edit.go | 8 ----- pkg/cmd/gist/edit/edit_test.go | 53 ++-------------------------------- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/pkg/cmd/gist/edit/edit.go b/pkg/cmd/gist/edit/edit.go index 65f91732f..3bea3757b 100644 --- a/pkg/cmd/gist/edit/edit.go +++ b/pkg/cmd/gist/edit/edit.go @@ -29,7 +29,6 @@ type EditOptions struct { Config func() (config.Config, error) Edit func(string, string, string, *iostreams.IOStreams) (string, error) - Add func(string, string, *iostreams.IOStreams) (string, error) Selector string EditFilename string AddFilename string @@ -47,13 +46,6 @@ func NewCmdEdit(f *cmdutil.Factory, runF func(*EditOptions) error) *cobra.Comman defaultContent, io.In, io.Out, io.ErrOut, nil) }, - Add: func(editorCmd, filename string, io *iostreams.IOStreams) (string, error) { - return surveyext.Edit( - editorCmd, - "*."+filename, - "", - io.In, io.Out, io.ErrOut, nil) - }, } cmd := &cobra.Command{ diff --git a/pkg/cmd/gist/edit/edit_test.go b/pkg/cmd/gist/edit/edit_test.go index c1b411a47..1b5ac25b4 100644 --- a/pkg/cmd/gist/edit/edit_test.go +++ b/pkg/cmd/gist/edit/edit_test.go @@ -19,7 +19,7 @@ import ( ) const ( - fixtureFile = "../fixture.txt" + fixtureFile = "../fixture.txt" ) func Test_getFilesToAdd(t *testing.T) { @@ -243,7 +243,7 @@ func Test_editRun(t *testing.T) { wantStderr: "You do not own this gist.", }, { - name: "add file to existing gist with absolute path", + name: "add file to existing gist", gist: &shared.Gist{ ID: "1234", Files: map[string]*shared.GistFile{ @@ -260,50 +260,7 @@ func Test_editRun(t *testing.T) { httpmock.StatusStringResponse(201, "{}")) }, opts: &EditOptions{ - AddFilename: "/Users/octocat/foo.txt", - }, - wantParams: map[string]interface{}{ - "description": "", - "updated_at": "0001-01-01T00:00:00Z", - "public": false, - "files": map[string]interface{}{ - "foo.txt": map[string]interface{}{ - "content": "new content to existing gist", - "filename": "foo.txt", - }, - }, - }, - }, - { - name: "add file to existing gist with relative path", - gist: &shared.Gist{ - ID: "1234", - Files: map[string]*shared.GistFile{ - "sample.txt": { - Filename: "sample.txt", - Content: "bwhiizzzbwhuiiizzzz", - Type: "text/plain", - }, - }, - Owner: &shared.GistOwner{Login: "octocat"}, - }, - httpStubs: func(reg *httpmock.Registry) { - reg.Register(httpmock.REST("POST", "gists/1234"), - httpmock.StatusStringResponse(201, "{}")) - }, - opts: &EditOptions{ - AddFilename: "../foo.txt", - }, - wantParams: map[string]interface{}{ - "description": "", - "updated_at": "0001-01-01T00:00:00Z", - "public": false, - "files": map[string]interface{}{ - "foo.txt": map[string]interface{}{ - "content": "new content to existing gist", - "filename": "foo.txt", - }, - }, + AddFilename: "../fixture.txt", }, }, } @@ -338,10 +295,6 @@ func Test_editRun(t *testing.T) { return "new file content", nil } - tt.opts.Add = func(_, _ string, _ *iostreams.IOStreams) (string, error) { - return "new content to existing gist", nil - } - tt.opts.HttpClient = func() (*http.Client, error) { return &http.Client{Transport: reg}, nil }