forgejo-hooks: Add failing tests
Signed-off-by: pep <pep@bouah.net>
This commit is contained in:
parent
979dc50644
commit
25eeacde7c
4 changed files with 285 additions and 14 deletions
|
|
@ -13,17 +13,20 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct CommitAuthor {
|
||||
pub name: String,
|
||||
pub email: String,
|
||||
pub username: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct User {
|
||||
pub id: u32,
|
||||
pub login: String,
|
||||
|
|
@ -33,7 +36,7 @@ pub struct User {
|
|||
pub username: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Commit {
|
||||
pub id: String,
|
||||
pub message: String,
|
||||
|
|
@ -43,21 +46,21 @@ pub struct Commit {
|
|||
pub timestamp: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct Perms {
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Permissions {
|
||||
admin: bool,
|
||||
push: bool,
|
||||
pull: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct InternalTracker {
|
||||
enable_time_tracker: bool,
|
||||
allow_only_contributors_to_track_time: bool,
|
||||
enable_issue_dependencies: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Repository {
|
||||
pub id: u32,
|
||||
pub owner: User,
|
||||
|
|
@ -79,7 +82,7 @@ pub struct Repository {
|
|||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct RepositoryFull {
|
||||
pub id: u32,
|
||||
pub owner: RepositoryOwner,
|
||||
|
|
@ -134,7 +137,7 @@ pub struct RepositoryFull {
|
|||
pub repo_transfer: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct RepositoryOwner {
|
||||
pub id: u32,
|
||||
pub login: String,
|
||||
|
|
@ -159,7 +162,7 @@ pub struct RepositoryOwner {
|
|||
pub username: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct Push {
|
||||
#[serde(rename(deserialize = "ref"))]
|
||||
pub ref_: String,
|
||||
|
|
@ -171,12 +174,12 @@ pub struct Push {
|
|||
pub sender: User,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub enum RefType {
|
||||
Branch,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct AddedBranch {
|
||||
pub sha: String,
|
||||
pub ref_type: String,
|
||||
|
|
@ -184,7 +187,7 @@ pub struct AddedBranch {
|
|||
pub sender: RepositoryOwner,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
pub struct RemovedBranch {
|
||||
pub sha: String,
|
||||
pub ref_type: String,
|
||||
|
|
@ -193,7 +196,19 @@ pub struct RemovedBranch {
|
|||
pub sender: RepositoryOwner,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
impl From<Push> for Hook {
|
||||
fn from(push: Push) -> Self {
|
||||
Self::Push(push)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Issue> for Hook {
|
||||
fn from(issue: Issue) -> Self {
|
||||
Self::Issue(issue)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
#[serde(untagged)]
|
||||
pub enum Hook {
|
||||
Push(Push),
|
||||
|
|
|
|||
Loading…
Reference in a new issue