aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/package/root_alias_package_test.rs
blob: f168e1304611d82e7d1958269095b137541bc721 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! ref: composer/tests/Composer/Test/Package/RootAliasPackageTest.php

use indexmap::IndexMap;
use shirabe::package::{Link, RootAliasPackageHandle, RootPackageHandle};
use shirabe_semver::constraint::MatchAllConstraint;

fn links(link_type: &str) -> IndexMap<String, Link> {
    let mut map: IndexMap<String, Link> = IndexMap::new();
    map.insert(
        "b".to_string(),
        Link::new(
            "a".to_string(),
            "b".to_string(),
            MatchAllConstraint::new(None).into(),
            Some(link_type.to_string()),
            "self.version".to_string(),
        ),
    );
    map
}

fn alias() -> RootAliasPackageHandle {
    let root = RootPackageHandle::new(
        "something/something".to_string(),
        "1.0.0.0".to_string(),
        "1.0".to_string(),
    );
    RootAliasPackageHandle::new(root, "1.0".to_string(), "1.0.0.0".to_string())
}

#[test]
fn test_update_requires() {
    let alias = alias();
    assert!(alias.get_requires().is_empty());
    alias.set_requires(links(Link::TYPE_REQUIRE));
    assert!(!alias.get_requires().is_empty());
}

#[test]
#[ignore = "RootAliasPackage::set_dev_requires only updates alias_of, not the alias's own copy, so get_dev_requires stays empty"]
fn test_update_dev_requires() {
    let alias = alias();
    assert!(alias.get_dev_requires().is_empty());
    alias.set_dev_requires(links(Link::TYPE_DEV_REQUIRE));
    assert!(!alias.get_dev_requires().is_empty());
}

#[test]
#[ignore = "RootAliasPackage::set_conflicts only updates alias_of, not the alias's own copy, so get_conflicts stays empty"]
fn test_update_conflicts() {
    let alias = alias();
    assert!(alias.get_conflicts().is_empty());
    alias.set_conflicts(links(Link::TYPE_CONFLICT));
    assert!(!alias.get_conflicts().is_empty());
}

#[test]
#[ignore = "RootAliasPackage::set_provides only updates alias_of, not the alias's own copy, so get_provides stays empty"]
fn test_update_provides() {
    let alias = alias();
    assert!(alias.get_provides().is_empty());
    alias.set_provides(links(Link::TYPE_PROVIDE));
    assert!(!alias.get_provides().is_empty());
}

#[test]
#[ignore = "RootAliasPackage::set_replaces only updates alias_of, not the alias's own copy, so get_replaces stays empty"]
fn test_update_replaces() {
    let alias = alias();
    assert!(alias.get_replaces().is_empty());
    alias.set_replaces(links(Link::TYPE_REPLACE));
    assert!(!alias.get_replaces().is_empty());
}