mirror of https://github.com/Squidex/squidex.git
Browse Source
* Tus support. * Save file. * Fix registration. * Fix local cache usage. * Make assert more flexible. * Cleanup * Another cleanup. * better tests. * Fix tests? * Update packages. * Easier tests? * Upload packages. * Another attempt. * Check for exception. * Fix testpull/840/head
committed by
GitHub
47 changed files with 698 additions and 155 deletions
@ -0,0 +1,40 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Orleans; |
|||
using Orleans.Runtime; |
|||
using tusdotnet.Interfaces; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities.Assets |
|||
{ |
|||
public sealed class AssetCleanupGrain : Grain, IRemindable, IAssetCleanupGrain |
|||
{ |
|||
private readonly ITusExpirationStore expirationStore; |
|||
|
|||
public AssetCleanupGrain(ITusExpirationStore expirationStore) |
|||
{ |
|||
this.expirationStore = expirationStore; |
|||
} |
|||
|
|||
public override Task OnActivateAsync() |
|||
{ |
|||
RegisterOrUpdateReminder("Cleanup", TimeSpan.Zero, TimeSpan.FromMinutes(10)); |
|||
|
|||
return base.OnActivateAsync(); |
|||
} |
|||
|
|||
public Task ActivateAsync() |
|||
{ |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
public Task ReceiveReminder(string reminderName, TickStatus status) |
|||
{ |
|||
return expirationStore.RemoveExpiredFilesAsync(default); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using Squidex.Infrastructure.Orleans; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities.Assets |
|||
{ |
|||
public interface IAssetCleanupGrain : IBackgroundGrain |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,39 @@ |
|||
// ==========================================================================
|
|||
// Squidex Headless CMS
|
|||
// ==========================================================================
|
|||
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
|||
// All rights reserved. Licensed under the MIT license.
|
|||
// ==========================================================================
|
|||
|
|||
using FakeItEasy; |
|||
using tusdotnet.Interfaces; |
|||
using Xunit; |
|||
|
|||
namespace Squidex.Domain.Apps.Entities.Assets |
|||
{ |
|||
public class AssetCleanupGrainTests |
|||
{ |
|||
private readonly ITusExpirationStore expirationStore = A.Fake<ITusExpirationStore>(); |
|||
private readonly AssetCleanupGrain sut; |
|||
|
|||
public AssetCleanupGrainTests() |
|||
{ |
|||
sut = new AssetCleanupGrain(expirationStore); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_do_nothing_on_activate() |
|||
{ |
|||
await sut.ActivateAsync(); |
|||
} |
|||
|
|||
[Fact] |
|||
public async Task Should_call_expiration_store_when_reminder_invoked() |
|||
{ |
|||
await sut.ReceiveReminder("Reminder", default); |
|||
|
|||
A.CallTo(() => expirationStore.RemoveExpiredFilesAsync(default)) |
|||
.MustHaveHappened(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue