diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-07-15 18:21:21 +0200 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-07-30 18:00:42 +0200 |
commit | 5d9e84b579b8abc2e16acf32dbb2c468968574ed (patch) | |
tree | c13727b420e94fc173795c108fa14040ec855a36 | |
parent | test: org variables (diff) | |
download | forgejo-api-5d9e84b579b8abc2e16acf32dbb2c468968574ed.tar.xz forgejo-api-5d9e84b579b8abc2e16acf32dbb2c468968574ed.zip |
test: user vars
-rw-r--r-- | tests/user.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/user.rs b/tests/user.rs index 9ca808d..3b6e0e3 100644 --- a/tests/user.rs +++ b/tests/user.rs @@ -191,3 +191,47 @@ async fn oauth2_login() { let myself = token_api.user_get_current().await.unwrap(); assert_eq!(myself.login.as_deref(), Some("TestingAdmin")); } + +#[tokio::test] +async fn user_vars() { + let api = common::login(); + + let query = GetUserVariablesListQuery::default(); + let var_list = api + .get_user_variables_list(query) + .await + .expect("failed to list user vars"); + assert!(var_list.is_empty()); + + let opt = CreateVariableOption { + value: "false".into(), + }; + api.create_user_variable("likes_dogs", opt) + .await + .expect("failed to create user var"); + + let new_var = api + .get_user_variable("likes_dogs") + .await + .expect("failed to get user var"); + assert_eq!(new_var.data.as_deref(), Some("false")); + + // what??? totally wrong. I love dogs! + let opt = UpdateVariableOption { + name: Some("loves_dogs".into()), + value: "true".into(), + }; + api.update_user_variable("likes_dogs", opt) + .await + .expect("failed to update user variable"); + + let new_var = api + .get_user_variable("loves_dogs") + .await + .expect("failed to get user var"); + assert_eq!(new_var.data.as_deref(), Some("true")); + + api.delete_user_variable("loves_dogs") + .await + .expect("failed to delete user var"); +} |