func TestApplyChangeEventUsingWith(t *testing.T) {
	for _, l := range changeEventTestTbl {
		called := false
		runTest(t, func(s *res.Service) {
			s.Handle("model",
				res.GetModel(func(r res.ModelRequest) {
					r.NotFound()
				}),
				res.ApplyChange(func(r res.Resource, changes map[string]interface{}) (map[string]interface{}, error) {
					called = true
					restest.AssertEqualJSON(t, "changes", changes, l.Payload)
					restest.AssertEqualJSON(t, "ResourceName", r.ResourceName(), "test.model")
					return map[string]interface{}{"foo": 12}, nil
				}),
			)
		}, func(s *restest.Session) {
			restest.AssertNoError(t, s.Service().With("test.model", func(r res.Resource) {
				r.ChangeEvent(l.Payload)
				restest.AssertEqualJSON(t, "called", called, true)
			}))
			s.GetMsg().AssertEventName("test.model", "change")
		})
	}
}
Test ApplyChange is called on change event using With
package test
import (
	"testing"
	res "github.com/jirenius/go-res"
	"github.com/jirenius/go-res/restest"
)
func TestApplyChangeEvent(t *testing.T) {
	for _, l := range changeEventTestTbl {
		called := false
		runTest(t, func(s *res.Service) {
			s.Handle("model",
				res.GetModel(func(r res.ModelRequest) {
					r.NotFound()
				}),
				res.Call("method", func(r res.CallRequest) {
					r.ChangeEvent(l.Payload)
					restest.AssertEqualJSON(t, "called", called, true)
					r.OK(nil)
				}),
				res.ApplyChange(func(r res.Resource, changes map[string]interface{}) (map[string]interface{}, error) {
					called = true
					restest.AssertEqualJSON(t, "changes", changes, l.Payload)
					restest.AssertEqualJSON(t, "ResourceName", r.ResourceName(), "test.model")
					return map[string]interface{}{"foo": 12}, nil
				}),
			)
		}, func(s *restest.Session) {
			req := s.Call("test.model", "method", nil)
			s.GetMsg().AssertEventName("test.model", "change")
			req.Response()
		})
	}
}
func TestApplyEmptyChangeEvent(t *testing.T) {
	called := false
	runTest(t, func(s *res.Service) {
		s.Handle("model",
			res.GetModel(func(r res.ModelRequest) {
				r.NotFound()
			}),
			res.Call("method", func(r res.CallRequest) {
				r.ChangeEvent(nil)
				restest.AssertEqualJSON(t, "called", called, false)
				r.OK(nil)
			}),
			res.ApplyChange(func(r res.Resource, changes map[string]interface{}) (map[string]interface{}, error) {
				called = true
				return nil, nil
			}),
		)
	}, func(s *restest.Session) {
		s.Call("test.model", "method", nil).Response()
	})
}