Merge pull request #10374 from iamazeem/10342-gh-project-item-edit-number
[gh project item-edit] Fix number type
This commit is contained in:
commit
9da292d3a6
3 changed files with 13 additions and 5 deletions
|
|
@ -23,7 +23,7 @@ type editItemOpts struct {
|
||||||
fieldID string
|
fieldID string
|
||||||
projectID string
|
projectID string
|
||||||
text string
|
text string
|
||||||
number float32
|
number float64
|
||||||
date string
|
date string
|
||||||
singleSelectOptionID string
|
singleSelectOptionID string
|
||||||
iterationID string
|
iterationID string
|
||||||
|
|
@ -123,7 +123,7 @@ func NewCmdEditItem(f *cmdutil.Factory, runF func(config editItemConfig) error)
|
||||||
editItemCmd.Flags().StringVar(&opts.fieldID, "field-id", "", "ID of the field to update")
|
editItemCmd.Flags().StringVar(&opts.fieldID, "field-id", "", "ID of the field to update")
|
||||||
editItemCmd.Flags().StringVar(&opts.projectID, "project-id", "", "ID of the project to which the field belongs to")
|
editItemCmd.Flags().StringVar(&opts.projectID, "project-id", "", "ID of the project to which the field belongs to")
|
||||||
editItemCmd.Flags().StringVar(&opts.text, "text", "", "Text value for the field")
|
editItemCmd.Flags().StringVar(&opts.text, "text", "", "Text value for the field")
|
||||||
editItemCmd.Flags().Float32Var(&opts.number, "number", 0, "Number value for the field")
|
editItemCmd.Flags().Float64Var(&opts.number, "number", 0, "Number value for the field")
|
||||||
editItemCmd.Flags().StringVar(&opts.date, "date", "", "Date value for the field (YYYY-MM-DD)")
|
editItemCmd.Flags().StringVar(&opts.date, "date", "", "Date value for the field (YYYY-MM-DD)")
|
||||||
editItemCmd.Flags().StringVar(&opts.singleSelectOptionID, "single-select-option-id", "", "ID of the single select option value to set on the field")
|
editItemCmd.Flags().StringVar(&opts.singleSelectOptionID, "single-select-option-id", "", "ID of the single select option value to set on the field")
|
||||||
editItemCmd.Flags().StringVar(&opts.iterationID, "iteration-id", "", "ID of the iteration value to set on the field")
|
editItemCmd.Flags().StringVar(&opts.iterationID, "iteration-id", "", "ID of the iteration value to set on the field")
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,14 @@ func TestNewCmdeditItem(t *testing.T) {
|
||||||
itemID: "123",
|
itemID: "123",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "number with floating point value",
|
||||||
|
cli: "--number 123.45 --id 123",
|
||||||
|
wants: editItemOpts{
|
||||||
|
number: 123.45,
|
||||||
|
itemID: "123",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "field-id",
|
name: "field-id",
|
||||||
cli: "--field-id FIELD_ID --id 123",
|
cli: "--field-id FIELD_ID --id 123",
|
||||||
|
|
@ -255,7 +263,7 @@ func TestRunItemEdit_Number(t *testing.T) {
|
||||||
// edit item
|
// edit item
|
||||||
gock.New("https://api.github.com").
|
gock.New("https://api.github.com").
|
||||||
Post("/graphql").
|
Post("/graphql").
|
||||||
BodyString(`{"query":"mutation UpdateItemValues.*","variables":{"input":{"projectId":"project_id","itemId":"item_id","fieldId":"field_id","value":{"number":2}}}}`).
|
BodyString(`{"query":"mutation UpdateItemValues.*","variables":{"input":{"projectId":"project_id","itemId":"item_id","fieldId":"field_id","value":{"number":123.45}}}}`).
|
||||||
Reply(200).
|
Reply(200).
|
||||||
JSON(map[string]interface{}{
|
JSON(map[string]interface{}{
|
||||||
"data": map[string]interface{}{
|
"data": map[string]interface{}{
|
||||||
|
|
@ -284,7 +292,7 @@ func TestRunItemEdit_Number(t *testing.T) {
|
||||||
config := editItemConfig{
|
config := editItemConfig{
|
||||||
io: ios,
|
io: ios,
|
||||||
opts: editItemOpts{
|
opts: editItemOpts{
|
||||||
number: 2,
|
number: 123.45,
|
||||||
itemID: "item_id",
|
itemID: "item_id",
|
||||||
projectID: "project_id",
|
projectID: "project_id",
|
||||||
fieldID: "field_id",
|
fieldID: "field_id",
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,7 @@ type FieldValueNodes struct {
|
||||||
Field ProjectField
|
Field ProjectField
|
||||||
} `graphql:"... on ProjectV2ItemFieldLabelValue"`
|
} `graphql:"... on ProjectV2ItemFieldLabelValue"`
|
||||||
ProjectV2ItemFieldNumberValue struct {
|
ProjectV2ItemFieldNumberValue struct {
|
||||||
Number float32
|
Number float64
|
||||||
Field ProjectField
|
Field ProjectField
|
||||||
} `graphql:"... on ProjectV2ItemFieldNumberValue"`
|
} `graphql:"... on ProjectV2ItemFieldNumberValue"`
|
||||||
ProjectV2ItemFieldSingleSelectValue struct {
|
ProjectV2ItemFieldSingleSelectValue struct {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue