diff --git a/policy/policy_test.go b/policy/policy_test.go index 7ad333d..9a3e7b8 100644 --- a/policy/policy_test.go +++ b/policy/policy_test.go @@ -359,16 +359,18 @@ func TestDeletePolicy_Validate(t *testing.T) { } func TestChangeOrder_Validate(t *testing.T) { + targetIndex := -1 request := &ChangeOrderRequest{ Id: "asd", TeamId: "asd", Type: NotificationPolicy, - TargetIndex: -1, + TargetIndex: &targetIndex, } err := request.Validate() assert.Equal(t, "target index should be at least 0", err.Error()) - request.TargetIndex = 0 + targetIndex = 0 + request.TargetIndex = &targetIndex err = request.Validate() assert.Nil(t, err) } diff --git a/policy/request.go b/policy/request.go index e05e2b1..c44d01f 100644 --- a/policy/request.go +++ b/policy/request.go @@ -440,7 +440,7 @@ type ChangeOrderRequest struct { Id string `json:"id,omitempty"` TeamId string Type PolicyType - TargetIndex int `json:"targetIndex,omitempty"` + TargetIndex *int `json:"targetIndex,omitempty"` } func (r *ChangeOrderRequest) Validate() error { @@ -451,7 +451,7 @@ func (r *ChangeOrderRequest) Validate() error { if err != nil { return err } - if r.TargetIndex < 0 { + if *r.TargetIndex < 0 { return errors.New("target index should be at least 0") } return nil