JujaLabs / itevents

Resource to subscribe on it events
Apache License 2.0
7 stars 5 forks source link

Tests Bug #75

Closed romach closed 8 years ago

romach commented 9 years ago

Нашел баг в тестах:

Порядок воспроизведения

При первом запуске тестов возникают две ошибки:

org.itevents.service.CityServiceTest > testAddCity FAILED
    org.springframework.dao.DuplicateKeyException at CityServiceTest.java:55
        Caused by: org.postgresql.util.PSQLException at CityServiceTest.java:55

org.itevents.service.CityServiceTest > testRemoveCitySuccess FAILED
    org.springframework.dao.DuplicateKeyException at CityServiceTest.java:77
        Caused by: org.postgresql.util.PSQLException at CityServiceTest.java:77

При последующих запусках ошибки не возникают;

Анализ бага

    org.springframework.dao.DuplicateKeyException: 
    ### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
      Подробности: Key (id)=(1) already exists.
    ### The error may involve org.itevents.mybatis.mapper.CityMapper.addCity-Inline
    ### The error occurred while setting parameters
    ### SQL: INSERT INTO city(name, details, point) VALUES(?, ?, ST_MakePoint(?,?))
    ### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
      Подробности: Key (id)=(1) already exists.
    ; SQL []; ERROR: duplicate key value violates unique constraint "city_pkey"
      Подробности: Key (id)=(1) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
      Подробности: Key (id)=(1) already exists.
org.springframework.dao.DuplicateKeyException: 
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(2) already exists.
### The error may involve org.itevents.mybatis.mapper.CityMapper.addCity-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO city(name, details, point) VALUES(?, ?, ST_MakePoint(?,?))
### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(2) already exists.
; SQL []; ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(2) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(2) already exists.
org.springframework.dao.DuplicateKeyException: 
### Error updating database.  Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(3) already exists.
### The error may involve org.itevents.mybatis.mapper.CityMapper.addCity-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO city(name, details, point) VALUES(?, ?, ST_MakePoint(?,?))
### Cause: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(3) already exists.
; SQL []; ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(3) already exists.; nested exception is org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "city_pkey"
  Подробности: Key (id)=(3) already exists.

При последующих запусках тестов исключений нет, так как сиквенс обновлен.

Вывод

Если явно не указывать id, бага не будет

vaa25 commented 8 years ago

Замечательный отчет, Рома как всегда на высоте. Но данный баг легко исправился при рефакторинге тестов, так что issue 75 больше не актуальна.