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

Fix 887 and improve code coverage of R/config.R from 28.21% to 100% #1043

Merged
merged 11 commits into from
Aug 8, 2023

Commits on May 27, 2023

  1. fix: add user supplied path to config for guess_where_config()

    - add helper try_user_config_location()
        - search for new config location to be set inside R/app_config.R
    - update guess_where_config() with a final guess using this helper
    - run styler::style_file("R/config.R", transformers =
      grkstyle::grk_style_transformers())
    ilyaZar committed May 27, 2023
    Configuration menu
    Copy the full SHA
    31213b0 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    83a96a7 View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2023

  1. test: guess_where_config() works with path changes

    - path changes mean new dir and new filename so:
      - create a new dir for config
      - move config to that dir and rename
    
    => test correctly identifies changes (changing dir AND changing filename) in the yaml-config.
    
    attribute to @ALanguillaume with some minor tweaks
    
    Co-authored-by: ALanguillaume <[email protected]>
    ilyaZar and ALanguillaume committed Jun 5, 2023
    Configuration menu
    Copy the full SHA
    230b73d View commit details
    Browse the repository at this point in the history

Commits on Aug 3, 2023

  1. refactor: improve readability and logical of `try_user_config_locatio…

    …n()`
    
    - encapsulate finding the relevant lines in the config file into "guess_lines_to_config_file()"
        - function allows for multi-line/grk-style app_sys()-calls (if file path to long and must be put into next line)
        - has clearer and commented logic to find the lines
    - document proper logic of function with comments
    - style with `grkstyle::grk_style_transformer`
    - update `tests/testthat/test-config.R` to incorporate above changes and move code coverage of that file to 63.16%
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    8e98808 View commit details
    Browse the repository at this point in the history
  2. style: try_user_config_location() returns fs-paths for consistency

    - allows valid comparison with fs_path()'s inside guess_where_config() and output values from try_user_config_location()
    - fix a typo in a comment
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    90ee1ca View commit details
    Browse the repository at this point in the history
  3. refactor: improve readability and logic inside guess_where_config

    Why:
    
    - clearly outline the different cases: since now the user can add a golem-config, there can be conflicting cases between the default golem config and the user golem config (if e.g. the user forgets to delete the default)
    - update the tests to check these different cases
    - remark: test inside testthat should work without golem:: prefixes
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    a941ec1 View commit details
    Browse the repository at this point in the history
  4. test: add test for exotic corner cases of guess_where_config()

    - test that config file can be found if
       - we end up inside "inst/" (a corner case not tested before)
       - guess_where_config() is fed with argument values for 'path' and 'file' that do not work
    
    -> improves code coverage to 70.75%
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    095bfc5 View commit details
    Browse the repository at this point in the history
  5. feature: guess_where_config() fails a bit faster

    - remove last if-statement (which is almost a duplicate of the one before)
       -> this makes the guess_where_config() fail easier (i.e. return NULL) as other exotic corner cases should be handled more explicitly
    - remark: golem::pkg_path() will (almost) never produce an error but this may change so the try-construct within attempt() is kept
    
    - improve comments for corner case IV.B as internal developer note
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    3917328 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    f3e6cb2 View commit details
    Browse the repository at this point in the history
  7. test: move coverage of R/config.R to 100%

    - notably: add package mockery to Suggests (no dependencies except for testthat and used for tests only)
    
    - add tests for non-interactive usage of guess_where_config(): check that error is thrown correctly
    
    - add tests for interactive usage of guess_where_config():
        - user says yes: test that necessary files are created
        - user says no: test that we return NULL
    
    - add tests for encapsulated ask_golem_creation_upon_config()
        - shallow test as non-interactive menu() calls (inside the yesno()) are forbidden
        - but this makes code coverage 100% :)
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    caf682a View commit details
    Browse the repository at this point in the history
  8. docs: update docs for get_current_config()

    - only exported function from R/config.R needs proper docs
    - besides more details on older usage and behavior:
        - add docs on how to set user supplied golem config
        - add code snippets
    ilyaZar committed Aug 3, 2023
    Configuration menu
    Copy the full SHA
    6529474 View commit details
    Browse the repository at this point in the history