Skip to content

Commit

Permalink
chore: remove temp_test_dir dep
Browse files Browse the repository at this point in the history
  • Loading branch information
oknozor committed Mar 18, 2021
1 parent edf667f commit ba9bfd6
Show file tree
Hide file tree
Showing 10 changed files with 125 additions and 128 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ jobs:
toolchain: stable
override: true

- name: Coverage
uses: actions-rs/tarpaulin@v0.1
with:
args: -- --test-threads 1

- name: Test
uses: actions-rs/cargo@v1
continue-on-error: false
with:
command: test
args: -- --test-threads 1

- name: Coverage
uses: actions-rs/tarpaulin@v0.1
with:
args: -- --test-threads 1

- name: Upload to codecov.io
uses: codecov/codecov-action@v1.0.6
with:
Expand Down Expand Up @@ -77,4 +77,4 @@ jobs:
continue-on-error: false
with:
command: clippy
args: -- -D warnings
args: -- -D warnings
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ config = "^0"
itertools = "^0"
serde_derive = "^1"
serde = "^1"
tempdir = "^0"
tempfile = "^3"
semver = "^0"
shell-words = "^1"
which = "^4"
Expand All @@ -34,7 +34,6 @@ clap = { version = "^2", optional = true }
[dev-dependencies]
assert_cmd = "1.0.3"
predicates = "1"
temp_testdir = "0.2.3"
rand = "0.7.3"

[features]
Expand Down
22 changes: 11 additions & 11 deletions src/git/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ mod tests {
use std::ops::Not;
use std::path::PathBuf;
use std::process::Command;
use temp_testdir::TempDir;
use tempfile::TempDir;

#[test]
fn add_pre_commit_hook() -> Result<()> {
let temp = TempDir::default();
let temp = temp.to_path_buf();
let temp = TempDir::new()?;
let temp = temp.path().to_path_buf();
env::set_current_dir(&temp)?;

Command::new("git").arg("init").output()?;
Expand All @@ -89,8 +89,8 @@ mod tests {

#[test]
fn add_pre_push_hook() -> Result<()> {
let temp = TempDir::default();
let temp = temp.to_path_buf();
let tmp = TempDir::new()?;
let temp = tmp.path().to_path_buf();
env::set_current_dir(&temp)?;

Command::new("git").arg("init").output()?;
Expand All @@ -108,9 +108,9 @@ mod tests {

#[test]
fn add_all() -> Result<()> {
let temp = TempDir::default();
let temp = temp.to_path_buf();
env::set_current_dir(&temp)?;
let tmp = TempDir::new()?;
let tmp = tmp.path().to_path_buf();
env::set_current_dir(&tmp)?;

Command::new("git").arg("init").output()?;

Expand All @@ -128,9 +128,9 @@ mod tests {
fn should_have_perm_755_on_unix() -> Result<()> {
use std::os::unix::fs::PermissionsExt;

let temp = TempDir::default();
let temp = temp.to_path_buf();
env::set_current_dir(&temp)?;
let tmp = TempDir::new()?;
let tmp = tmp.path().to_path_buf();
env::set_current_dir(&tmp)?;

Command::new("git").arg("init").output()?;

Expand Down
100 changes: 50 additions & 50 deletions src/git/repository.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,23 @@ mod test {
use anyhow::Result;
use std::ops::Not;
use std::process::{Command, Stdio};
use temp_testdir::TempDir;
use tempfile::TempDir;

#[test]
fn init_repo() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let repo = Repository::init(&temp_testdir.join("test_repo"));
let repo = Repository::init(&tmp.path().join("test_repo"));

assert!(repo.is_ok());
Ok(())
}

#[test]
fn create_commit_ok() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -271,9 +271,9 @@ mod test {

#[test]
fn not_create_empty_commit() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;

assert!(repo.commit("feat: a test commit").is_err());
Expand All @@ -282,9 +282,9 @@ mod test {

#[test]
fn not_create_empty_commit_with_unstaged_changed() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;

Expand All @@ -294,9 +294,9 @@ mod test {

#[test]
fn get_repo_working_dir_some() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
let dir = &path.join("dir");
std::fs::create_dir(dir)?;
Expand All @@ -308,9 +308,9 @@ mod test {

#[test]
fn get_diff_some() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -321,9 +321,9 @@ mod test {

#[test]
fn get_diff_none() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;

Expand All @@ -333,9 +333,9 @@ mod test {

#[test]
fn get_diff_include_untracked_some() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;

Expand All @@ -345,9 +345,9 @@ mod test {

#[test]
fn get_diff_include_untracked_none() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;

assert!(repo.get_diff(true).is_none());
Expand All @@ -357,10 +357,10 @@ mod test {
// see: https://git-scm.com/book/en/v2/Git-on-the-Server-Getting-Git-on-a-Server
#[test]
fn open_bare_err() -> Result<()> {
let temp_testdir = TempDir::default();
std::env::set_current_dir(&temp_testdir)?;
let tmp = TempDir::new()?;
std::env::set_current_dir(&tmp)?;

let tmp = &temp_testdir.to_str().unwrap();
let tmp = &tmp.path().to_str().unwrap();

Command::new("git")
.arg("init")
Expand All @@ -377,9 +377,9 @@ mod test {

#[test]
fn get_repo_statuses_empty() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;

let statuses = repo.get_statuses()?;
Expand All @@ -390,9 +390,9 @@ mod test {

#[test]
fn get_repo_statuses_not_empty() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;

Expand All @@ -404,9 +404,9 @@ mod test {

#[test]
fn get_repo_head_oid_ok() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -421,9 +421,9 @@ mod test {

#[test]
fn get_repo_head_oid_err() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;

let oid = repo.get_head_commit_oid();
Expand All @@ -434,9 +434,9 @@ mod test {

#[test]
fn get_repo_head_obj_ok() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -451,9 +451,9 @@ mod test {

#[test]
fn get_repo_head_obj_err() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -466,9 +466,9 @@ mod test {

#[test]
fn resolve_lightweight_tag_ok() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -483,9 +483,9 @@ mod test {

#[test]
fn resolve_lightweight_tag_err() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -500,9 +500,9 @@ mod test {

#[test]
fn get_latest_tag_ok() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -523,9 +523,9 @@ mod test {

#[test]
fn get_latest_tag_err() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -539,9 +539,9 @@ mod test {

#[test]
fn get_latest_tag_oid_ok() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -556,9 +556,9 @@ mod test {

#[test]
fn get_latest_tag_oid_err() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -572,9 +572,9 @@ mod test {

#[test]
fn get_head_some() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand All @@ -588,9 +588,9 @@ mod test {

#[test]
fn get_head_none() -> Result<()> {
let temp_testdir = TempDir::default();
let tmp = TempDir::new()?;

let path = temp_testdir.join("test_repo");
let path = tmp.path().join("test_repo");
let repo = Repository::init(&path)?;
std::fs::write(&path.join("file"), "changes")?;
repo.add_all()?;
Expand Down

0 comments on commit ba9bfd6

Please sign in to comment.