Skip to content

Commit

Permalink
test(uninstall_addon): use basic function instead of implementing them
Browse files Browse the repository at this point in the history
  • Loading branch information
tymmesyde committed Oct 12, 2023
1 parent 3837492 commit 63b5aee
Showing 1 changed file with 42 additions and 50 deletions.
92 changes: 42 additions & 50 deletions src/unit_tests/ctx/uninstall_addon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,48 @@ use std::any::Any;
use stremio_derive::Model;
use url::Url;

type Addon = Descriptor;

impl Addon {
fn new(transport_url: &str) -> Self {
Self {
manifest: Manifest {
id: "id".to_owned(),
version: Version::new(0, 0, 1),
name: "name".to_owned(),
contact_email: None,
description: None,
logo: None,
background: None,
types: vec![],
resources: vec![],
id_prefixes: None,
catalogs: vec![],
addon_catalogs: vec![],
behavior_hints: Default::default(),
},
transport_url: Url::parse(transport_url).unwrap(),
flags: Default::default(),
}
fn create_addon_descriptor(transport_url: &str) -> Descriptor {
Descriptor {
manifest: Manifest {
id: "id".to_owned(),
version: Version::new(0, 0, 1),
name: "name".to_owned(),
contact_email: None,
description: None,
logo: None,
background: None,
types: vec![],
resources: vec![],
id_prefixes: None,
catalogs: vec![],
addon_catalogs: vec![],
behavior_hints: Default::default(),
},
transport_url: Url::parse(transport_url).unwrap(),
flags: Default::default(),
}
}

type AddonStreamsItem = StreamsItem;

impl AddonStreamsItem {
fn new(addon: &Addon) -> Self {
let stream = Stream {
source: StreamSource::Url {
url: "https://source_url".parse().unwrap(),
},
name: None,
description: None,
thumbnail: None,
subtitles: vec![],
behavior_hints: StreamBehaviorHints::default(),
};
fn create_addon_streams_item(addon: &Descriptor) -> StreamsItem {
let stream = Stream {
source: StreamSource::Url {
url: "https://source_url".parse().unwrap(),
},
name: None,
description: None,
thumbnail: None,
subtitles: vec![],
behavior_hints: StreamBehaviorHints::default(),
};

Self {
stream,
r#type: "movie".to_owned(),
meta_id: "tt123456".to_owned(),
video_id: "tt123456:1:0".to_owned(),
meta_transport_url: addon.transport_url.clone(),
stream_transport_url: addon.transport_url.clone(),
mtime: TestEnv::now(),
}
StreamsItem {
stream,
r#type: "movie".to_owned(),
meta_id: "tt123456".to_owned(),
video_id: "tt123456:1:0".to_owned(),
meta_transport_url: addon.transport_url.clone(),
stream_transport_url: addon.transport_url.clone(),
mtime: TestEnv::now(),
}
}

Expand Down Expand Up @@ -433,8 +425,8 @@ fn actionctx_uninstalladdon_streams_bucket() {
ctx: Ctx,
}

let addon = Addon::new("https://transport_url");
let addon_2 = Addon::new("https://transport_url_2");
let addon = create_addon_descriptor("https://transport_url");
let addon_2 = create_addon_descriptor("https://transport_url_2");

let profile = Profile {
addons: vec![addon.to_owned()],
Expand All @@ -456,8 +448,8 @@ fn actionctx_uninstalladdon_streams_bucket() {
video_id: "tt123456:1:1".to_owned(),
};

let stream_item = AddonStreamsItem::new(&addon);
let stream_item_2 = AddonStreamsItem::new(&addon_2);
let stream_item = create_addon_streams_item(&addon);
let stream_item_2 = create_addon_streams_item(&addon_2);

let mut streams = StreamsBucket::default();
streams.items.insert(streams_item_key.clone(), stream_item);
Expand Down

0 comments on commit 63b5aee

Please sign in to comment.