aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/config/json_config_source_test.rs
blob: bab36a9ba32c86d5e7147f99f7aca688e4f06faf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! ref: composer/tests/Composer/Test/Config/JsonConfigSourceTest.php

use shirabe::util::filesystem::Filesystem;
use std::path::PathBuf;
use tempfile::TempDir;

fn set_up() -> TearDown {
    let fs = Filesystem::new(None);
    // getUniqueTmpDirectory creates a fresh unique temp directory.
    let working_dir = TempDir::new().unwrap();
    TearDown { fs, working_dir }
}

struct TearDown {
    fs: Filesystem,
    working_dir: TempDir,
}

impl TearDown {
    fn working_dir(&self) -> PathBuf {
        self.working_dir.path().to_path_buf()
    }
}

impl Drop for TearDown {
    fn drop(&mut self) {
        let working_dir = self.working_dir.path();
        if working_dir.is_dir() {
            self.fs.remove_directory(working_dir).unwrap();
        }
    }
}

// JsonConfigSource edits composer.json through JsonManipulator, whose text-rewriting
// operations reach addcslashes (todo!()) in the php-shim.
macro_rules! stub {
    ($name:ident) => {
        #[test]
        #[ignore = "JsonConfigSource uses JsonManipulator, which reaches addcslashes (todo!()) in the php-shim"]
        fn $name() {
            let _tear_down = set_up();
            todo!()
        }
    };
}

stub!(test_add_repository);
stub!(test_add_repository_as_list);
stub!(test_add_repository_with_options);
stub!(test_remove_repository);
stub!(test_add_packagist_repository_with_false_value);
stub!(test_remove_packagist);
stub!(test_add_link);
stub!(test_remove_link);