Skip to content
This repository was archived by the owner on Sep 21, 2023. It is now read-only.

Commit ff69906

Browse files
committed
fix tests & correctly set testers
1 parent a46af3d commit ff69906

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/db.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,27 +118,28 @@ pub async fn create_submit_chat(c: &mut SqliteConnection, chat: &SubmitChat) ->
118118
Ok(())
119119
}
120120

121-
/// Upgrade a submit chat with chat_id `id` to a review chat
121+
/// Upgrade a submit chat with chat_id `id` to a review chat.
122122
pub async fn upgrade_to_review_chat(
123123
c: &mut SqliteConnection,
124124
chat: &ReviewChat,
125125
) -> anyhow::Result<()> {
126126
sqlx::query(
127-
"UPDATE chats SET review_helper = ?, submit_helper = ?, review_chat_id = ?, submit_chat_id = ?, publisher = ?, app_info = ? WHERE submit_chat_id = ?"
128-
).bind(chat.review_helper.to_u32())
129-
.bind(chat.submit_helper.to_u32())
130-
.bind(chat.submit_chat.to_u32())
127+
"UPDATE chats SET review_helper = ?, review_chat_id = ?, publisher = ?, testers = ? WHERE submit_chat_id = ?"
128+
)
129+
.bind(chat.review_helper.to_u32())
130+
.bind(chat.review_chat.to_u32())
131131
.bind(chat.publisher.to_u32())
132+
.bind(serde_json::to_string(&chat.testers)?)
132133
.bind(chat.submit_chat.to_u32())
133-
.bind(chat.review_chat.to_u32()).execute(c).await?;
134+
.execute(c).await?;
134135
Ok(())
135136
}
136137

137138
pub async fn get_review_chat(
138139
c: &mut SqliteConnection,
139140
chat_id: ChatId,
140141
) -> anyhow::Result<ReviewChat> {
141-
sqlx::query("SELECT review_helper, submit_helper, review_chat_id, submit_chat_id, publisher, app_info FROM chats WHERE (review_chat_id = ?)")
142+
sqlx::query("SELECT review_helper, submit_helper, review_chat_id, submit_chat_id, publisher, testers, app_info FROM chats WHERE review_chat_id = ?")
142143
.bind(chat_id.to_u32())
143144
.fetch_one(c)
144145
.await
@@ -150,7 +151,7 @@ pub async fn get_review_chat(
150151
submit_chat: ChatId::new(row.try_get("submit_chat_id")?),
151152
publisher: ContactId::new(row.try_get("publisher")?),
152153
app_info: row.try_get("app_info")?,
153-
testers: vec![],
154+
testers: serde_json::from_str(row.try_get("testers")?)?,
154155
})
155156
})?
156157
}
@@ -440,14 +441,18 @@ mod tests {
440441
submit_chat: submit_chat.submit_chat,
441442
submit_helper: submit_chat.submit_helper,
442443
review_chat: review_chat_id,
444+
testers: vec![ContactId::new(3)],
443445
..Default::default()
444446
};
445447

446448
upgrade_to_review_chat(&mut conn, &review_chat)
447449
.await
448450
.unwrap();
449451

450-
get_review_chat(&mut conn, review_chat_id).await.unwrap();
452+
let loaded_review_chat = super::get_review_chat(&mut conn, review_chat_id)
453+
.await
454+
.unwrap();
455+
assert_eq!(loaded_review_chat.testers, review_chat.testers);
451456
}
452457

453458
#[tokio::test]

src/request_handlers/review.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ impl ReviewChat {
102102
)
103103
.await?;
104104

105-
let submit_helper = send_webxdc(context, chat_id, REVIEW_HELPER_XDC, None).await?;
106-
send_app_info(context, &app_info, submit_helper).await?;
105+
let review_helper = send_webxdc(context, chat_id, REVIEW_HELPER_XDC, None).await?;
106+
send_app_info(context, &app_info, review_helper).await?;
107107

108108
let review_chat = ReviewChat {
109109
review_chat: chat_id,
110-
submit_chat: submit_chat.submit_chat,
111110
publisher,
111+
review_helper,
112112
testers: testers.clone(),
113+
submit_chat: submit_chat.submit_chat,
113114
app_info: submit_chat.app_info,
114-
review_helper: submit_chat.submit_helper,
115-
submit_helper,
115+
submit_helper: submit_chat.submit_helper,
116116
};
117117

118118
db::upgrade_to_review_chat(conn, &review_chat).await?;

0 commit comments

Comments
 (0)