Skip to content

Commit

Permalink
rename rest and graphql methods and clean up tests
Browse files Browse the repository at this point in the history
clean clippy
  • Loading branch information
dkijania committed Jul 6, 2020
1 parent 7b8c5bd commit 90c63da
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 13 deletions.
12 changes: 6 additions & 6 deletions vit-servicing-station-tests/src/common/server.rs
Expand Up @@ -12,22 +12,22 @@ impl Server {
Self { process, settings }
}

pub fn rest(&self) -> RestClient {
pub fn rest_client(&self) -> RestClient {
RestClient::new(self.settings.address.to_string())
}

pub fn rest_with_token(&self, hash: String) -> RestClient {
let mut rest_client = self.rest();
pub fn rest_client_with_token(&self, hash: String) -> RestClient {
let mut rest_client = self.rest_client();
rest_client.set_api_token(hash);
rest_client
}

pub fn graphql(&self) -> GraphqlClient {
pub fn graphql_client(&self) -> GraphqlClient {
GraphqlClient::new(self.settings.address.to_string())
}

pub fn graphql_with_token(&self, hash: String) -> GraphqlClient {
let mut graphql_client = self.graphql();
pub fn graphql_client_with_token(&self, hash: String) -> GraphqlClient {
let mut graphql_client = self.graphql_client();
graphql_client.set_api_token(hash);
graphql_client
}
Expand Down
2 changes: 0 additions & 2 deletions vit-servicing-station-tests/src/common/startup/db.rs
Expand Up @@ -7,8 +7,6 @@ use std::str::FromStr;
use thiserror::Error;
use vit_servicing_station_lib::db::models::{api_tokens::APITokenData, proposals::Proposal};

use std::fs;

use crate::common::{
db::{DbInserter, DbInserterError},
paths::MIGRATION_DIR,
Expand Down
1 change: 1 addition & 0 deletions vit-servicing-station-tests/src/tests/graphql/mod.rs
@@ -0,0 +1 @@
pub mod proposals;
Expand Up @@ -2,8 +2,11 @@ use crate::common::startup::quick_start;
use assert_fs::TempDir;

#[test]
pub fn graphql_sanity_test() {
pub fn get_proposals_by_id() {
let temp_dir = TempDir::new().unwrap();
let (server, token) = quick_start(&temp_dir);
assert!(server.graphql_with_token(token).proposal_by_id(1).is_ok());
assert!(server
.graphql_client_with_token(token)
.proposal_by_id(1)
.is_ok());
}
2 changes: 1 addition & 1 deletion vit-servicing-station-tests/src/tests/mod.rs
@@ -1,2 +1,2 @@
pub mod bootstrap;
pub mod graphql;
pub mod rest;
1 change: 1 addition & 0 deletions vit-servicing-station-tests/src/tests/rest/mod.rs
@@ -0,0 +1 @@
pub mod proposals;
Expand Up @@ -2,11 +2,11 @@ use crate::common::startup::quick_start;
use assert_fs::TempDir;

#[test]
pub fn rest_sanity_test() {
pub fn get_proposals_list_is_not_empty() {
let temp_dir = TempDir::new().unwrap();
let (server, hash) = quick_start(&temp_dir);
let proposals = server
.rest_with_token(hash)
.rest_client_with_token(hash)
.proposals()
.expect("cannot get proposals");
assert!(proposals.len() > 0);
Expand Down

0 comments on commit 90c63da

Please sign in to comment.