Skip to content

Chore/migrate tests#75

Closed
ascandone wants to merge 62 commits intofeat/specs-formatfrom
chore/migrate-tests
Closed

Chore/migrate tests#75
ascandone wants to merge 62 commits intofeat/specs-formatfrom
chore/migrate-tests

Conversation

@ascandone
Copy link
Contributor

No description provided.

ascandone and others added 23 commits July 12, 2025 18:04
- TestSend -> send.num
- TestVariablesJSON -> variables-json.num
- TestPortionSyntax -> portion-syntax.num
- TestBadPortionSyntax -> bad-portion-syntax.num
- TestSource -> source.num
- TestAllocation -> allocation.num
- TestDynamicAllocation -> dynamic-allocation.num
- TestSendAll -> send-all.num
- TestSendAllWhenNegative -> send-all-when-negative.num
- TestSendAllWhenNegativeWithOverdraft -> send-all-negative-with-overdraft.num

All tests follow the specs.schema.json format and exclude grouped tests with multiple t.Run() calls.

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
Migrated tests:
- TestSendAllVariable -> send-all-variable.num
- TestSendAlltMaxWhenNoAmount -> send-all-max-when-no-amount.num
- TestNegativeMaxSendAll -> negative-max-send-all.num
- TestNegativeMax -> negative-max.num
- TestSendAllDestinatioAllot -> send-all-destination-allot.num
- TestSendAllDestinatioAllotComplex -> send-all-destination-allot-complex.num
- TestOverdraftInSendAll -> overdraft-in-send-all.num
- TestOverdraftInSendAllWhenNoop -> overdraft-in-send-all-when-noop.num
- TestSendAlltMaxInSrc -> send-all-max-in-src.num
- TestSendAlltMaxInDest -> send-all-max-in-dest.num
- TestManyMaxDest -> many-max-dest.num
- TestManyKeptDest -> many-kept-dest.num
- TestSendAllManyMaxInDest -> send-all-many-max-in-dest.num
- TestSendAllMulti -> send-all-multi.num
- TestInsufficientFunds -> insufficient-funds.num
- TestWorldSource -> world-source.num
- TestNoEmptyPostings -> no-empty-postings.num
- TestEmptyPostings -> empty-postings.num
- TestAllocateDontTakeTooMuch -> allocate-dont-take-too-much.num
- TestMetadata -> metadata.num
- TestTrackBalances -> track-balances.num
- TestTrackBalances2 -> track-balances2.num
- TestKeptInSendAllInorder -> kept-in-send-all-inorder.num
- TestRemainingKeptInSendAllInorder -> remaining-kept-in-send-all-inorder.num
- TestTrackBalancesSendAll -> track-balances-send-all.num
- TestTrackBalances3 -> track-balances3.num
- TestSourceAllotment -> source-allotment.num
- TestVariablePortionPart -> variable-portion-part.num
- TestSourceAllotmentInvalidAmt -> source-allotment-invalid-amt.num
- TestSourceOverlapping -> source-overlapping.num
- TestCappedWhenMoreThanBalance -> capped-when-more-than-balance.num
- TestCappedWhenLessThanNeeded -> capped-when-less-than-needed.num
- TestSourceComplex -> source-complex.num
- TestKeptInorder -> kept-inorder.num
- TestRemainingKeptInorder -> remaining-kept-inorder.num
- TestKeptWithBalance -> kept-with-balance.num
- TestRemainingNone -> remaining-none.num
- TestRemainingNoneInSendAll -> remaining-none-in-send-all.num
- TestDestinationComplex -> destination-complex.num
- TestSendZero -> send-zero.num
- TestBalance -> balance.num
- TestBalanceNotFound -> balance-not-found.num
- TestInoderDestination -> inorder-destination.num
- TestBalanceSimple -> balance-simple.num
- TestAskBalanceTwice -> ask-balance-twice.num

