Skip to content
Snippets Groups Projects
Commit 996d49cf authored by Éloïs's avatar Éloïs
Browse files

[tests] module: create ModuleTest for tests that need a DursModule

parent 4dca5d00
No related branches found
No related tags found
1 merge request!256load conf from env vars as a priority
...@@ -24,3 +24,4 @@ serde_json = "1.0.*" ...@@ -24,3 +24,4 @@ serde_json = "1.0.*"
structopt= "0.3.4" structopt= "0.3.4"
[features] [features]
module-test = []
// Copyright (C) 2017-2019 The AXIOM TEAM Association.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! Define a test module for automated tests
use crate::*;
use std::marker::PhantomData;
/// Module test
#[derive(Debug)]
pub struct ModuleTest<DC: DursConfTrait, M: ModuleMessage> {
phantom: PhantomData<DC>,
phantom2: PhantomData<M>,
}
/// Module test user config
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct ModuleTestUserConf {
/// Field 1
pub field1: Option<String>,
/// Field 2
pub field2: Option<usize>,
}
impl Merge for ModuleTestUserConf {
fn merge(self, other: Self) -> Self {
ModuleTestUserConf {
field1: self.field1.or(other.field1),
field2: self.field2.or(other.field2),
}
}
}
/// Module test config
#[derive(Clone, Debug, Default, Deserialize, PartialEq)]
pub struct ModuleTestConf {
field1: String,
field2: usize,
}
#[derive(StructOpt, Debug, Clone)]
#[structopt(name = "test", setting(structopt::clap::AppSettings::ColoredHelp))]
/// Gva subcommand options
pub struct ModuleTestOpt {
/// Field
#[structopt(long = "field")]
pub field: Option<String>,
}
impl<DC: DursConfTrait, M: ModuleMessage> DursModule<DC, M> for ModuleTest<DC, M> {
type ModuleConf = ModuleTestConf;
type ModuleUserConf = ModuleTestUserConf;
type ModuleOpt = ModuleTestOpt;
fn name() -> ModuleStaticName {
ModuleStaticName("module_test")
}
fn priority() -> ModulePriority {
ModulePriority::Recommended
}
fn ask_required_keys() -> RequiredKeys {
RequiredKeys::None
}
fn have_subcommand() -> bool {
false
}
fn generate_module_conf(
_currency_name: Option<&CurrencyName>,
_global_conf: &<DC as DursConfTrait>::GlobalConf,
_module_user_conf: Option<Self::ModuleUserConf>,
) -> Result<(Self::ModuleConf, Option<Self::ModuleUserConf>), ModuleConfError> {
Ok((
ModuleTestConf::default(),
Some(ModuleTestUserConf::default()),
))
}
fn exec_subcommand(
_soft_meta_datas: &SoftwareMetaDatas<DC>,
_keys: RequiredKeysContent,
_module_conf: Self::ModuleConf,
_module_user_conf: Option<Self::ModuleUserConf>,
_subcommand_args: Self::ModuleOpt,
) -> Option<Self::ModuleUserConf> {
unimplemented!()
}
fn start(
_soft_meta_datas: &SoftwareMetaDatas<DC>,
_keys: RequiredKeysContent,
_conf: Self::ModuleConf,
_router_sender: std::sync::mpsc::Sender<RouterThreadMessage<M>>,
) -> Result<(), failure::Error> {
unimplemented!()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment