Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
479dd71
Fix matching issue
zenibako May 13, 2024
d67cf7a
Use == instead of .equals()
zenibako Jul 19, 2024
acffae6
Add suggestions from @scolladon
zenibako Jul 20, 2024
660c1bb
Misc cleanup
zenibako Jul 21, 2024
63e9f06
Add test for custom type without properties
zenibako Jul 21, 2024
c645b12
Add logic to determine jsonEquals usage from list
zenibako Jul 21, 2024
4f4931b
Update API versions
zenibako Jul 21, 2024
582e2a7
Update tests and clean up JSON check criteria
zenibako Jul 21, 2024
73fbe42
Update all API versions
zenibako Jul 21, 2024
1bbc5a0
Clarify `getType` implementation
zenibako Jul 21, 2024
472b883
Restore `json()` string wrapping
zenibako Jul 21, 2024
2ec9476
Add `this.` prefix
zenibako Jul 21, 2024
dfc98bd
Apply low-impact @scolladon suggestions
zenibako Jul 22, 2024
2eb45f8
Update to `.equals()` and fix test
zenibako Jul 22, 2024
5270802
Add comment for new Boolean check
zenibako Jul 22, 2024
bf26933
Update force-app/src/classes/Argument.cls
zenibako Jul 22, 2024
f14ebe0
Comment out failing asserts. Need to investigate further.
zenibako Jul 22, 2024
17b8cfa
Fix CustomType assert
zenibako Jul 22, 2024
4437a80
Apply @scolladon suggestion to only use `.equals()` for String
zenibako Jul 22, 2024
abc809a
Update force-app/test/package/classes/unit/ArgumentTest.cls
zenibako Jul 22, 2024
9502def
Update force-app/test/package/classes/unit/ArgumentTest.cls
zenibako Jul 22, 2024
77b3380
Add checks for case sensitivity
zenibako Jul 22, 2024
505977d
Merge branch 'main' into main
LudoMeurillon Oct 4, 2024
5d30310
chore: run prettier to fix whitespace
zenibako Oct 5, 2024
fac54ed
Merge branch 'main' into main
LudoMeurillon Oct 11, 2024
38f4d07
Merge remote-tracking branch 'salesforce/main'
zenibako Nov 30, 2024
6100dd4
73: Inject namespace using string replacement
zenibako Nov 30, 2024
63e1e4a
fix: string replacements schema
zenibako Nov 30, 2024
cd508e5
chore: fix removed namespace
zenibako Nov 30, 2024
54989a2
Delete redundant class
zenibako Nov 30, 2024
8d73d6a
chore: remove old private class
zenibako Nov 30, 2024
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
34 changes: 17 additions & 17 deletions force-app/recipes/classes/ApexMockeryOverview.cls
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ private class ApexMockeryOverview {
@isTest
static void recipe() {
// Arrange
Mock deliveryServiceMock = Mock.forType(DeliveryService.class);
MethodSpy planDeliverySpy = deliveryServiceMock.spyOn('planDelivery');
namespace.Mock deliveryServiceMock = namespace.Mock.forType(DeliveryService.class, new StubBuilderImpl());
namespace.MethodSpy planDeliverySpy = deliveryServiceMock.spyOn('planDelivery');
Bakery myBakery = new Bakery((DeliveryService) deliveryServiceMock.stub);
planDeliverySpy.whenCalledWith(new Pastry('Chocolatine')).thenReturn(Date.today().addDays(3)).thenReturnOnce(Date.today().addDays(2));
planDeliverySpy.whenCalledWith(new OperaPastryMatchable()).thenThrow(new RecipeException());
planDeliverySpy.returns(Date.today().addDays(4));

Expect.that(planDeliverySpy).hasNotBeenCalled();
Expect.that(planDeliverySpy).hasBeenCalledTimes(0);
namespace.Expect.that(planDeliverySpy).hasNotBeenCalled();
namespace.Expect.that(planDeliverySpy).hasBeenCalledTimes(0);

// Act & Assert
// Once matcher (imagine first command is delivered early)
OrderConfirmation order = myBakery.order(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenCalled();
Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenLastCalledWith(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenCalledTimes(1);
namespace.Expect.that(planDeliverySpy).hasBeenCalled();
namespace.Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Chocolatine'));
namespace.Expect.that(planDeliverySpy).hasBeenLastCalledWith(new Pastry('Chocolatine'));
namespace.Expect.that(planDeliverySpy).hasBeenCalledTimes(1);
Assert.areEqual(Date.today().addDays(2), order.deliveryDate);

// Matcher
order = myBakery.order(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenCalled();
Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenLastCalledWith(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenCalledTimes(2);
namespace.Expect.that(planDeliverySpy).hasBeenCalled();
namespace.Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Chocolatine'));
namespace.Expect.that(planDeliverySpy).hasBeenLastCalledWith(new Pastry('Chocolatine'));
namespace.Expect.that(planDeliverySpy).hasBeenCalledTimes(2);
Assert.areEqual(Date.today().addDays(3), order.deliveryDate);

order = myBakery.order(new Pastry('Croissant'));
Expect.that(planDeliverySpy).hasBeenCalled();
Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Chocolatine'));
Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Croissant'));
Expect.that(planDeliverySpy).hasBeenLastCalledWith(new Pastry('Croissant'));
Expect.that(planDeliverySpy).hasBeenCalledTimes(3);
namespace.Expect.that(planDeliverySpy).hasBeenCalled();
namespace.Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Chocolatine'));
namespace.Expect.that(planDeliverySpy).hasBeenCalledWith(new Pastry('Croissant'));
namespace.Expect.that(planDeliverySpy).hasBeenLastCalledWith(new Pastry('Croissant'));
namespace.Expect.that(planDeliverySpy).hasBeenCalledTimes(3);
Assert.areEqual(Date.today().addDays(4), order.deliveryDate);

try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
public class StubBuilderImpl implements mockery.Mock.StubBuilder {
public class StubBuilderImpl implements namespace.Mock.StubBuilder {
public Object build(final Type aType, System.StubProvider stubProvider) {
return Test.createStub(aType, stubProvider);
}
Expand Down
61 changes: 0 additions & 61 deletions force-app/test/namespace/classes/ApexMockeryOverview.cls

This file was deleted.

This file was deleted.

10 changes: 9 additions & 1 deletion sfdx-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,13 @@
"packageAliases": {
"Apex Mockery": "0HoDn000000kA5aKAE",
"Apex Mockery NS Test": "0HoDn000000kA6JKAU"
}
},
"replacements": [
{
"glob": "force-app/recipes/**/*.cls",
"stringToReplace": "namespace.",
"replaceWithEnv": "SF_NAMESPACE_DOT",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: SF_NAMESPACE_DOT should be used then in the github actions right ?

We should remove then this githubaction
And only use this one:

  • It should take a parameter a boolean "namespace". When namespace is true it should set the SF_NAMESPACE_DOT with the value mockery., else it should set it with empty string
  • this github action should be modified to call the only one action twice with the "namespace" boolean true for validate-namespace-compatibility step and false for validate-package-version

Something like that ?

Copy link
Contributor Author

@zenibako zenibako Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly it. It should also give people the opportunity to use their own namespace if they want to fork the package (since tests in their repository will fail if it is locked to mockery).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to contribute here soon (don't know when yet) !

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure when I'll be able to work on this @zenibako

Feel free to start the work from this discussion 😁

"allowUnsetEnvVariable": true
}
]
}