Exemple #1
0
func (m *Mother) UserStrategy() services.UserStrategy {
	return services.NewUserStrategy(m.Enqueuer(), m.V2Enqueuer())
}
var _ = Describe("UserStrategy", func() {
	var (
		strategy        services.UserStrategy
		v1Enqueuer      *mocks.Enqueuer
		v2Enqueuer      *mocks.V2Enqueuer
		conn            *mocks.Connection
		requestReceived time.Time
	)

	BeforeEach(func() {
		requestReceived, _ = time.Parse(time.RFC3339Nano, "2015-06-08T14:37:35.181067085-07:00")
		conn = mocks.NewConnection()
		v1Enqueuer = mocks.NewEnqueuer()
		v2Enqueuer = mocks.NewV2Enqueuer()
		strategy = services.NewUserStrategy(v1Enqueuer, v2Enqueuer)
	})

	Describe("Dispatch", func() {
		Context("when the job is not v2", func() {
			It("calls v1Enqueuer.Enqueue with the correct arguments for a user", func() {
				_, err := strategy.Dispatch(services.Dispatch{
					GUID:       "user-123",
					Connection: conn,
					Message: services.DispatchMessage{
						To:      "*****@*****.**",
						ReplyTo: "*****@*****.**",
						Subject: "this is the subject",
						Text:    "Please make sure to leave your bottle in a place that is safe and dry",
						HTML: services.HTML{
							BodyContent:    "<p>The water bottle needs to be safe and dry</p>",