feat: Add support for deleting autolink references by hoffm · Pull Request #10362 · cli/cli · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/cmd/repo/autolink/autolink.go
2 changes: 1 addition & 1 deletion pkg/cmd/repo/autolink/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func createRun(opts *createOptions) error {
"%s Created repository autolink %s on %s\n",
cs.SuccessIconWithColor(cs.Green),
cs.Cyanf("%d", autolink.ID),
ghrepo.FullName(repo))
cs.Bold(ghrepo.FullName(repo)))

return nil
}
12 changes: 6 additions & 6 deletions pkg/cmd/repo/autolink/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ func TestNewCmdCreate(t *testing.T) {
}
}

type stubAutoLinkCreator struct {
type stubAutolinkCreator struct {
err error
}

func (g stubAutoLinkCreator) Create(repo ghrepo.Interface, request AutolinkCreateRequest) (*shared.Autolink, error) {
func (g stubAutolinkCreator) Create(repo ghrepo.Interface, request AutolinkCreateRequest) (*shared.Autolink, error) {
if g.err != nil {
return nil, g.err
}
Expand All @@ -119,7 +119,7 @@ func TestCreateRun(t *testing.T) {
tests := []struct {
name string
opts *createOptions
stubCreator stubAutoLinkCreator
stubCreator stubAutolinkCreator
expectedErr error
errMsg string
wantStdout string
Expand All @@ -131,7 +131,7 @@ func TestCreateRun(t *testing.T) {
KeyPrefix: "TICKET-",
URLTemplate: "https://example.com/TICKET?query=<num>",
},
stubCreator: stubAutoLinkCreator{},
stubCreator: stubAutolinkCreator{},
wantStdout: "✓ Created repository autolink 1 on OWNER/REPO\n",
},
{
Expand All @@ -141,7 +141,7 @@ func TestCreateRun(t *testing.T) {
URLTemplate: "https://example.com/TICKET?query=<num>",
Numeric: true,
},
stubCreator: stubAutoLinkCreator{},
stubCreator: stubAutolinkCreator{},
wantStdout: "✓ Created repository autolink 1 on OWNER/REPO\n",
},
{
Expand All @@ -150,7 +150,7 @@ func TestCreateRun(t *testing.T) {
KeyPrefix: "TICKET-",
URLTemplate: "https://example.com/TICKET?query=<num>",
},
stubCreator: stubAutoLinkCreator{err: testAutolinkClientCreateError{}},
stubCreator: stubAutolinkCreator{err: testAutolinkClientCreateError{}},
expectedErr: testAutolinkClientCreateError{},
errMsg: fmt.Sprint("error creating autolink: ", testAutolinkClientCreateError{}.Error()),
},
Expand Down
4 changes: 0 additions & 4 deletions pkg/cmd/repo/autolink/create/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ func (a *AutolinkCreator) Create(repo ghrepo.Interface, request AutolinkCreateRe

defer resp.Body.Close()

// if resp.StatusCode != http.StatusCreated {
// return nil, api.HandleHTTPError(resp)
// }

err = handleAutolinkCreateError(resp)

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/repo/autolink/create/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/stretchr/testify/require"
)

func TestAutoLinkCreator_Create(t *testing.T) {
func TestAutolinkCreator_Create(t *testing.T) {
repo := ghrepo.New("OWNER", "REPO")

tests := []struct {
Expand Down
107 changes: 107 additions & 0 deletions pkg/cmd/repo/autolink/delete/delete.go
Loading