-
Notifications
You must be signed in to change notification settings - Fork 9
VCST-3904: Published file should not be removed when user makes changes #200
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
Open
basilkot
wants to merge
15
commits into
dev
Choose a base branch
from
fix/VCST-3904
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6654678
small fixes
basilkot 9e9186a
calculate statistics with file state
basilkot 05473d1
add publishing service tests
basilkot a20561e
add content statistic service tests
basilkot 5f5aef9
remove extra spaces
basilkot f3ce603
always return non-draft file name
basilkot ed46ce3
Merge branch 'dev' into fix/VCST-3904
basilkot ecfbc75
add moq
basilkot 8d9e044
Merge branch 'fix/VCST-3904' of https://github.com/VirtoCommerce/vc-m…
basilkot fb69100
fix tests
basilkot 1d9c5db
small fixes
basilkot a78fae0
small code readability fixes
basilkot d2b4837
small fixes
basilkot 65212d8
display correct relative url
basilkot 6dd039f
relative url should be original
basilkot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
tests/VirtoCommerce.ContentModule.Tests/ContentStatisticServiceTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,151 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Moq; | ||
| using VirtoCommerce.AssetsModule.Core.Assets; | ||
| using VirtoCommerce.ContentModule.Core.Search; | ||
| using VirtoCommerce.ContentModule.Core.Services; | ||
| using VirtoCommerce.ContentModule.Data.Services; | ||
| using Xunit; | ||
|
|
||
| namespace VirtoCommerce.ContentModule.Tests; | ||
|
|
||
| public class ContentStatisticServiceTests | ||
| { | ||
| private const string StoreId = "TestStore"; | ||
|
|
||
| [Theory] | ||
| [InlineData(2, "file1.md", "file2.md")] | ||
| [InlineData(2, "file1.md-draft", "file2.md-draft")] | ||
| [InlineData(2, "file1.md-draft", "file2.md")] | ||
| [InlineData(1, "file1.md-draft", "file1.md")] | ||
| public async Task GetStorePagesCount_IsCorrect(int count, params string[] files) | ||
basilkot marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| var sut = GetService(files); | ||
| var result = await sut.GetStorePagesCountAsync(StoreId); | ||
| Assert.Equal(count, result); | ||
| } | ||
|
|
||
| private ContentStatisticService GetService(params string[] files) | ||
| { | ||
| var blobContentProviderFactory = new BlobContentStorageProviderStub(files); | ||
| var contentPathResolver = new ContentPathResolverStub(); | ||
|
|
||
| var contentItemPathRegistrar = new Mock<IContentItemTypeRegistrar>(); | ||
| contentItemPathRegistrar.Setup(x => x.IsRegisteredContentItemType(It.IsAny<string>())).Returns(true); | ||
|
|
||
| var contentService = new Mock<IContentService>(); | ||
| var publishingService = new PublishingServices(contentService.Object); | ||
| var result = new ContentStatisticService(blobContentProviderFactory, contentPathResolver, contentItemPathRegistrar.Object, publishingService); | ||
| return result; | ||
| } | ||
|
|
||
| private class ContentPathResolverStub : IContentPathResolver | ||
| { | ||
| public string GetContentBasePath(string contentType, string storeId, string themeName = null) | ||
| { | ||
| return string.Empty; | ||
| } | ||
| } | ||
|
|
||
| private class BlobContentStorageProviderStub(string[] files) : IBlobContentStorageProviderFactory | ||
| { | ||
| public IBlobContentStorageProvider CreateProvider(string basePath) | ||
| { | ||
| return new ContentBlobStorageProviderStub(files.ToList()); | ||
| } | ||
| } | ||
|
|
||
| private class ContentBlobStorageProviderStub(List<string> files) : IBlobContentStorageProvider | ||
| { | ||
| public Task DeleteAsync(string blobUrl) | ||
| { | ||
| files.Remove(blobUrl); | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| public Task<bool> ExistsAsync(string blobUrl) | ||
| { | ||
| var exists = files.Contains(blobUrl); | ||
| return Task.FromResult(exists); | ||
| } | ||
|
|
||
| public Task<BlobEntrySearchResult> SearchAsync(string folderUrl, string keyword) | ||
| { | ||
| var result = new BlobEntrySearchResult | ||
| { | ||
| Results = files.Select(x => new BlobInfo { Name = x, RelativeUrl = x }).Cast<BlobEntry>().ToList(), | ||
| TotalCount = files.Count | ||
| }; | ||
| return Task.FromResult(result); | ||
| } | ||
|
|
||
| public Task<BlobInfo> GetBlobInfoAsync(string blobUrl) | ||
| { | ||
| var result = new BlobInfo(); | ||
| return Task.FromResult(result); | ||
| } | ||
|
|
||
| public Task CreateFolderAsync(BlobFolder folder) | ||
| { | ||
| return Task.CompletedTask; | ||
| } | ||
|
|
||
| public Stream OpenRead(string blobUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Task<Stream> OpenReadAsync(string blobUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Stream OpenWrite(string blobUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Task<Stream> OpenWriteAsync(string blobUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Task RemoveAsync(string[] urls) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public void Move(string srcUrl, string destUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Task MoveAsyncPublic(string srcUrl, string destUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public void Copy(string srcUrl, string destUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Task CopyAsync(string srcUrl, string destUrl) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public Task UploadAsync(string blobUrl, Stream content, string contentType, bool overwrite = true) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
|
|
||
| public string GetAbsoluteUrl(string blobKey) | ||
| { | ||
| throw new NotImplementedException(); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.