ONSdigital / dp-find-insights-poc-api

Find Insights Proof of Concept
MIT License
1 stars 0 forks source link

Bug/comp tests #170

Closed stmuk closed 2 years ago

stmuk commented 2 years ago

What

https://trello.com/c/AA1PT5hX/217-check-comptests

"duplicate key value violates unique constraint" errors were showing a serious bug in metadata/metadata_test.go"

The first such error in INSERT INTO NOMIS_TOPIC (id) VALUES (0) (now fixed) didn't matter and was a warning.

But the other such errors were showing the database wasn't rolling back (as spotted by V last week).

The root cause was the wrong db handle being used in metadata/metadata_test.go (now fixed)

Also notice that taking down the docker container "docker container kill postgis" caused a failure first run (showing the tests were using old state)

How to review

go test -count=1 ./... -v -tags=comptest|grep -i "duplicate key value" should be blank

take down via "docker container kill postgis" & rerun tests (should work)