parent
37ae67bd1c
commit
56bdb3bac7
24 changed files with 266 additions and 164 deletions
@ -1,26 +0,0 @@ |
||||
.PHONY: _pre_build debug release run clean unit integration test |
||||
|
||||
CARGO=./scripts/cargo_musl.sh
|
||||
|
||||
clean: |
||||
${CARGO} clean
|
||||
|
||||
_pre_build: |
||||
docker build -t unki/musllibs ./muslrust
|
||||
|
||||
debug: _pre_build |
||||
${CARGO} build
|
||||
|
||||
release: _pre_build |
||||
${CARGO} build --release
|
||||
|
||||
run: build |
||||
${CARGO} run
|
||||
|
||||
unit: |
||||
${CARGO} test --lib
|
||||
|
||||
integration: |
||||
cd ./integration && ./integration_tests.sh
|
||||
|
||||
test: unit integration |
@ -0,0 +1,48 @@ |
||||
[config] |
||||
default_to_workspace = false
|
||||
|
||||
[env] |
||||
CARGO = "./scripts/cargo_musl.sh"
|
||||
|
||||
[tasks.build_cargo_image] |
||||
script = "docker build -t unki/musllibs ./muslrust"
|
||||
|
||||
[tasks.clean] |
||||
command = "${CARGO}"
|
||||
args = ["clean"]
|
||||
|
||||
[tasks.debug] |
||||
dependencies = ["build_cargo_image"]
|
||||
command = "${CARGO}"
|
||||
args = ["build"]
|
||||
|
||||
[tasks.release] |
||||
dependencies = ["build_cargo_image"]
|
||||
command = "${CARGO}"
|
||||
args = ["build", "--release"]
|
||||
|
||||
[tasks.run] |
||||
script = '''
|
||||
echo "Only integration tests are supported." |
||||
exit 1 |
||||
''' |
||||
|
||||
[tasks.unit] |
||||
command = "${CARGO}"
|
||||
args = ["test", "--lib", "${@}"]
|
||||
|
||||
[tasks.integration] |
||||
script = '''
|
||||
cd ./integration |
||||
bash integration_tests.sh |
||||
''' |
||||
|
||||
[tasks.gen_schema] |
||||
script = '''
|
||||
cd ./integration |
||||
docker-compose up -d u_server |
||||
docker-compose down |
||||
''' |
||||
|
||||
[tasks.test] |
||||
dependencies = ["unit", "integration"]
|
@ -0,0 +1,35 @@ |
||||
use crate::models::schema::*; |
||||
use diesel::{Insertable, Queryable}; |
||||
use serde::{Deserialize, Serialize}; |
||||
use std::time::SystemTime; |
||||
use uuid::Uuid; |
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Queryable, Insertable, PartialEq)] |
||||
#[table_name = "errors"] |
||||
pub struct AgentError { |
||||
pub agent_id: Uuid, |
||||
pub created: SystemTime, |
||||
pub id: Uuid, |
||||
pub msg: String, |
||||
} |
||||
|
||||
impl AgentError { |
||||
pub fn from_msg(msg: impl Into<String>, agent_id: Uuid) -> Self { |
||||
AgentError { |
||||
agent_id, |
||||
msg: msg.into(), |
||||
..Default::default() |
||||
} |
||||
} |
||||
} |
||||
|
||||
impl Default for AgentError { |
||||
fn default() -> Self { |
||||
Self { |
||||
agent_id: Uuid::new_v4(), |
||||
created: SystemTime::now(), |
||||
id: Uuid::new_v4(), |
||||
msg: String::new(), |
||||
} |
||||
} |
||||
} |
@ -1,13 +1,6 @@ |
||||
mod agent; |
||||
pub mod jobs; |
||||
mod errors; |
||||
mod jobs; |
||||
pub mod schema; |
||||
|
||||
pub use crate::models::{agent::*, jobs::*}; |
||||
use serde::{Deserialize, Serialize}; |
||||
|
||||
#[derive(Serialize, Deserialize, Clone, PartialEq)] |
||||
pub enum ExecResult { |
||||
Assigned(AssignedJob), |
||||
Agent(Agent), |
||||
Dummy, |
||||
} |
||||
pub use crate::models::{agent::*, errors::*, jobs::*}; |
||||
|
Loading…
Reference in new issue