Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Implement priority field in project label creation and update funct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
timofurrer committed Mar 7, 2022
1 parent 98aef99 commit d15c5d4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit d15c5d4

Please sign in to comment.