2020-05-17 21:52:39 +02:00
|
|
|
// This Source Code Form is subject to the terms of
|
|
|
|
|
// the Mozilla Public License, v. 2.0. If a copy of the
|
|
|
|
|
// MPL was not distributed with this file, You can
|
|
|
|
|
// obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
2020-05-17 01:17:19 +02:00
|
|
|
mod actions;
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
|
|
use crate::actions::Manifest;
|
2020-05-18 10:32:16 +02:00
|
|
|
use crate::actions::{parse_manifest_string, Attr};
|
2020-05-17 22:02:35 +02:00
|
|
|
use std::collections::HashSet;
|
2020-05-17 01:17:19 +02:00
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn parse_manifest() {
|
|
|
|
|
let manifest_string = String::from("set name=pkg.fmri value=pkg://openindiana.org/web/server/nginx@1.18.0,5.11-2020.0.1.0:20200421T195136Z
|
|
|
|
|
set name=com.oracle.info.name value=nginx value=test
|
|
|
|
|
set name=userland.info.git-remote value=git://github.com/OpenIndiana/oi-userland.git
|
|
|
|
|
set name=userland.info.git-branch value=HEAD
|
|
|
|
|
set name=userland.info.git-rev value=1665491ba61bd494bf73e2916cd2250f3024260e
|
|
|
|
|
set name=pkg.summary value=\"Nginx Webserver\"
|
|
|
|
|
set name=info.classification value=\"org.opensolaris.category.2008:Web Services/Application and Web Servers\"
|
|
|
|
|
set name=info.upstream-url value=http://nginx.net/
|
|
|
|
|
set name=info.source-url value=http://nginx.org/download/nginx-1.18.0.tar.gz
|
|
|
|
|
set name=org.opensolaris.consolidation value=userland
|
|
|
|
|
set name=com.oracle.info.version value=1.18.0
|
|
|
|
|
set name=variant.arch value=i386");
|
2020-05-18 10:32:16 +02:00
|
|
|
let test_results = vec![
|
2020-05-17 21:52:39 +02:00
|
|
|
Attr{
|
|
|
|
|
key: String::from("pkg.fmri"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("pkg://openindiana.org/web/server/nginx@1.18.0,5.11-2020.0.1.0:20200421T195136Z")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("com.oracle.info.name"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("nginx"), String::from("test")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("userland.info.git-remote"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("git://github.com/OpenIndiana/oi-userland.git")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("userland.info.git-branch"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("HEAD")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("userland.info.git-rev"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("1665491ba61bd494bf73e2916cd2250f3024260e")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("pkg.summary"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("Nginx Webserver")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("info.classification"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("org.opensolaris.category.2008:Web Services/Application and Web Servers")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("info.upstream-url"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("http://nginx.net/")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("info.source-url"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("http://nginx.org/download/nginx-1.18.0.tar.gz")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("org.opensolaris.consolidation"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("userland")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("com.oracle.info.version"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("1.18.0")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
},
|
|
|
|
|
Attr{
|
|
|
|
|
key: String::from("variant.arch"),
|
2020-05-17 22:02:35 +02:00
|
|
|
values: vec![String::from("i386")],
|
|
|
|
|
properties: HashSet::new(),
|
2020-05-17 21:52:39 +02:00
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
2020-05-18 10:32:16 +02:00
|
|
|
let mut manifest = Manifest::new();
|
|
|
|
|
match parse_manifest_string(manifest_string) {
|
2020-05-17 01:17:19 +02:00
|
|
|
Ok(m) => manifest = m,
|
2020-05-18 10:32:16 +02:00
|
|
|
Err(_) => assert!(false, "caught error"),
|
2020-05-17 01:17:19 +02:00
|
|
|
};
|
2020-05-17 21:52:39 +02:00
|
|
|
assert_eq!(manifest.attributes.len(), 12);
|
|
|
|
|
for (pos, attr) in manifest.attributes.iter().enumerate() {
|
2020-05-18 10:32:16 +02:00
|
|
|
assert_eq!(attr.key, test_results[pos].key);
|
2020-05-17 21:52:39 +02:00
|
|
|
for (vpos, val) in attr.values.iter().enumerate() {
|
2020-05-18 10:32:16 +02:00
|
|
|
assert_eq!(val, &test_results[pos].values[vpos]);
|
2020-05-17 01:17:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|