Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
removed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thesuzerain committed Oct 6, 2023
1 parent e4e86ba commit 79df302
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 88 deletions.
39 changes: 3 additions & 36 deletions tests/common/database.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#![allow(dead_code)]

use labrinth::database::redis::RedisPool;
use sqlx::{postgres::PgPoolOptions, Executor, PgPool};
use sqlx::{postgres::PgPoolOptions, PgPool};
use std::time::Duration;
use url::Url;

// The dummy test database adds a fair bit of 'dummy' data to test with.
// These constants are used to refer to that data, and are described here.
// Some constants are used to refer to that data, and are described here.
// The rest can be accessed in the TestEnvironment 'dummy' field.

// The user IDs are as follows:
pub const ADMIN_USER_ID: &str = "1";
Expand All @@ -28,30 +29,6 @@ pub const USER_USER_PAT: &str = "mrp_patuser";
pub const FRIEND_USER_PAT: &str = "mrp_patfriend";
pub const ENEMY_USER_PAT: &str = "mrp_patenemy";

// There are two test projects. They are both created by user 3 (USER_USER_ID).
// They differ only in that 'ALPHA' is a public, approved project, and 'BETA' is a private, project in queue.
// The same goes for their corresponding versions- one listed, one draft.
// pub const PROJECT_ALPHA_TEAM_ID: &str = "1c";
// pub const PROJECT_BETA_TEAM_ID: &str = "1d";

// pub const PROJECT_ALPHA_PROJECT_ID: &str = "G8";
// pub const PROJECT_BETA_PROJECT_ID: &str = "G9";

// pub const PROJECT_ALPHA_PROJECT_SLUG: &str = "testslug";
// pub const PROJECT_BETA_PROJECT_SLUG: &str = "testslug2";

// pub const alpha_version_id: &str = "Hk";
// pub const beta_version_id: &str = "Hl";

// These are threads created alongside the projects.
// pub const alpha_thread_id: &str = "U";
// pub const PROJECT_BETA_THREAD_ID: &str = "V";

// These are the hashes of the files attached to their versions: they do not reflect a 'real' hash of data.
// This can be used for /version_file/ type endpoints which get a project's data from its hash.
// pub const alpha_file_hash: &str = "000000000";
// pub const beta_file_hash: &str = "111111111";

pub struct TemporaryDatabase {
pub pool: PgPool,
pub redis_pool: RedisPool,
Expand Down Expand Up @@ -141,16 +118,6 @@ impl TemporaryDatabase {
.await
.expect("Database deletion failed");
}

pub async fn add_dummy_data(&self) {
// Adds basic dummy data to the database directly with sql (user, pats)
let pool = &self.pool.clone();
pool.execute(include_str!("../files/dummy_data.sql"))
.await
.unwrap();

// Adds dummy data to the database with sqlx (projects, versions, threads)
}
}

fn generate_random_database_name() -> String {
Expand Down
53 changes: 1 addition & 52 deletions tests/files/dummy_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -33,55 +33,4 @@ INSERT INTO categories (id, category, project_type) VALUES (3, 'economy', 1);

INSERT INTO categories (id, category, project_type) VALUES (4, 'combat', 2);
INSERT INTO categories (id, category, project_type) VALUES (5, 'decoration', 2);
INSERT INTO categories (id, category, project_type) VALUES (6, 'economy', 2);

-- -- Inserts 2 dummy projects for testing, with slight differences
-- ------------------------------------------------------------
-- INSERT INTO teams (id) VALUES (100); -- ID: 100, 1c
-- INSERT INTO team_members (id, team_id, user_id, role, permissions, accepted, payouts_split, ordering) VALUES (200, 100, 3, 'Owner', B'1111111111'::BIGINT, true, 100.0, 0);

-- -- ID: 1000, G8
-- -- This project is approved, viewable
-- INSERT INTO mods (id, team_id, title, description, body, published, downloads, status, requested_status, client_side, server_side, license, slug, project_type, monetization_status)
-- VALUES (1000, 100, 'Test Mod', 'Test mod description', 'Test mod body', timezone('utc', now()), 0, 'approved', 'approved', 1, 2, 'MIT', 'testslug', 1, 'monetized');

-- -- ID: 1100, Hk
-- -- This version is listed, viewable
-- INSERT INTO versions ( id, mod_id, author_id, name, version_number, changelog, date_published, downloads, version_type, featured, status)
-- VALUES (1100, 1000, 3, 'v1', 'v1.2.1', 'No changes', timezone('utc', now()), 0,'released', true, 'listed');

-- INSERT INTO loaders_versions (loader_id, version_id) VALUES (1, 1100);
-- INSERT INTO game_versions_versions (game_version_id, joining_version_id) VALUES (20000, 1100);

-- -- not real hash or file
-- INSERT INTO files (id, version_id, url, filename, is_primary, size, file_type)
-- VALUES (800, 1100, 'http://www.url.to/myfile.jar', 'myfile.jar', true, 1, 'required-resource-pack');
-- INSERT INTO hashes (file_id, algorithm, hash) VALUES (800, 'sha1', '000000000');

-- -- ID: 30, U
-- INSERT INTO threads (id, thread_type, mod_id, report_id) VALUES (30, 'project', 1000, null);

-- ------------------------------------------------------------
-- INSERT INTO teams (id) VALUES (101); -- ID: 101, 1d
-- INSERT INTO team_members (id, team_id, user_id, role, permissions, accepted, payouts_split, ordering) VALUES (201, 101, 3, 'Owner', B'1111111111'::BIGINT, true, 100.0, 0);

-- -- ID: 1001, G9
-- -- This project is processing, and therefore not publically viewable
-- INSERT INTO mods (id, team_id, title, description, body, published, downloads, status, requested_status, client_side, server_side, license, slug, project_type, monetization_status)
-- VALUES (1001, 101, 'Test Mod 2', 'Test mod description 2', 'Test mod body 2', timezone('utc', now()), 0, 'processing', 'approved', 1, 2, 'MIT', 'testslug2', 1, 'monetized');

-- -- ID: 1101, Hl
-- -- This version is a draft, and therefore not publically viewable
-- INSERT INTO versions ( id, mod_id, author_id, name, version_number, changelog, date_published, downloads, version_type, featured, status)
-- VALUES (1101, 1001, 3, 'v1.0', 'v1.2.1', 'No changes', timezone('utc', now()), 0,'released', true, 'draft');

-- INSERT INTO loaders_versions (loader_id, version_id) VALUES (1, 1101);
-- INSERT INTO game_versions_versions (game_version_id, joining_version_id) VALUES (20000, 1101);

-- -- not real hash or file
-- INSERT INTO files (id, version_id, url, filename, is_primary, size, file_type)
-- VALUES (801, 1101, 'http://www.url.to/myfile2.jar', 'myfile2.jar', true, 1, 'required-resource-pack');
-- INSERT INTO hashes (file_id, algorithm, hash) VALUES (801, 'sha1', '111111111');

-- -- ID: 31, V
-- INSERT INTO threads (id, thread_type, mod_id, report_id, show_in_mod_inbox) VALUES (31, 'project', 1001, null, true);
INSERT INTO categories (id, category, project_type) VALUES (6, 'economy', 2);

0 comments on commit 79df302

Please sign in to comment.