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
4 changes: 4 additions & 0 deletions .chloggen/mdatagen-no-panic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
change_type: bug_fix
component: cmd/mdatagen
note: Fix panic when mdatagen is run without arguments.
issues: [14506]
1 change: 1 addition & 0 deletions cmd/mdatagen/internal/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func NewCommand() (*cobra.Command, error) {
Use: "mdatagen",
Version: ver,
SilenceUsage: true,
Args: cobra.ExactArgs(1),
RunE: func(_ *cobra.Command, args []string) error {
return run(args[0])
},
Expand Down
10 changes: 10 additions & 0 deletions cmd/mdatagen/internal/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ func TestNewCommand(t *testing.T) {
assert.True(t, cmd.SilenceUsage)
}

func TestCommandNoArgs(t *testing.T) {
cmd, err := NewCommand()
require.NoError(t, err)

cmd.SetArgs([]string{})
err = cmd.Execute()

require.Error(t, err)
}

func TestRunContents(t *testing.T) {
tests := []struct {
yml string
Expand Down
Loading