Skip to content

Commit

Permalink
add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yeastplume committed Jun 4, 2020
1 parent da4c3dc commit cc01221
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 0 deletions.
64 changes: 64 additions & 0 deletions tests/cmd_line_basic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright 2020 Revcore Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Test wallet command line works as expected
#[macro_use]
extern crate clap;

#[macro_use]
extern crate log;

use aloevera::Error;

mod common;
use common::{clean_output_dir, execute_command, setup};

#[test]
fn command_line_basic() -> Result<(), Error> {
let test_dir = "target/test_output/command_line_basic";
setup(test_dir);
let project_file = format!("{}/testproject.av", test_dir);
load_app!(app);

// Create Project
let arg_vec = vec!["aloevera", "create", "project", &project_file];
execute_command(&app, arg_vec)?;

// Import palette
let arg_vec = vec![
"aloevera",
"-p",
&project_file,
"palette",
"import",
"tile_wall_pal",
"tests/data/input/imageset-4bpp.png",
];
execute_command(&app, arg_vec)?;

// Output palette and check formats
let arg_vec = vec![
"aloevera",
"-p",
&project_file,
"asm",
"-f",
"bin",
"tests/data/input/imageset-4bpp.png",
];
execute_command(&app, arg_vec)?;

clean_output_dir(test_dir);
Ok(())
}
44 changes: 44 additions & 0 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2020 Revcore Technologies Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Common functions for integration tests
use clap::App;
use std::fs;

use aloevera::cmd;
use aloevera::Error;
use aloevera_util as util;

pub fn clean_output_dir(test_dir: &str) {
let _ = fs::remove_dir_all(test_dir);
}

pub fn setup(test_dir: &str) {
util::init_test_logger();
clean_output_dir(test_dir);
let _ = fs::create_dir_all(test_dir);
}

pub fn execute_command(app: &App, arg_vec: Vec<&str>) -> Result<String, Error> {
let args = app.clone().get_matches_from(arg_vec);
cmd::execute::execute_command(&args)
}

#[macro_export]
macro_rules! load_app {
($app: ident) => {
let yml = load_yaml!("../src/bin/aloevera.yml");
let $app = clap::App::from_yaml(yml);
};
}
Binary file added tests/data/input/imageset-4bpp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cc01221

Please sign in to comment.