Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Dec 4, 2023
1 parent d3a3e78 commit 6e49eb2
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions backend/integration_tests/src/update_profile_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ fn update_username_succeeds() {
#[test]
fn update_display_name_succeeds() {
let mut wrapper = ENV.deref().get();
let TestEnv { env, canister_ids, .. } = wrapper.env();
let TestEnv {
env,
canister_ids,
controller,
} = wrapper.env();

let user = client::local_user_index::happy_path::register_user(env, canister_ids.local_user_index);
let user = client::register_diamond_user(env, canister_ids, *controller);

env.advance_time(Duration::from_secs(10));

Expand All @@ -59,3 +63,29 @@ fn update_display_name_succeeds() {
let updates = client::user::happy_path::updates(env, &user, now - 1);
assert_eq!(updates.unwrap().display_name, OptionUpdate::SetToSome(display_name));
}

#[test]
fn update_display_name_unauthorized_if_not_diamond_member() {
let mut wrapper = ENV.deref().get();
let TestEnv { env, canister_ids, .. } = wrapper.env();

let user = client::local_user_index::happy_path::register_user(env, canister_ids.local_user_index);

env.advance_time(Duration::from_secs(10));

let display_name = random_string();

let response = client::user_index::set_display_name(
env,
user.principal,
canister_ids.user_index,
&user_index_canister::set_display_name::Args {
display_name: Some(display_name.clone()),
},
);

assert!(matches!(
response,
user_index_canister::set_display_name::Response::Unauthorized
));
}

0 comments on commit 6e49eb2

Please sign in to comment.