This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP #60 start converting executor to work on task-lists
- Loading branch information
Showing
8 changed files
with
161 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2016 Snowplow Analytics Ltd. All rights reserved. | ||
* | ||
* This program is licensed to you under the Apache License Version 2.0, and | ||
* you may not use this file except in compliance with the Apache License | ||
* Version 2.0. You may obtain a copy of the Apache License Version 2.0 at | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the Apache License Version 2.0 is distributed on an "AS | ||
* IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | ||
* implied. See the Apache License Version 2.0 for the specific language | ||
* governing permissions and limitations there under. | ||
*/ | ||
|
||
use factotum::tests::make_task; | ||
use factotum::factfile::*; | ||
use factotum::executor::*; | ||
|
||
#[test] | ||
fn get_task_execution_list_good() { | ||
let mut ff = Factfile::new("test"); | ||
ff.add_task_obj(&make_task("apple", &vec![])); | ||
ff.add_task_obj(&make_task("turnip", &vec![])); | ||
ff.add_task_obj(&make_task("orange", &vec!["apple"])); | ||
ff.add_task_obj(&make_task("egg", &vec!["apple"])); | ||
ff.add_task_obj(&make_task("potato", &vec!["apple", "egg"])); | ||
ff.add_task_obj(&make_task("chicken", &vec!["potato","orange"])); | ||
|
||
// apple---------- turnip | ||
// / \ \ | ||
// orange egg----- \ | ||
// \ \ \ | ||
// \ potato | ||
// \ \ | ||
// --------------- chicken | ||
|
||
let tl = get_task_execution_list(&ff, None); | ||
|
||
let expected = vec![ vec!["turnip", "apple"], | ||
vec!["egg", "orange"], | ||
vec!["potato"], | ||
vec!["chicken"] ]; | ||
|
||
let actual:Vec<Vec<String>> = tl.tasks | ||
.iter() | ||
.map(|task_group| task_group.iter().map(|task| task.name.clone()).collect()) | ||
.collect(); | ||
|
||
assert_eq!(actual, expected); | ||
|
||
// check the children are correctly mapped | ||
|
||
assert_eq!(tl.get_descendants("turnip"), Vec::<String>::new()); | ||
assert_eq!(tl.get_descendants("apple"), vec!["chicken", "egg", "orange", "potato"]); | ||
assert_eq!(tl.get_descendants("egg"), vec!["chicken", "potato"]); | ||
assert_eq!(tl.get_descendants("orange"), vec!["chicken"]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters