Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
996d49cf
Commit
996d49cf
authored
5 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[tests] module: create ModuleTest for tests that need a DursModule
parent
4dca5d00
No related branches found
No related tags found
1 merge request
!256
load conf from env vars as a priority
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/core/module/Cargo.toml
+1
-0
1 addition, 0 deletions
lib/core/module/Cargo.toml
lib/core/module/src/module_test.rs
+106
-0
106 additions, 0 deletions
lib/core/module/src/module_test.rs
with
107 additions
and
0 deletions
lib/core/module/Cargo.toml
+
1
−
0
View file @
996d49cf
...
@@ -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
=
[]
This diff is collapsed.
Click to expand it.
lib/core/module/src/module_test.rs
0 → 100644
+
106
−
0
View file @
996d49cf
// 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!
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment