diff --git a/.github/workflows/postman_tests.yml b/.github/workflows/postman_tests.yml index 6fbf109..9a027b3 100644 --- a/.github/workflows/postman_tests.yml +++ b/.github/workflows/postman_tests.yml @@ -36,7 +36,7 @@ jobs: - name: Start backend server env: S_PORT: 3100 - MONGODB_URI: ${{secrets.MONGODB_URI}} + MONGODB_URI: mongodb://127.0.0.1:27017/foodstoragemanager_test run: | set -eo pipefail npm --workspace=server run dev >/tmp/server.log 2>&1 & diff --git a/server/postman/backend.postman_collection.json b/server/postman/backend.postman_collection.json index f7d5b7c..4132499 100644 --- a/server/postman/backend.postman_collection.json +++ b/server/postman/backend.postman_collection.json @@ -205,9 +205,14 @@ "script": { "type": "text/javascript", "exec": [ - "pm.test('delete returns 200', () => pm.response.to.have.status(200));", - "const json = pm.response.json();", - "pm.test('deleted item matches id', () => pm.expect(json.item._id).to.eql(pm.collectionVariables.get('itemId')));" + "const status = pm.response.code;", + "pm.test('delete returns 200 or 404 if already removed', () => pm.expect([200, 404]).to.include(status));", + "if (status === 200) {", + " const json = pm.response.json();", + " pm.test('deleted item matches id', () => pm.expect(json.item._id).to.eql(pm.collectionVariables.get('itemId')));", + "} else {", + " pm.test('already removed is acceptable', () => true);", + "}" ] } }