diff options
Diffstat (limited to 'tests/repo.rs')
-rw-r--r-- | tests/repo.rs | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/tests/repo.rs b/tests/repo.rs index c9d6894..3a0377c 100644 --- a/tests/repo.rs +++ b/tests/repo.rs @@ -232,6 +232,7 @@ async fn release() { prerelease: Some(false), tag_name: "v1.0".into(), target_commitish: None, + hide_archive_links: None, }; let release = api .repo_create_release("TestingAdmin", "release-test", release_opt) @@ -244,6 +245,7 @@ async fn release() { prerelease: None, tag_name: None, target_commitish: None, + hide_archive_links: None, }; api.repo_edit_release( "TestingAdmin", @@ -390,3 +392,104 @@ async fn team_pr_review_request() { .expect("couldn't get pr"); assert_eq!(pr.requested_reviewers, Some(Vec::new())); } + +#[tokio::test] +async fn tag_protection() { + let api = common::login(); + let git = Git::new("./test_repos/tag-protect"); + let _ = basic_repo(&api, &git, "tag-protect").await; + + let tag_protections = api + .repo_list_tag_protection("TestingAdmin", "tag-protect") + .await + .expect("failed to list tag protections"); + assert!(tag_protections.is_empty()); + + let protection_opt = CreateTagProtectionOption { + name_pattern: Some("v*".into()), + whitelist_teams: None, + whitelist_usernames: Some(vec!["TestingAdmin".into()]), + }; + let new_protection = api + .repo_create_tag_protection("TestingAdmin", "tag-protect", protection_opt) + .await + .expect("failed to create tag protection"); + let pattern = new_protection + .name_pattern + .as_deref() + .expect("protection does not have pattern"); + assert_eq!(pattern, "v*"); + let id = new_protection.id.expect("protection does not have id") as u32; + + let protection_get = api + .repo_get_tag_protection("TestingAdmin", "tag-protect", id) + .await + .expect("failed to get tag protection"); + assert_eq!(new_protection, protection_get); + + let edit_opt = EditTagProtectionOption { + name_pattern: Some("v*.*.*".into()), + whitelist_teams: None, + whitelist_usernames: Some(vec![]), + }; + let edited = api + .repo_edit_tag_protection("TestingAdmin", "tag-protect", id, edit_opt) + .await + .expect("failed to edit tag protection"); + let pattern = edited + .name_pattern + .as_deref() + .expect("protection does not have pattern"); + assert_eq!(pattern, "v*.*.*"); + + api.repo_delete_tag_protection("TestingAdmin", "tag-protect", id) + .await + .expect("failed to delete tag protection"); +} + +#[tokio::test] +async fn repo_vars() { + let api = common::login(); + let git = Git::new("./test_repos/repo-vars"); + let _ = basic_repo(&api, &git, "repo-vars").await; + + let query = GetRepoVariablesListQuery::default(); + let var_list = api + .get_repo_variables_list("TestingAdmin", "repo-vars", query) + .await + .expect("failed to list repo vars"); + assert!(var_list.is_empty()); + + let opt = CreateVariableOption { + value: "false".into(), + }; + api.create_repo_variable("TestingAdmin", "repo-vars", "very_cool", opt) + .await + .expect("failed to create repo var"); + + let new_var = api + .get_repo_variable("TestingAdmin", "repo-vars", "very_cool") + .await + .expect("failed to get repo var"); + assert_eq!(new_var.data.as_deref(), Some("false")); + + // wait, that's not right. you ARE very cool! + // gotta fix that + let opt = UpdateVariableOption { + name: Some("extremely_cool".into()), + value: "true".into(), + }; + api.update_repo_variable("TestingAdmin", "repo-vars", "very_cool", opt) + .await + .expect("failed to update repo variable"); + + let new_var = api + .get_repo_variable("TestingAdmin", "repo-vars", "extremely_cool") + .await + .expect("failed to get repo var"); + assert_eq!(new_var.data.as_deref(), Some("true")); + + api.delete_repo_variable("TestingAdmin", "repo-vars", "extremely_cool") + .await + .expect("failed to delete repo var"); +} |