File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -552,8 +552,12 @@ pub struct TestContext<'a> {
552552impl < ' a > TestContext < ' a > {
553553 /// Creates a new [`TestContext`] with the given [`KvStore`] implementation.
554554 pub fn new ( kv_store : & ' a dyn KvStore ) -> Self {
555- let store_id: String = ( 0 ..7 ) . map ( |_| thread_rng ( ) . sample ( Alphanumeric ) as char ) . collect ( ) ;
556- TestContext { kv_store, user_token : "userToken" . to_string ( ) , store_id }
555+ let store_id_len = thread_rng ( ) . gen_range ( 0 ..6 ) ;
556+ let store_id: String =
557+ ( 0 ..store_id_len) . map ( |_| thread_rng ( ) . sample ( Alphanumeric ) as char ) . collect ( ) ;
558+ let user_token: String =
559+ ( 0 ..7 ) . map ( |_| thread_rng ( ) . sample ( Alphanumeric ) as char ) . collect ( ) ;
560+ TestContext { kv_store, user_token, store_id }
557561 }
558562
559563 async fn get_object ( & self , key : & str ) -> Result < KeyValue , VssError > {
Original file line number Diff line number Diff line change @@ -26,14 +26,15 @@ pub(crate) const MIGRATIONS: &[&str] = &[
2626 // We do not complain if the table already exists, as users of VSS could have already created this table
2727 "CREATE TABLE IF NOT EXISTS vss_db (
2828 user_token character varying(120) NOT NULL CHECK (user_token <> ''),
29- store_id character varying(120) NOT NULL CHECK (store_id <> '') ,
29+ store_id character varying(120) NOT NULL,
3030 key character varying(600) NOT NULL,
3131 value bytea NULL,
3232 version bigint NOT NULL,
3333 created_at TIMESTAMP WITH TIME ZONE,
3434 last_updated_at TIMESTAMP WITH TIME ZONE,
3535 PRIMARY KEY (user_token, store_id, key)
3636 );" ,
37+ "ALTER TABLE vss_db DROP CONSTRAINT IF EXISTS vss_db_store_id_check;" ,
3738] ;
3839#[ cfg( test) ]
3940pub ( crate ) const DUMMY_MIGRATION : & str = "SELECT 1 WHERE FALSE;" ;
Original file line number Diff line number Diff line change 11CREATE TABLE vss_db (
22 user_token character varying (120 ) NOT NULL CHECK (user_token <> ' ' ),
3- store_id character varying (120 ) NOT NULL CHECK (store_id <> ' ' ) ,
3+ store_id character varying (120 ) NOT NULL ,
44 key character varying (600 ) NOT NULL ,
55 value bytea NULL ,
66 version bigint NOT NULL ,
You can’t perform that action at this time.
0 commit comments