-
Notifications
You must be signed in to change notification settings - Fork 19
/
factories.rb
51 lines (45 loc) · 1.58 KB
/
factories.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
require "registration/addon"
require "suse/connect"
def suse_connect_product_generator(attrs = {})
params = {}
params["available"] = attrs["available"] if attrs.key?("available")
params["name"] = attrs["name"] || "Product#{rand(100_000)}"
params["friendly_name"] = attrs["friendly_name"] || "The best cool #{params["name"]}"
params["description"] = attrs["description"] || "Bla bla bla bla!"
params["id"] = attrs["id"] || rand(10_000).to_s
params["identifier"] = attrs["zypper_name"] || "prod#{rand(100_000)}"
params["version"] = attrs["version"] || rand(13).to_s
params["arch"] = attrs["arch"] || "x86_64"
params["free"] = attrs.fetch("free", true)
params["eula_url"] = attrs["eula_url"]
params["extensions"] = attrs["extensions"] || []
params["former_identifier"] = attrs["former_identifier"]
params["release_stage"] = attrs["release_stage"]
params["recommended"] = attrs["recommended"] || false
params
end
def addon_generator(params = {})
OpenStruct.new(suse_connect_product_generator(params))
end
def addon_with_child_generator(parent_params = {})
prod_child = OpenStruct.new(suse_connect_product_generator)
OpenStruct.new(
suse_connect_product_generator(parent_params.merge("extensions" => [prod_child]))
)
end
# add cache reset, which is not needed in runtime, but for test it is critical
module Registration
class Addon
class << self
def reset_cache
@cached_addons = nil
@registered = nil
@selected = nil
@auto_selected = nil
end
end
end
end
def addon_reset_cache
Registration::Addon.reset_cache
end