Skip to content

Commit

Permalink
remove test about none
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii committed Dec 3, 2024
1 parent 76c37c1 commit d0fe47c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 58 deletions.
17 changes: 6 additions & 11 deletions src/backend/src/user_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,10 @@ pub fn add_hidden_dapp_id(
dapp_id: String,
user_profile_model: &mut UserProfileModel,
) -> Result<(), AddDappSettingsError> {
if let Ok(user_profile) = find_profile(principal, user_profile_model) {
let now = time();
if let Ok(new_profile) = user_profile.add_hidden_dapp_id(profile_version, now, dapp_id) {
user_profile_model.store_new(principal, now, &new_profile);
Ok(())
} else {
Err(AddDappSettingsError::VersionMismatch)
}
} else {
Err(AddDappSettingsError::UserNotFound)
}
let user_profile = find_profile(principal, user_profile_model)
.map_err(|_| AddDappSettingsError::UserNotFound)?;
let now = time();
let new_profile = user_profile.add_hidden_dapp_id(profile_version, now, dapp_id)?;
user_profile_model.store_new(principal, now, &new_profile);
Ok(())
}
47 changes: 0 additions & 47 deletions src/backend/tests/it/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,53 +203,6 @@ fn test_add_user_hidden_dapp_id_cannot_update_wrong_version() {
);
}

#[test]
fn test_add_user_hidden_dapp_id_does_not_update_if_version_is_none() {
let pic_setup = setup();

let caller = Principal::from_text(CALLER).unwrap();

let create_profile_response =
pic_setup.update::<UserProfile>(caller, "create_user_profile", ());

let profile = create_profile_response.expect("Create failed");
assert_eq!(profile.settings.dapp.dapp_carousel.hidden_dapp_ids.len(), 0);

let add_hidden_dapp_id_arg = AddHiddenDappIdRequest {
dapp_id: "test_dapp_id".to_string(),
current_user_version: None,
};

let add_hidden_dapp_id_response = pic_setup.update::<Result<(), AddDappSettingsError>>(
caller,
"add_user_hidden_dapp_id",
add_hidden_dapp_id_arg,
);

assert_eq!(
add_hidden_dapp_id_response,
Ok(Err(AddDappSettingsError::VersionMismatch))
);

let get_profile_response = pic_setup.update::<Result<UserProfile, GetUserProfileError>>(
caller,
"get_user_profile",
(),
);

assert_eq!(
get_profile_response
.expect("Call to get profile failed")
.expect("Get profile failed")
.settings
.dapp
.dapp_carousel
.hidden_dapp_ids
.len(),
0
);
}

#[test]
fn test_add_user_hidden_dapp_id_does_not_add_duplicate_dapp_id() {
let pic_setup = setup();
Expand Down

0 comments on commit d0fe47c

Please sign in to comment.