Skip to content

Commit

Permalink
chore: Rename command option
Browse files Browse the repository at this point in the history
  • Loading branch information
almas1992 committed Dec 26, 2024
1 parent 7d15029 commit b9d6717
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions database/console/table_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func (r *TableCommand) Extend() command.Extend {
ArgsUsage: " [--] [<table>]",
Flags: []command.Flag{
&command.StringFlag{
Name: "database",
Usage: "The database connection",
Name: "connection",
Usage: "The database connection",
Aliases: []string{"c"},
},
},
}

Check warning on line 47 in database/console/table_command.go

View check run for this annotation

Codecov / codecov/patch

database/console/table_command.go#L36-L47

Added lines #L36 - L47 were not covered by tests
Expand All @@ -49,7 +50,7 @@ func (r *TableCommand) Extend() command.Extend {
// Handle Execute the console command.
func (r *TableCommand) Handle(ctx console.Context) error {
ctx.NewLine()
r.schema = r.schema.Connection(ctx.Option("database"))
r.schema = r.schema.Connection(ctx.Option("connection"))
table := ctx.Argument(0)
tables, err := r.schema.GetTables()
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions database/console/table_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestTableCommand(t *testing.T) {
name: "get tables failed",
setup: func() {
mockContext.EXPECT().NewLine().Once()
mockContext.EXPECT().Option("database").Return("").Once()
mockContext.EXPECT().Option("connection").Return("").Once()
mockSchema.EXPECT().Connection("").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("").Once()
mockSchema.EXPECT().GetTables().Return(nil, assert.AnError).Once()
Expand All @@ -60,7 +60,7 @@ func TestTableCommand(t *testing.T) {
name: "table not found",
setup: func() {
mockContext.EXPECT().NewLine().Times(2)
mockContext.EXPECT().Option("database").Return("test").Once()
mockContext.EXPECT().Option("connection").Return("test").Once()
mockSchema.EXPECT().Connection("test").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("test").Once()
mockSchema.EXPECT().GetTables().Return(nil, nil).Once()
Expand All @@ -74,7 +74,7 @@ func TestTableCommand(t *testing.T) {
name: "choice table canceled",
setup: func() {
mockContext.EXPECT().NewLine().Times(1)
mockContext.EXPECT().Option("database").Return("test").Once()
mockContext.EXPECT().Option("connection").Return("test").Once()
mockSchema.EXPECT().Connection("test").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("").Once()
mockSchema.EXPECT().GetTables().Return(nil, nil).Once()
Expand All @@ -90,7 +90,7 @@ func TestTableCommand(t *testing.T) {
name: "get columns failed",
setup: func() {
mockContext.EXPECT().NewLine().Once()
mockContext.EXPECT().Option("database").Return("test").Once()
mockContext.EXPECT().Option("connection").Return("test").Once()
mockSchema.EXPECT().Connection("test").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("").Once()
mockSchema.EXPECT().GetTables().Return([]schema.Table{{Name: "test"}}, nil).Once()
Expand All @@ -107,7 +107,7 @@ func TestTableCommand(t *testing.T) {
name: "get indexes failed",
setup: func() {
mockContext.EXPECT().NewLine().Once()
mockContext.EXPECT().Option("database").Return("test").Once()
mockContext.EXPECT().Option("connection").Return("test").Once()
mockSchema.EXPECT().Connection("test").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("").Once()
mockSchema.EXPECT().GetTables().Return([]schema.Table{{Name: "test"}}, nil).Once()
Expand All @@ -125,7 +125,7 @@ func TestTableCommand(t *testing.T) {
name: "get foreign keys failed",
setup: func() {
mockContext.EXPECT().NewLine().Once()
mockContext.EXPECT().Option("database").Return("test").Once()
mockContext.EXPECT().Option("connection").Return("test").Once()
mockSchema.EXPECT().Connection("test").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("").Once()
mockSchema.EXPECT().GetTables().Return([]schema.Table{{Name: "test"}}, nil).Once()
Expand All @@ -144,7 +144,7 @@ func TestTableCommand(t *testing.T) {
name: "success",
setup: func() {
mockContext.EXPECT().NewLine().Times(5)
mockContext.EXPECT().Option("database").Return("test").Once()
mockContext.EXPECT().Option("connection").Return("test").Once()
mockSchema.EXPECT().Connection("test").Return(mockSchema).Once()
mockContext.EXPECT().Argument(0).Return("").Once()
mockSchema.EXPECT().GetTables().Return([]schema.Table{{Name: "test"}}, nil).Once()
Expand Down

0 comments on commit b9d6717

Please sign in to comment.