From d15c5d4a27be9c7aeccec5f0c9060c5c131f4c2c Mon Sep 17 00:00:00 2001 From: Timo Furrer Date: Mon, 7 Mar 2022 11:06:55 +0100 Subject: [PATCH] Implement `priority` field in project label creation and update functions --- labels.go | 2 ++ labels_test.go | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/labels.go b/labels.go index 66db47445..4868bdaaf 100644 --- a/labels.go +++ b/labels.go @@ -140,6 +140,7 @@ type CreateLabelOptions struct { Name *string `url:"name,omitempty" json:"name,omitempty"` Color *string `url:"color,omitempty" json:"color,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"` + Priority *int `url:"priority,omitempty" json:"priority,omitempty"` } // CreateLabel creates a new label for given repository with given name and @@ -200,6 +201,7 @@ type UpdateLabelOptions struct { NewName *string `url:"new_name,omitempty" json:"new_name,omitempty"` Color *string `url:"color,omitempty" json:"color,omitempty"` Description *string `url:"description,omitempty" json:"description,omitempty"` + Priority *int `url:"priority,omitempty" json:"priority,omitempty"` } // UpdateLabel updates an existing label with new name or now color. At least diff --git a/labels_test.go b/labels_test.go index eb262b326..66cdcb787 100644 --- a/labels_test.go +++ b/labels_test.go @@ -30,20 +30,21 @@ func TestCreateLabel(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/labels", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPost) - fmt.Fprint(w, `{"id":1, "name": "My Label", "color" : "#11FF22"}`) + fmt.Fprint(w, `{"id":1, "name": "My Label", "color" : "#11FF22", "priority": 2}`) }) // Create new label l := &CreateLabelOptions{ - Name: String("My Label"), - Color: String("#11FF22"), + Name: String("My Label"), + Color: String("#11FF22"), + Priority: Int(2), } label, _, err := client.Labels.CreateLabel("1", l) if err != nil { log.Fatal(err) } - want := &Label{ID: 1, Name: "My Label", Color: "#11FF22"} + want := &Label{ID: 1, Name: "My Label", Color: "#11FF22", Priority: 2} if !reflect.DeepEqual(want, label) { t.Errorf("Labels.CreateLabel returned %+v, want %+v", label, want) } @@ -74,7 +75,7 @@ func TestUpdateLabel(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/labels", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, http.MethodPut) - fmt.Fprint(w, `{"id":1, "name": "New Label", "color" : "#11FF23" , "description":"This is updated label"}`) + fmt.Fprint(w, `{"id":1, "name": "New Label", "color" : "#11FF23" , "description":"This is updated label", "priority": 42}`) }) // Update label @@ -83,6 +84,7 @@ func TestUpdateLabel(t *testing.T) { NewName: String("New Label"), Color: String("#11FF23"), Description: String("This is updated label"), + Priority: Int(42), } label, resp, err := client.Labels.UpdateLabel("1", l) @@ -94,7 +96,7 @@ func TestUpdateLabel(t *testing.T) { log.Fatal(err) } - want := &Label{ID: 1, Name: "New Label", Color: "#11FF23", Description: "This is updated label"} + want := &Label{ID: 1, Name: "New Label", Color: "#11FF23", Description: "This is updated label", Priority: 42} if !reflect.DeepEqual(want, label) { t.Errorf("Labels.UpdateLabel returned %+v, want %+v", label, want)