fix topic update integration test, topicGetByUrl now optionally applies defaults
[websub-hub] / test / src / db / integration.js
index 83feac761222a620793cb6963b9a2604e3fb60f5..bd28e92a9124c7ba1d7cb2c0a7bc9d256e10c983 100644 (file)
@@ -79,6 +79,11 @@ describe('Database Integration', function () {
         assert(db);
       });
 
+      it('is healthy', async function () {
+        const result = await db.healthCheck();
+        assert(result);
+      });
+
       describe('Authentication', function () {
         let identifier, credential;
         beforeEach(function () {
@@ -148,12 +153,15 @@ describe('Database Integration', function () {
           const data = {
             topicId,
             leaseSecondsMin: 60,
-          }
+          };
           await db.context(async(dbCtx) => {
-            let topic = await db.topicGetByUrl(dbCtx, testData.topicSet.url);
+            const expected = await db.topicGetByUrl(dbCtx, testData.topicSet.url, true);
+            expected.leaseSecondsMin = data.leaseSecondsMin;
+            let topic = await db.topicGetByUrl(dbCtx, testData.topicSet.url, false);
             await db.topicUpdate(dbCtx, { ...topic, ...data });
             topic = await db.topicGetByUrl(dbCtx, testData.topicSet.url);
             assert.strictEqual(Number(topic.leaseSecondsMin), data.leaseSecondsMin);
+            assert.deepEqual(topic, expected);
           });
         });
         step('gets topic by id', async function () {
@@ -220,6 +228,14 @@ describe('Database Integration', function () {
             assert.strictEqual(Number(topic.contentFetchAttemptsSinceSuccess), 0);
           });
         });
+        step('gets publish history', async function () {
+          await db.context(async (dbCtx) => {
+            const result = (await db.topicPublishHistory(dbCtx, topicId, 7))
+              .map((x) => Number(x));
+            const expected = [1, 0, 0, 0, 0, 0, 0];
+            assert.deepStrictEqual(result, expected);
+          });  
+        });
         step('deletes a topic', async function () {
           await db.context(async (dbCtx) => {
             const result = await db.topicSet(dbCtx, testData.anotherTopicSet);