Closed tamper2 closed 3 years ago
Thanks a lot! Would you be able to add a test for this?
Sure, I'll do that. Any requests for the test?
On Mon, 15 Jun 2020, 18:41 Thomas Pentenrieder, notifications@github.com wrote:
Thanks a lot! Would you be able to add a test for this?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wp-net/WordPressPCL/pull/206#issuecomment-644211804, or unsubscribe https://github.com/notifications/unsubscribe-auth/APOOAXOLKLKHV5LHZC7IKUTRWY6JDANCNFSM4N6IOTUA .
Nothing special, just check that the correct status is read after deleting / moving a post to trash.
Running the hosted & selfhosted tests coming with the original project (without my commit) – most tests fail…?
Am I doing something wrong? I’d prefer to start with a clean slate to know that my tests are running properly…
Image attached:
Description: https://puu.sh/FXKPV/a4b071b547.png
From: Thomas Pentenrieder [mailto:notifications@github.com] Sent: Tuesday, June 16, 2020 16:37 To: wp-net/WordPressPCL Cc: tamper2; Author Subject: Re: [wp-net/WordPressPCL] added trash status (for post/page) (#206)
Nothing special, just check that the correct status is read after deleting / moving a post to trash.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/wp-net/WordPressPCL/pull/206#issuecomment-644770619 , or unsubscribe https://github.com/notifications/unsubscribe-auth/APOOAXKRNYWYBYAX6F33H3TRW5YPZANCNFSM4N6IOTUA . https://github.com/notifications/beacon/APOOAXPBHNOR6MCKTEWRE23RW5YPZA5CNFSM4N6IOTUKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEZXGWOY.gif
huh, at least the Selfhosted should all pass with a properly configured test environment. I need to check what's happening with those in the PR pipeline
huh, at least the Selfhosted should all pass with a properly configured test environment. I need to check what's happening with those in the PR pipeline
Okay, let me know and I'll try to implement those tests later on.
I fixed the ci/cd pipeline, for some reason the wordpress docker container that the tests are run against wasn't created properly.
I fixed the ci/cd pipeline, for some reason the wordpress docker container that the tests are run against wasn't created properly.
Still doesn't work for me in my PR, the tests still fail... :( The PR also shows "All checks have failed" regarding WordpressPCL Integration Tests...
I don't think the pipeline has re-run for this PR after I fixed it. Not sure if there's a way to trigger it besides pushing new changes to this branch.
Edit: found it, lets see
test seems to run fine now so you can try adding new Unit Tests and letting them run here if you can't make it work locally.
Sorry! I completely forgot about this... I'll try to get around to creating a test next week. I'm still not entirely familiar with the project's way of unit testing so it may take me a while. Got any pointers?
I'm not quite sure in which situations the trash status would be visible, but you can take a look here how the integration tests for posts are set up: https://github.com/wp-net/WordPressPCL/blob/master/WordPressPCL.Tests.Selfhosted/Posts_Tests.cs
Best way would be to create a lokal WordPress instance and having the Selfhosted tests run against that by updating the ApiCredentials: https://github.com/wp-net/WordPressPCL/blob/master/WordPressPCL.Tests.Selfhosted/Utility/ApiCredentials.cs
I'm sorry, I'm still rather new to testing in C#, and I can't open a local WP instance on my PC.
Regarding the use-case: In my app I want to let the users restore posts that were previously deleted by them by listing posts with status 'trash'. Would something like this be an appropriate test?
[TestMethod]
public async Task Posts_Trash_Query()
{
var queryBuilder = new PostsQueryBuilder()
{
Statuses = new Status[] { Status.Trash },
};
var posts = await _clientAuth.Posts.Query(queryBuilder, true);
Assert.AreEqual(queryBuilder.BuildQueryURL(), "?status=trash");
Assert.IsNotNull(posts);
Assert.AreNotEqual(posts.Count(), 0);
}
This would of course require having a trashed post in the testing environment. Would you like me to setup that inside the testing method too? (creating & trashing a post -> testing -> deleting post completely)
I would split this into two tests - one to check the QueryBuilder where you don't actually have to make any server calls
(your Assert.AreEqual(queryBuilder.BuildQueryURL(), "?status=trash");
line)
And the second one as you described, creating a post, trashing it and then checking if it's actually trashed.
Can you actually attempt to implement the test? As I'm having issues doing it locally... :(
added tests :) https://github.com/wp-net/WordPressPCL/pull/240
Found out this was missing, fixed for my project and shared :) As per issue #177