mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 09:47:50 +03:00
Исправление тестов.
FCMClient теперь не инициализируется, если отсутствует требуемая переменная окружения.
This commit is contained in:
@@ -56,7 +56,7 @@ pub struct AppState {
|
|||||||
pub schedule: Mutex<Option<Schedule>>,
|
pub schedule: Mutex<Option<Schedule>>,
|
||||||
pub database: Mutex<PgConnection>,
|
pub database: Mutex<PgConnection>,
|
||||||
pub vk_id: VkId,
|
pub vk_id: VkId,
|
||||||
pub fcm_client: Mutex<FCMClient>,
|
pub fcm_client: Option<Mutex<FCMClient>>, // в рантайме не меняется, так что опционален мьютекс, а не данные в нём.
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AppState {
|
impl AppState {
|
||||||
@@ -71,7 +71,13 @@ impl AppState {
|
|||||||
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url)),
|
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url)),
|
||||||
),
|
),
|
||||||
vk_id: VkId::new(),
|
vk_id: VkId::new(),
|
||||||
fcm_client: Mutex::new(FCMClient::new().await.expect("FCM client must be created")),
|
fcm_client: if env::var("GOOGLE_APPLICATION_CREDENTIALS").is_ok() {
|
||||||
|
Some(Mutex::new(
|
||||||
|
FCMClient::new().await.expect("FCM client must be created"),
|
||||||
|
))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,6 +567,8 @@ fn convert_groups_to_teachers(
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use schedule_parser_rusted::parser::parse_xls;
|
||||||
|
///
|
||||||
/// let result = parse_xls(&include_bytes!("../../schedule.xls").to_vec());
|
/// let result = parse_xls(&include_bytes!("../../schedule.xls").to_vec());
|
||||||
///
|
///
|
||||||
/// assert!(result.is_ok());
|
/// assert!(result.is_ok());
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ pub async fn set_token(
|
|||||||
// Subscribe to default topics.
|
// Subscribe to default topics.
|
||||||
if let Some(e) = app_state
|
if let Some(e) = app_state
|
||||||
.fcm_client
|
.fcm_client
|
||||||
|
.as_ref()
|
||||||
|
.unwrap()
|
||||||
.async_scope(
|
.async_scope(
|
||||||
async |client: &mut FCMClient| -> Result<(), TopicManagementError> {
|
async |client: &mut FCMClient| -> Result<(), TopicManagementError> {
|
||||||
let mut tokens: Vec<String> = Vec::new();
|
let mut tokens: Vec<String> = Vec::new();
|
||||||
|
|||||||
Reference in New Issue
Block a user