Skip to content
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

Tests #1

Closed
32 of 44 tasks
sebinsua opened this issue Dec 13, 2015 · 0 comments
Closed
32 of 44 tasks

Tests #1

sebinsua opened this issue Dec 13, 2015 · 0 comments
Assignees
Labels
Milestone

Comments

@sebinsua
Copy link
Owner

Write unit tests. Will potentially need yup-hyper-mock to help test the client, and to write Fs mocks for testing config.

Before I can finish writing the tests I need to refactor a few hinderances to this in the code.

  • get_transactions needs to a receive a from_date and to_date which are computed within the commands from an injected current_time.
  • In order to alter the server responses when testing each of the commands we will need to be able to inject TellerClients in.
  • Do not test main.
  • inquirer/ask:
    • can I instantiate a Question?
    • can I instantiate an Answer?
    • ask_question:
    • ask_questions:
      • Given a list of questions, only return an answer if one was typed in when prompted.
  • config (see: http://doc.rust-lang.org/std/io/struct.Cursor.html#examples):
    • get_config_path returns the correct path.
    • get_config_file return an Option<File> that is None if not found, and a file otherwise. (NOTE: Closing as not possible to test yet.)
    • get_config_file_to_write return an Result<File, StdIoError> that panics if permission is denied, and the result otherwise. (NOTE: Closing as not possible to test yet.)
    • read_config should return a Result<Config, ConfigError> and write_config a Result<(), ConfigError>.
  • cli/parse:
    • instantiate a CliArgs and then get_command_type with it to return a CommandType.
  • api:
    • api/client:
      • instantiate a TellerClient, Account and Transaction.
      • get_account returns an Account.
      • get_accounts returns a Vec<Account>.
      • get_transactions returns a Vec<Transaction>. Unable to test the timeframe thing easily, so ignore for now.
    • api/inform:
      • instantiate some Money.
      • get_account_balance should return some valid Money.
      • get_aggregates test that get_balances, get_incomings and get_outgoings return monthly absolute values with a currency from the current Account.
      • get_counterparties should return the grouped counterparties outgoing amounts for a particular timeframe.
      • get_incoming should return the Money of the sum of the positive transactions this month.
      • get_outgoing should return the Money of the absolute sum of the negative transactions this month.
      • get_transactions_with_currency should return a valid TransactionsWithCurrrency.

These tests will no longer be done as (1) testing exit codes is not that useful, and (2) perfect representation is not as important as actual computation (make more sense to see it with eyes, than to test spacing with code, etc.)

  • command for each test its represent_ and whether it can return 0 or 1 on network success/failure:
    • initialise.
    • list_accounts.
    • list_balances.
    • list_counterparties.
    • list_incomings.
    • list_outgoings.
    • list_transactions.
    • show_balance.
    • show_incoming.
    • show_outgoing.
    • show_usage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant