You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.
invariant means "something that should never changes". There are tests that, regardless of the account state, shall always be true.
the idea is to implement generic tests for any account. we could have a convention of a "account spec" and it could be as simple as implementing a function account => { ... tests here }
example:
functiongenericAccountInvariants(account,ctx){test("operations are in order",()=>{letdates=account.operations.map(o=>o.date);letsorted=account.operations.sort(dateSorter);expect(dates).toEqual(sorted);});if(ctx.stable){// stable could be a flag that says "you can assume the account didn't change"test("a sync works and do not change the operations list",async()=> ...doasynchere...)}}
each family could also provide their own invariant function to test the specific parts.
the point of this invariance definition is that we can now use it from different places and contextes! We can trivially use it for "stable" accounts that are frozen. but we can also use it in the bot. or we can use it inside LLD testing context. Basically as much as we will instrument it, more we will evaluate and detect problems.
NB: today, such tests already exists, a bit hidden in the "dataset test" logic, goal is to move out of this paradigm and make the dataset tests independent of the "frozen accounts", because these tests can be shared for the bot. making the "frozen dataset" pretty trivial as you can just compose the data with these invariants.
The text was updated successfully, but these errors were encountered:
function syncAccountInvariants (account, ctx) {
test("operations are in order", () => {
let dates = account.operations.map(o=>o.date);
let sorted = account.operations.sort(dateSorter);
expect(dates).toEqual(sorted);
});
}
function asyncAccountInvariants (account, ctx) {
test("a sync works and do not change the operations list", async () => ...do a sync here... )
}
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
invariant means "something that should never changes". There are tests that, regardless of the account state, shall always be true.
the idea is to implement generic tests for any account. we could have a convention of a "account spec" and it could be as simple as implementing a function
account => { ... tests here }
example:
each family could also provide their own invariant function to test the specific parts.
the point of this invariance definition is that we can now use it from different places and contextes! We can trivially use it for "stable" accounts that are frozen. but we can also use it in the bot. or we can use it inside LLD testing context. Basically as much as we will instrument it, more we will evaluate and detect problems.
NB: today, such tests already exists, a bit hidden in the "dataset test" logic, goal is to move out of this paradigm and make the dataset tests independent of the "frozen accounts", because these tests can be shared for the bot. making the "frozen dataset" pretty trivial as you can just compose the data with these invariants.
The text was updated successfully, but these errors were encountered: