Skip to content

Commit c383f85

Browse files
tegiozcynthia-sg
andauthored
Add tests for templates (#629)
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com> Signed-off-by: Cintia Sánchez García <cynthiasg@icloud.com> Co-authored-by: Cintia Sánchez García <cynthiasg@icloud.com>
1 parent 8e7eafb commit c383f85

24 files changed

Lines changed: 656 additions & 34 deletions

src/results.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! This module defines the logic to calculate vote results.
22
3-
use std::{collections::HashMap, fmt};
3+
use std::{collections::BTreeMap, fmt};
44

55
use anyhow::{bail, Result};
66
use serde::{Deserialize, Serialize};
@@ -113,7 +113,7 @@ pub(crate) struct VoteResults {
113113
pub binding: i64,
114114
pub non_binding: i64,
115115
pub allowed_voters: i64,
116-
pub votes: HashMap<UserName, UserVote>,
116+
pub votes: BTreeMap<UserName, UserVote>,
117117
pub pending_voters: Vec<UserName>,
118118
}
119119

@@ -141,7 +141,7 @@ pub(crate) async fn calculate<'a>(
141141
gh.get_allowed_voters(inst_id, &vote.cfg, owner, repo, vote.organization.as_ref()).await?;
142142

143143
// Track users votes
144-
let mut votes: HashMap<UserName, UserVote> = HashMap::new();
144+
let mut votes: BTreeMap<UserName, UserVote> = BTreeMap::new();
145145
let mut multiple_options_voters: Vec<UserName> = Vec::new();
146146
for reaction in reactions {
147147
// Get vote option from reaction
@@ -345,7 +345,7 @@ mod tests {
345345
not_voted: 0,
346346
binding: 1,
347347
non_binding: 0,
348-
votes: HashMap::from([
348+
votes: BTreeMap::from([
349349
(
350350
USER1.to_string(),
351351
UserVote {
@@ -393,7 +393,7 @@ mod tests {
393393
not_voted: 1,
394394
binding: 0,
395395
non_binding: 0,
396-
votes: HashMap::new(),
396+
votes: BTreeMap::new(),
397397
allowed_voters: 1,
398398
pending_voters: vec![USER1.to_string()],
399399
}
@@ -445,7 +445,7 @@ mod tests {
445445
not_voted: 1,
446446
binding: 3,
447447
non_binding: 1,
448-
votes: HashMap::from([
448+
votes: BTreeMap::from([
449449
(
450450
USER1.to_string(),
451451
UserVote {
@@ -525,7 +525,7 @@ mod tests {
525525
not_voted: 1,
526526
binding: 3,
527527
non_binding: 0,
528-
votes: HashMap::from([
528+
votes: BTreeMap::from([
529529
(
530530
USER1.to_string(),
531531
UserVote {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Configuration file not found. Please see <https://github.com/cncf/gitvote#configuration>.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The requested configuration profile was not found in the configuration file.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Something went wrong while processing the configuration file:
2+
3+
```text
4+
Missing required field: pass_threshold
5+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
There is no vote in progress to cancel in this issue @testuser.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
There is no vote in progress to cancel in this pull request @testuser.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Vote cancelled
2+
3+
@testuser has cancelled the vote in progress in this issue.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Vote cancelled
2+
3+
@testuser has cancelled the vote in progress in this pull request.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Votes can only be checked once a day.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The vote for "**Implement RFC-42** (**#123**)" is now closed.
2+
3+
## Vote results
4+
5+
The vote **passed**! 🎉
6+
7+
`66.67%` of the users with binding vote were in favor and `0.00%` were against (passing threshold: `50%`).
8+
9+
### Summary
10+
11+
| In favor | Against | Abstain | Not voted |
12+
| :--------------------: | :-------------------: | :------------------: | :---------------------: |
13+
| 2 | 0 | 1 | 0 |
14+
15+
### Binding votes (3)
16+
17+
| User | Vote | Timestamp |
18+
| ---- | :---: | :-------: |
19+
| @alice | In favor | 2023-01-04 10:00:00.0 +00:00:00 |
20+
| @bob | In favor | 2023-01-04 11:00:00.0 +00:00:00 |
21+
| @charlie | Abstain | 2023-01-04 12:00:00.0 +00:00:00 |
22+

0 commit comments

Comments
 (0)