This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Opens chrome once the server starts | |
async fn open_web_app(url: &str) -> () { | |
use std::process::Command; | |
let mut cmd = Command::new("open"); | |
cmd.arg("-a") | |
.arg("Google Chrome") | |
.arg(format!("http://{}", url)) | |
.spawn() | |
.expect("failed to spawn child"); | |
println!("{}", url) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn init_routes(config: &mut web::ServiceConfig) { | |
config.service(test_route); | |
config.service(static_files()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use crate::server::routes::AppState; | |
use crate::server; | |
use actix_web::dev::Server; | |
use actix_web::{App, HttpServer}; | |
// Starts the server with wanted configuration and shared state | |
async fn start_server(results_count: usize, server_address: &str) -> Result<Server, std::io::Error> { | |
let server = HttpServer::new(move || { | |
App::new().data(AppState { | |
results_count, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub async fn serve_report(results_count: usize) -> std::io::Result<()> { | |
let server_address = "127.0.0.1:8080"; //todo: move to config.json | |
let server = start_server(results_count, server_address).await?; | |
tokio::join!(server, open_web_app(server_address)); | |
Ok(()) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[actix_web::main] | |
async fn main() -> std::io::Result<()> { | |
let results = run_tsttgen().await?; | |
serve_report(results).await | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn new(suites_map: HashMap<String, Vec<String>>) -> Self { // builder | |
Self { suites_map } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
counter = 0; | |
constructor() { | |
interval(100) | |
.pipe( | |
tap(() => this.counter++), | |
takeWhile(() => this.counter < 100) | |
) | |
.subscribe(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Fake remove file | |
function remove(filename: string) { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve(); | |
}, 300); | |
}); | |
} | |
interface FileRemoveInteractorImpl { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
createTagsForTest$(count = 5): Observable<any[]> { | |
const rndName = btoa(String(Math.random())).substr(5, 5); // generate random string as tag name | |
const usersObs$ = [...Array(count).keys()].map((_) => createTag$(rndName)); // create an array of http requests as observables | |
return forkJoin(usersObs$) // will subscribe to each of the inner observables and when all complete will emit a list of results | |
.pipe(catchError(error => of(error))); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Observable, from} from 'rxjs'; | |
import { tap } from 'rxjs/operators'; | |
//Similar to native JS 'some' method, | |
//if at least one value pass predicate emit true, else false | |
function some(predicate: Function) { | |
return function <T>(source: Observable<T>):Observable<Boolean>{ | |
return new Observable(subscriber => { | |
return source.subscribe({ |