Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass timestamp to givenEvents events #1862

Closed
krutilin opened this issue May 12, 2021 · 0 comments · Fixed by #1872
Closed

Can't pass timestamp to givenEvents events #1862

krutilin opened this issue May 12, 2021 · 0 comments · Fixed by #1872
Assignees
Labels
bug Issues related to defects and incorrect/unexpected feature behavior severity: minor Issues with low impact on the product, e.g., small improvements or imperfections

Comments

@krutilin
Copy link
Contributor

Describe the bug
Can't pass timestamp to givenEvents events in tests. The timestamp value is always modified under the hood.

To Reproduce
Steps to reproduce the behavior:

  1. npx create-resolve-app resolve-shopping-list -e shopping-list
  2. aggregates.test.js
import {
  SHOPPING_LIST_CREATED,
} from '../../common/event_types'

import givenEvents from '@resolve-js/testing-tools'
import projection from '../../common/aggregates/shopping_list.projection'
import commands from '../../common/aggregates/shopping_list.commands'

const shoppingListAggregate = {
  name: 'ShoppingList',
  projection,
  commands: commands
}

describe('aggregates', () => {
  test.only('ShoppingList Create', async () => {
    const event = await givenEvents([{
      type: SHOPPING_LIST_CREATED,
      payload: { name: 'TESTS' },
      timestamp: 1
    }])
      .aggregate(shoppingListAggregate)
      .command('createShoppingList', {
        name: 'Lager',
      })

    console.log(event)
  })
})
  1. shopping_list.projection.js
import { SHOPPING_LIST_CREATED, SHOPPING_LIST_REMOVED } from '../event_types'

export default {
  Init: () => ({}),
  [SHOPPING_LIST_CREATED]: (state, payload) => {
    const { timestamp } = payload
    console.log('state', state)
    console.log('payload', payload)
    return {
      ...state,
      createdAt: timestamp,
    }
  },
  [SHOPPING_LIST_REMOVED]: () => ({}),
}

  1. yarn test
  2. see the console log with timestamp different from passed to the givenEvents events.
console.log
    payload {
      threadCounter: 0,
      threadId: 169,
      type: 'SHOPPING_LIST_CREATED',
      timestamp: 1620836182180,
      aggregateId: 'test-aggregate-id',
      aggregateVersion: 1,
      payload: { name: 'TESTS' }
    }

Expected behavior
Do not modify timestamp if it is set in events.

Desktop (please complete the following information):

  • ReSolve Version 0.30.2
@max-vasin max-vasin linked a pull request May 13, 2021 that will close this issue
@max-vasin max-vasin removed a link to a pull request May 13, 2021
@MrCheater MrCheater self-assigned this May 13, 2021
@MrCheater MrCheater added bug Issues related to defects and incorrect/unexpected feature behavior severity: minor Issues with low impact on the product, e.g., small improvements or imperfections labels May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to defects and incorrect/unexpected feature behavior severity: minor Issues with low impact on the product, e.g., small improvements or imperfections
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants