Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance test for Media Cleanup #2118

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,46 @@ codeunit 135018 "Media Cleanup Test"
LibraryAssert.IsTrue(TempTenantMedia.IsEmpty(), 'Detached Tenant media was not cleaned up properly.');
end;

[Test]
procedure EnsureNormalMediaArePersisted()
var
TenantMedia: Record "Tenant Media";
TenantMediaSetup: Record "Tenant Media Set";
TestMediaClean: Record "Test Media Cleanup";
TempBlob: Codeunit "Temp Blob";
MediaOutStream: OutStream;
i: Integer;
begin
PermissionsMock.Set('SUPER');

TestMediaClean.Insert();

TempBlob.CreateOutStream(MediaOutStream);
MediaOutStream.WriteText('123');
TestMediaClean."Test Media".ImportStream(TempBlob.CreateInStream(), '');
TestMediaClean.Modify();

clear(TempBlob);
TempBlob.CreateOutStream(MediaOutStream);
for i := 0 to 99 do
MediaOutStream.WriteText('123');
TestMediaClean."Test Media Set".ImportStream(TempBlob.CreateInStream(), '');
TestMediaClean.Modify();

LibraryAssert.IsTrue(TestMediaClean."Test Media".HasValue(), 'Tenant Media is not correctly inserted.');
LibraryAssert.IsTrue(TestMediaClean."Test Media Set".Count() > 0, 'Tenant Media Set is not correctly inserted.');
LibraryAssert.IsFalse(TenantMedia.IsEmpty(), 'Tenant Media is not correctly inserted.');
LibraryAssert.IsFalse(TenantMediaSetup.IsEmpty(), 'Tenant Media Set is not correctly inserted.');

Codeunit.Run(Codeunit::"Media Cleanup Runner");

LibraryAssert.IsFalse(TenantMedia.IsEmpty(), 'Normal tenant media is also affected.');
LibraryAssert.IsFalse(TenantMediaSetup.IsEmpty(), 'Normal tenant media set is also affected.');

PermissionsMock.ClearAssignments();
end;


local procedure GetDetachedTenantMedia(var TempTenantMedia: Record "Tenant Media" temporary)
var
MediaCleanup: Codeunit "Media Cleanup";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// ------------------------------------------------------------------------------------------------

namespace System.Test.DataAdministration;

table 135018 "Test Media Cleanup"
{
DataClassification = CustomerContent;
InherentPermissions = RIMDX;
InherentEntitlements = RIMDX;

fields
{
field(1; "Primary Key"; Integer)
{
}
field(2; "Test Media"; Media)
{
}
field(3; "Test Media Set"; MediaSet)
{
}
}

keys
{
key(PK; "Primary Key")
{
Clustered = true;
}
}
}
Loading