Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests... #11

Open
serayuzgur opened this issue Apr 17, 2017 · 3 comments
Open

tests... #11

serayuzgur opened this issue Apr 17, 2017 · 3 comments
Assignees
Milestone

Comments

@serayuzgur
Copy link
Owner

Since the dependencies are fixed and basic skeleton created it is the sweet spot for writing tests.

@serayuzgur serayuzgur added this to the 0.0.1-beta milestone Apr 17, 2017
serayuzgur added a commit that referenced this issue Apr 20, 2017
serayuzgur added a commit that referenced this issue Apr 20, 2017
@serayuzgur serayuzgur self-assigned this Apr 22, 2017
@kbukum
Copy link
Collaborator

kbukum commented May 2, 2017

I found a sollution for integration tests.
You can check this link for integration test.
integration_tests

I will complete integrations tests and push issue asap.

@kbukum
Copy link
Collaborator

kbukum commented May 2, 2017

@serayuzgur

I am thinking to change code like below.

// main.rs
#![warn(missing_docs)]
extern crate weld;
use weld::start_application;

fn main() {
   start_application();
}

moved all main code in lib.rs.

// lib.rs
#![warn(missing_docs)]
//! # Weld
//! Weld is a fake API generator for easily mocking back-end services.
//! It is heavily inspired from [JSON Server](https://github.com/typicode/json-server).
//! Weld also claims that you can create APIs with **zero coding** in less than **30 seconds**.
//! Providing a `db.json` file will generate crud operations, cascading manipulation and query parametric filter support.

extern crate hyper;
extern crate rand;
extern crate futures;
extern crate futures_cpupool;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[macro_use]
extern crate slog;
extern crate slog_term;
extern crate slog_async;
#[macro_use]
extern crate lazy_static;
extern crate time;

pub mod service;
pub mod server;
pub mod configuration;
pub mod database;
pub mod weld;

use server::Server;
use std::env::args;

pub fn start_application() {
    info!(weld::ROOT_LOGGER, "Application started";"started_at" => format!("{}", time::now().rfc3339()), "version" => env!("CARGO_PKG_VERSION"));

    load_config();

    load_db();

    start_server();
}

/// Loads configuration.
fn load_config() {
    let mut configuration = weld::CONFIGURATION.lock()
        .expect("Configuration is not accesible. Terminating...");

    //No arg ? so use default.
    if let Some(path) = args().nth(1) {
        configuration.load(path.as_str())
    } else {
        info!(weld::ROOT_LOGGER, "Program arguments not found.");
        configuration.load("weld.json");
    }
}

/// Loads database.
fn load_db() {
    let mut db = weld::DATABASE.lock().expect("Database is not accesible. Terminating...");
    db.load(&weld::CONFIGURATION.lock().unwrap().database);
}

/// Starts server.
fn start_server() {
    let config = weld::CONFIGURATION.lock().unwrap().server.clone();
    Server::new(&config).start();
}

what do you think about that ?

@serayuzgur
Copy link
Owner Author

Seems ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants