Example #1
0
        public void RemoveFromQueue_ReallyDeletesTheJobFromTheQueue()
        {
            UseConnection((provider, connection) =>
            {
                // Arrange
                var id            = CreateJobQueueRecord(connection, "1", "default");
                var processingJob = new FetchedJob(provider, id, "1", "default");

                // Act
                processingJob.RemoveFromQueue();

                // Assert
                var count = connection.Query <long>(@"select count(*) from """ + GetSchemaName() + @""".""jobqueue""")
                            .Single();
                Assert.Equal(0, count);
            });
        }
Example #2
0
        public void RemoveFromQueue_DoesNotDelete_UnrelatedJobs()
        {
            UseConnection((provider, connection) =>
            {
                // Arrange
                CreateJobQueueRecord(connection, "1", "default");
                CreateJobQueueRecord(connection, "1", "critical");
                CreateJobQueueRecord(connection, "2", "default");

                var fetchedJob = new FetchedJob(provider, 999, "1", "default");

                // Act
                fetchedJob.RemoveFromQueue();

                // Assert
                var count = connection.Query <long>(@"select count(*) from """ + GetSchemaName() + @""".""jobqueue""")
                            .Single();
                Assert.Equal(3, count);
            });
        }
Example #3
0
    public void Dequeue_ShouldRemoveFromQueue_WhenTheJobIsRemovedFromQueue()
    {
        // clean all the documents for the container
        ContainerFixture.Clean();

        //arrange
        JobQueue jobQueue = new(Storage);

        jobQueue.Enqueue("default", Guid.NewGuid().ToString());

        //act
        FetchedJob job = (FetchedJob)jobQueue.Dequeue(defaultQueues, CancellationToken.None);

        job.RemoveFromQueue();

        JobQueueMonitoringApi monitoringApi = new(Storage);

        (int?enqueuedCount, int?fetchedCount)data = monitoringApi.GetEnqueuedAndFetchedCount("default");

        //assert
        Assert.Equal(0, data.enqueuedCount);
        Assert.Equal(0, data.fetchedCount);
    }