Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[DEX-116] Mark file flag as required for the objects import command #37

Merged
merged 1 commit into from
Aug 23, 2022
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/objects/import/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func NewImportCmd(f *cmdutil.Factory) *cobra.Command {
}

cmd.Flags().StringVarP(&file, "file", "F", "", "Read records to import from `file` (use \"-\" to read from standard input)")
_ = cmd.MarkFlagRequired("file")

cmd.Flags().BoolVar(&opts.AutoGenerateObjectIDIfNotExist, "auto-generate-object-id-if-not-exist", false, "Automatically generate object ID if not exist")
cmd.Flags().IntVarP(&opts.BatchSize, "batch-size", "b", 1000, "Specify the upload batch size")
return cmd
Expand Down
10 changes: 10 additions & 0 deletions pkg/cmd/objects/import/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ func Test_runExportCmd(t *testing.T) {
stdin: `{"objectID", "foo"},`,
wantErr: "failed to parse JSON object on line 0: invalid character ',' after object key",
},
{
name: "missing file flag",
cli: "foo",
wantErr: "required flag(s) \"file\" not set",
},
{
name: "non-existant file",
cli: "foo -F /tmp/foo",
wantErr: "open /tmp/foo: no such file or directory",
},
}

for _, tt := range tests {
Expand Down