MCPcopy Create free account
hub / github.com/cli/cli / TestNewCmdeditItem

Function TestNewCmdeditItem

pkg/cmd/project/item-edit/item_edit_test.go:14–247  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

12)
13
14func TestNewCmdeditItem(t *testing.T) {
15 tests := []struct {
16 name string
17 cli string
18 wants editItemOpts
19 wantsErr bool
20 wantsErrMsg string
21 wantsExporter bool
22 }{
23 {
24 name: "no item selector flags",
25 cli: "",
26 wantsErr: true,
27 wantsErrMsg: "specify the item to edit with `--id` or `--url`",
28 },
29 {
30 name: "invalid-flags",
31 cli: "--id 123 --text t --date 2023-01-01",
32 wantsErr: true,
33 wantsErrMsg: "only one of `--text`, `--number`, `--date`, `--single-select-option-id`, `--iteration-id` or `--value` may be used",
34 },
35 {
36 name: "field and field-id conflict",
37 cli: "--url https://github.com/o/r/issues/1 --field Status --field-id FIELD_ID",
38 wantsErr: true,
39 wantsErrMsg: "only one of `--field` or `--field-id` may be used",
40 },
41 {
42 name: "url and id conflict",
43 cli: "--id 123 --url https://github.com/o/r/issues/1",
44 wantsErr: true,
45 wantsErrMsg: "only one of `--url` or `--id` may be used",
46 },
47 {
48 name: "value and single-select-option-id conflict",
49 cli: "--url https://github.com/o/r/issues/1 --field Status --value Todo --single-select-option-id OPTION_ID",
50 wantsErr: true,
51 wantsErrMsg: "only one of `--text`, `--number`, `--date`, `--single-select-option-id`, `--iteration-id` or `--value` may be used",
52 },
53 {
54 name: "value requires field",
55 cli: "1 --url https://github.com/o/r/issues/1 --value Todo",
56 wantsErr: true,
57 wantsErrMsg: "`--value` requires `--field`",
58 },
59 {
60 name: "value and field-id conflict",
61 cli: "1 --owner monalisa --url https://github.com/o/r/issues/1 --field-id FIELD_ID --value Todo",
62 wantsErr: true,
63 wantsErrMsg: "`--value` cannot be used with `--field-id`; name the field with `--field` to use `--value`",
64 },
65 {
66 name: "field and id conflict",
67 cli: "1 --owner monalisa --id ITEM_ID --field Status",
68 wantsErr: true,
69 wantsErrMsg: "`--field` cannot be used with `--id`; use `--url` to address the item when editing by name",
70 },
71 {

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewCmdEditItemFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected