install addon unit test refactored
@@ -3,7 +3,7 @@ use crate::constants::{LIBRARY_RECENT_STORAGE_KEY, LIBRARY_STORAGE_KEY, PROFILE_
use crate::state_types::models::ctx::Ctx;
use crate::state_types::msg::{Action, ActionCtx, Msg};
use crate::state_types::{EnvFuture, Environment, Runtime};
-use crate::types::addons::{Descriptor, DescriptorFlags, Manifest};
+use crate::types::addons::{Descriptor, Manifest};
use crate::types::api::{
APIResult, Auth, AuthRequest, AuthResponse, CollectionResponse, GDPRConsent, SuccessResponse,
True, User,
@@ -498,51 +498,51 @@ fn actionctx_installaddon() {
}
let addon = Descriptor {
manifest: Manifest {
- id: "com.stremio.taddon".to_owned(),
- version: Version {
- major: 1,
- minor: 0,
- patch: 0,
- pre: vec![],
- build: vec![],
- },
- name: "Stremio\'s test addon".to_owned(),
+ id: "id".to_owned(),
+ version: Version::new(0, 0, 1),
+ name: "name".to_owned(),
contact_email: None,
- description: Some("Addon for test the stremio addons system".to_owned()),
+ description: None,
logo: None,
background: None,
types: vec![],
resources: vec![],
- id_prefixes: Some(vec![]),
+ id_prefixes: None,
catalogs: vec![],
addon_catalogs: vec![],
behavior_hints: Default::default(),
},
- transport_url: "http://127.0.0.1:7001/manifest.json".to_owned(),
- flags: DescriptorFlags {
- official: false,
- protected: false,
- extra: Default::default(),
- },
+ transport_url: "transport_url".to_owned(),
+ flags: Default::default(),
};
Env::reset();
- let (runtime, _) = Runtime::<Env, Model>::new(Model::default(), 1000);
+ let (runtime, _) = Runtime::<Env, Model>::new(
+ Model {
+ ctx: Ctx {
+ profile: Profile {
+ addons: vec![],
+ ..Default::default()
+ },
+ ..Default::default()
+ },
+ },
+ 1000,
+ );
run(
runtime.dispatch(&Msg::Action(Action::Ctx(ActionCtx::InstallAddon(
addon.to_owned(),
)))),
);
assert_eq!(
- runtime.app.read().unwrap().ctx.profile.addons.last(),
- Some(&addon),
+ runtime.app.read().unwrap().ctx.profile.addons[0],
+ addon,
"addon installed successfully"
);
assert_eq!(
serde_json::from_str::<Profile>(&STORAGE.read().unwrap().get(PROFILE_STORAGE_KEY).unwrap())
.unwrap()
- .addons
- .last(),
- Some(&addon),
+ .addons[0],
+ addon,
"addon updated successfully in storage"
);
}
