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

Proposal for unit & integration testing #1

Merged
merged 24 commits into from
Oct 13, 2021
Merged

Proposal for unit & integration testing #1

merged 24 commits into from
Oct 13, 2021

Commits on Oct 10, 2021

  1. Draft: proposal for unit & integration testing

    There's a lot going on, and I haven't documented any of it. But the idea
    is to be able to do unit tests without relying on real git, since it
    could be slow, use the network, or impact local state.
    
    So `cargo test --lib` will use mostly in-memory tests, reaching out to
    fake git binaries when necessary. The Integration tests (under the
    `tests/` folder) will run against the real git binary, and may do things
    like authenticate to remote hosts or create / remove branches.
    robertdfrench committed Oct 10, 2021
    Configuration menu
    Copy the full SHA
    76b5fd0 View commit details
    Browse the repository at this point in the history
  2. Fixes #3: Rewrite fake_git in Rust

    * Rewrote fake_git sh scripts in Rust
    * Moved all executables to src/bin & removed from TOML
    * Updated tests to use new exes
    J. Caleb Wherry committed Oct 10, 2021
    Configuration menu
    Copy the full SHA
    e187ac1 View commit details
    Browse the repository at this point in the history
  3. Move with_path impl to tests module. Fixes #4.

    I wasn't 100% sure this would work at first, but you can split an `impl`
    block up over multiple sections. So since `with_path` doesn't need to be
    defined for the `Git` struct in application code, I moved it into the
    `test` module instead.
    
    If you don't do something like this, then marking `with_path` as private
    will generate a warning, since no other application code (even within
    its own module) uses it.
    
    Two alternative approaches:
    * Leave `with_path` where it is, but mark it as `#[cfg(test)]`
    * Change `new` to call `with_path`, so that `with_path` is used by something.
    robertdfrench committed Oct 10, 2021
    Configuration menu
    Copy the full SHA
    956844e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    52c2d23 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    234cec3 View commit details
    Browse the repository at this point in the history

Commits on Oct 11, 2021

  1. Custom error type for git invocations. Fixes #5.

    Invoking git either raises an `io::Error` or returns a
    `std::process::ExitStatus`, the `success()` method of which may return
    `false`. The new type, `GitError`, is designed to encompass both of
    these cases and should simplify error handling when interacting with git
    subprocesses.
    robertdfrench committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    5f90c9f View commit details
    Browse the repository at this point in the history
  2. Comment out Cargo.lock in gitignore. Fixes #12.

    Commented Cargo.lock from gitignore so that we have a record
    of why we did it. I think something like this is easy to forget
    so leaving it along with the original comment makes sense.
    
    Adding the version of Cargo.lock I get running on MacOs.
    J. Caleb Wherry committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    70661fd View commit details
    Browse the repository at this point in the history
  3. Simplify pattern matching in fake_git. Fixes #13.

    J. Caleb Wherry committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    625c00d View commit details
    Browse the repository at this point in the history
  4. Replace OsString/Path with String. Fixes #11.

    J. Caleb Wherry committed Oct 11, 2021
    Configuration menu
    Copy the full SHA
    7e42b1f View commit details
    Browse the repository at this point in the history

Commits on Oct 12, 2021

  1. Give rough overview in README

    We can add build/release/platform info once we have CI set up (see #2).
    robertdfrench committed Oct 12, 2021
    Configuration menu
    Copy the full SHA
    f5e9c5d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a436994 View commit details
    Browse the repository at this point in the history

Commits on Oct 13, 2021

  1. Match anything but '/' for origin name. Fixes #6.

    As @calebwherry said in the original issue:
    
    > Using origin can cause issues with others not using that wordage.
    > Replace with "not slash" match as it can be anything.
    
    I tried to be clever and match hyphenated words, but then I tried to
    look up the actual definition of a remote name, and there does not seem
    to be one: https://stackoverflow.com/questions/41461152/which-characters-are-illegal-within-a-git-remote-name/41462742
    
    So, it seems like the best thing to do is detect whatever isn't a slash,
    because we know those *can't* be allowed, since they are allowed in
    branch names (and therefore any ref with slashes in the remote or
    branch would parse ambiguously). Whatever else git tells us is obviously
    valid, since git is the authority here.
    robertdfrench committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    c0a8dae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    fc69b49 View commit details
    Browse the repository at this point in the history
  3. Test in release mode!

    robertdfrench committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    12704d2 View commit details
    Browse the repository at this point in the history
  4. Add more prints in GitHub YAML for debugging

    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    985096a View commit details
    Browse the repository at this point in the history
  5. More debugging for PR failure

    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    aa25626 View commit details
    Browse the repository at this point in the history
  6. Add setup repo step in GH actions yml. Fixes #17

    GitHub checks out the repo in a detached head state. We use
    a trick noted in the task to fix it.
    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    9943f2b View commit details
    Browse the repository at this point in the history
  7. Add setup repo step in GH actions yml. Fixes #17

    GitHub checks out the repo in a detached head state. We use
    a trick noted in the task to fix it.
    
    Try 2...
    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    0025909 View commit details
    Browse the repository at this point in the history
  8. Add setup repo step in GH actions yml. Fixes #17

    GitHub checks out the repo in a detached head state. We use
    a trick noted in the task to fix it.
    
    Try 3...
    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    022dc6d View commit details
    Browse the repository at this point in the history
  9. Print statment to help debug this more...

    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    f0513fc View commit details
    Browse the repository at this point in the history
  10. Undo debugging for now...

    J. Caleb Wherry committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    ce0145f View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    7efa1ba View commit details
    Browse the repository at this point in the history
  12. Include tempdir crate

    Found by @calebwherry.
    robertdfrench committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    1756869 View commit details
    Browse the repository at this point in the history
  13. Setup git config name and email

    So we can commit!
    robertdfrench committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    748b183 View commit details
    Browse the repository at this point in the history