Skipped grouped tests and tests with non-MissingFundsErr errors as requested.
All files follow the specs.schema.json format.

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added 16 more test migrations with exact script copies
- Removed problematic big-int and invalid-number-literal tests with extremely long numbers
- All scripts copied exactly from interpreter_test.go without modifications

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added arithmetic operations: add-monetaries-same-currency, add-numbers, sub-numbers, sub-monetaries
- Added oneof feature tests: oneof-in-source, oneof-all-failing, oneof-in-send-all, oneof-singleton, oneof-destination-first-clause
- All scripts copied exactly from interpreter_test.go without modifications
- Skipped error tests that expect non-MissingFundsErr errors

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added oneof destination tests: oneof-destination-second-clause, oneof-destination-remaining-clause
- Added account interpolation test: account-interp
- Added midscript balance tests: midscript-balance, midscript-balance-after-decrease
- Added expression and function tests: expr-in-var-origin, get-asset-function, get-amount-function
- All scripts copied exactly from interpreter_test.go without modifications
- Skipped error tests that expect non-MissingFundsErr errors

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added color send tests: color-send, color-send-overdraft
- Added color balance restriction tests: color-restrict-balance, color-restrict-balance-when-missing-funds
- All scripts copied exactly from interpreter_test.go without modifications
- Continued systematic migration of remaining tests

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added color-restriction-in-send-all test
- Added color-inorder test with multiple color sources
- All scripts copied exactly from interpreter_test.go without modifications
- Continued systematic migration of remaining tests

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added color-inorder-send-all test
- Added no-double-spending-in-colored-send-all test
- Added no-double-spending-in-colored-send test
- Added empty-color test
- All scripts copied exactly from interpreter_test.go without modifications
- Continued systematic migration of remaining tests

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added color-with-asset-precision test
- Added update-balances test
- All scripts copied exactly from interpreter_test.go without modifications
- Continued systematic migration of remaining tests

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added update-balances-with-oneof test
- Added send-when-negative-balance test
- Added overdraft-when-negative-overdraft-in-send-all test
- Added overdraft-when-negative-balance-in-send-all test
- Added overdraft-when-negative-balance test
- Added do-not-exceed-overdraft test
- All scripts copied exactly from interpreter_test.go without modifications
- Continued systematic migration of remaining tests

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Added do-not-exceed-overdraft-on-send-all test
- Added do-not-exceed-overdraft-when-double-spending test
- All scripts copied exactly from interpreter_test.go without modifications
- Completed systematic migration of remaining valid tests

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Fixed script to use exact copy from TestZeroPostingsDestination
- Corrected JSON posting format to match original CaseResult.Postings
- Script now properly uses max [COIN 0] to @d1 with remaining to @D2
- Expected posting correctly shows COIN 100 from world to d2

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
…ons exactly

- zero-postings.num: use correct script with @A and @world sources, amount 100
- zero-postings-explicit-inorder.num: use correct script with @A, @b, @c sources, amount 0
- zero-postings-explicit-allotment.num: use correct script with 1/2 from @A and @b sources, amount 0

All scripts now match their corresponding test functions in interpreter_test.go exactly.

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
…ngs expected postings

- Fixed expect.postings to include proper posting object instead of empty array
- Posting now correctly shows asset: COIN, amount: 100, source: world, destination: dest
- Matches original CaseResult.Postings from TestZeroPostings function exactly

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
- Use EUR/2 asset instead of COIN
- Use @A account instead of @src
- Use @world as source instead of @src
- Update expected posting amounts and accounts to match original test

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
…ons exactly

- balance-simple.num: Use USD/2 asset and @alice account instead of COIN/@world
- balance-not-found.num: Use EUR/2 asset and @A account instead of COIN/@src
- Add proper expected postings for balance-simple test
- Both tests now match their original TestBalanceSimple and TestBalanceNotFound functions

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
…wice function

- Script uses COIN asset and @src account instead of EUR/2/@A
- Only one send statement as in original test
- Balance amount is 50 not 100
- Source is src not world in posting

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
…wice function

- Script uses USD/2 asset instead of COIN
- JSON specs updated to match with USD/2 asset and amount 10
- Now matches original TestAskBalanceTwice function exactly

Co-Authored-By: alessandro@formance.com <alessandro@formance.com>
@ascandone ascandone changed the base branch from main to feat/specs-format July 14, 2025 08:13
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 14, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • main

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/migrate-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.02%. Comparing base (f4fdd84) to head (c660580).

Additional details and impacted files
@@                  Coverage Diff                  @@
##           feat/specs-format      #75      +/-   ##
=====================================================
+ Coverage              65.98%   66.02%   +0.04%     
=====================================================
  Files                     39       39              
  Lines                   4662     4662              
=====================================================
+ Hits                    3076     3078       +2     
+ Misses                  1452     1451       -1     
+ Partials                 134      133       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Bug: Snapshot Fix Uses Incorrect Assertion Field

The fixSnapshot function incorrectly uses failedAssertion.Expected in its switch statement to identify the assertion type. This comparison is flawed as failedAssertion.Expected contains the expected value, not the assertion name. It should use failedAssertion.Assertion. Consequently, the attempt to update t.ExpectPostings with failedAssertion.Expected.([]interpreter.Posting) is also incorrect; failedAssertion.Expected is the string "expect.postings" in this context, causing a runtime panic. The snapshot should be updated using failedAssertion.Got.

internal/cmd/test.go#L71-L75

if t.It == testResult.Result.It {
switch failedAssertion.Expected {
case "expect.postings":
t.ExpectPostings = failedAssertion.Expected.([]interpreter.Posting)

Fix in CursorFix in Web


Bug: Test Failure Flag Inverts Logic

The isTestFailed flag, used to count failed test files, has inverted logic. It currently checks if any test case passed (tc.Pass), causing files with passing tests to be incorrectly marked as failed. It should check if any test case failed (!tc.Pass).

internal/cmd/test.go#L265-L272

// Count tests
isTestFailed := slices.ContainsFunc(out.Cases, func(tc specs_format.TestCaseResult) bool {
return tc.Pass
})
if isTestFailed {
failedTestFiles += 1
}

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

@ascandone ascandone force-pushed the feat/specs-format branch from 2293b4f to 5d93aca Compare July 16, 2025 10:12
@ascandone ascandone closed this Jul 16, 2025
@ascandone ascandone deleted the chore/migrate-tests branch October 2, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant