Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
FelipeRosa committed Feb 8, 2023
1 parent beb7bad commit 9f14f62
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-tests-n-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
image: postgres:15
env:
POSTGRES_PASSWORD: 123456
LC_ALL: C # string sorting in tests expect this
options:
>-
--health-cmd pg_isready
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ jobs:
image: postgres:15
env:
POSTGRES_PASSWORD: 123456
LC_ALL: C # string sorting in tests expect this
options:
>-
--health-cmd pg_isready
Expand Down
4 changes: 2 additions & 2 deletions src/election-db/migrations/2022-12-01-043118_vit-ss/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Do not use this VIEW for new queries, its ONLY for backward compatibility.';
-- VIT-SS Compatibility View - api_tokens table.

CREATE VIEW api_tokens AS SELECT
DECODE(config.id2, 'base64') AS token,
DECODE(config.id2, 'base64')::BYTEA AS token,
(config.value->'created')::BIGINT AS creation_time,
(config.value->'expires')::BIGINT AS expire_time
FROM config
Expand Down Expand Up @@ -240,7 +240,7 @@ COMMENT ON COLUMN votes.raw_fragment is 'TODO';

CREATE TABLE snapshots (
tag TEXT PRIMARY KEY,
last_updated TIMESTAMP NOT NULL
last_updated BIGINT NOT NULL
);

COMMENT ON TABLE snapshots IS 'Something to do with snapshots. VIT-SS Compatibility Table, to be replaced when analysis completed.';
Expand Down
5 changes: 2 additions & 3 deletions src/election-db/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ diesel::table! {
tag -> Text,
/// The `last_updated` column of the `snapshots` table.
///
/// Its SQL type is `Timestamp`.
/// Its SQL type is `Int8`.
///
/// (Automatically generated by Diesel.)
last_updated -> Timestamp,
last_updated -> Int8,
}
}

Expand Down Expand Up @@ -964,7 +964,6 @@ diesel::joinable!(challenge -> challenge_category (category));
diesel::joinable!(challenge -> currency (rewards_currency));
diesel::joinable!(challenge -> election (election));
diesel::joinable!(challenge -> vote_options (vote_options));
diesel::joinable!(community_advisors_review -> proposal (proposal_id));
diesel::joinable!(contributions -> snapshots (snapshot_tag));
diesel::joinable!(goal -> election (election_id));
diesel::joinable!(proposal_voteplan -> proposal (proposal_id));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ impl ValidVotingTemplateGenerator for ArbitraryValidVotingTemplateGenerator {
let proposal_id = self
.proposals
.get(self.generator.random_index(self.proposals.len()))
.map(|proposal| proposal.internal_id.clone())
.map(|proposal| proposal.proposal_id.clone())
.unwrap();
let ranking = match self.generator.next_u32() % 2 {
0 => ReviewRanking::Excellent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl<'a> DbInserter<'a> {
config::id3.eq(""),
config::value.eq(serde_json::json!({
"created": token_data.creation_time,
"expired": token_data.expire_time,
"expires": token_data.expire_time,
})),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use assert_cmd::assert::OutputAssertExt;
use assert_fs::{fixture::PathChild, TempDir};

#[test]
#[ignore = "..."]
#[ignore = "Loading data will be done by the importers, not using the CLI"]
pub fn load_data_test() {
let temp_dir = TempDir::new().unwrap().into_persistent();
let db_url = DbBuilder::new().build().unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub fn generate_token_for_given_size_and_n() {
}

#[test]
#[ignore = "..."]
#[ignore = "Loading data will be done by the importers, not using the CLI"]
pub fn add_generated_token_to_db() -> Result<(), Box<dyn Error>> {
let temp_dir = TempDir::new().unwrap();
let (server, _snapshot) = quick_start(&temp_dir).unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ pub fn sort_proposals_result_by_funds_asc() {

#[test]
pub fn sort_proposals_result_by_title_desc() {
use pretty_assertions::assert_eq;

let temp_dir = TempDir::new().unwrap();
let (server, data) = quick_start(&temp_dir).unwrap();
let rest_client = server.rest_client_with_token(&data.token_hash());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ pub fn token_validation() -> Result<(), Box<dyn std::error::Error>> {
let invalid_token = data::token_hash();

let rest_client: RawRestClient = server.rest_client_with_token(&hash).into();
assert_eq!(rest_client.health()?.status(), StatusCode::OK);
let res = rest_client.health()?;
let status = res.status();
println!("{:?}", res.text());

assert_eq!(status, StatusCode::OK);

let rest_client: RawRestClient = server.rest_client_with_token(&invalid_token).into();
assert_eq!(rest_client.health()?.status(), StatusCode::UNAUTHORIZED);
Expand Down

0 comments on commit 9f14f62

Please sign in to comment.