-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: migrate voting tests to cucumber
- Loading branch information
Zoe Spellman
committed
Feb 21, 2024
1 parent
d47dd21
commit f9598ed
Showing
26 changed files
with
1,179 additions
and
646 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
//! Contains various feature implementations for the ratings backend. | ||
pub mod chart; | ||
pub mod common; | ||
pub mod pb; | ||
pub mod rating; | ||
pub mod user; | ||
|
||
mod common; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Feature: User voting | ||
Background: | ||
Given a Snap named "chu-chu-garden" has already accumulated 5 votes and 3 upvotes | ||
|
||
Scenario: Amy upvotes a snap she hasn't voted for in the past | ||
When Amy casts an upvote | ||
Then the total number of votes strictly increases | ||
And the ratings band monotonically increases | ||
|
||
Rule: Votes that a user updates do not change the total vote count | ||
|
||
Scenario Outline: Sonic changes his vote between downvote and upvote because "chu-chu-garden" got better/worse | ||
Given Sonic originally voted <original> | ||
When Sonic changes his vote to <after> | ||
Then the ratings band <direction> | ||
But the total number of votes stays constant | ||
|
||
Examples: | ||
| original | after | direction | | ||
| upvote | downvote | monotonically increases | | ||
| downvote | upvote | monotonically decreases | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use tonic::async_trait; | ||
use tonic::{metadata::MetadataValue, transport::Endpoint, Request, Response, Status}; | ||
|
||
use ratings::features::pb::app::{GetRatingRequest, GetRatingResponse}; | ||
|
||
use ratings::features::pb::app::app_client as pb; | ||
|
||
use super::Client; | ||
|
||
#[async_trait] | ||
pub trait AppClient: Client { | ||
async fn get_rating( | ||
&self, | ||
token: &str, | ||
id: &str, | ||
) -> Result<Response<GetRatingResponse>, Status> { | ||
let channel = Endpoint::from_shared(self.url().to_string()) | ||
.unwrap() | ||
.connect() | ||
.await | ||
.unwrap(); | ||
let mut client = pb::AppClient::with_interceptor(channel, move |mut req: Request<()>| { | ||
let header: MetadataValue<_> = format!("Bearer {token}").parse().unwrap(); | ||
req.metadata_mut().insert("authorization", header); | ||
Ok(req) | ||
}); | ||
client | ||
.get_rating(GetRatingRequest { | ||
snap_id: id.to_string(), | ||
}) | ||
.await | ||
} | ||
} |
Oops, something went wrong.