Debian Codegraph @

script/spec/distro_spec.rb

raw symbols SCIP
1 require_relative "../lib/distro"
2
3 def test_map
4 {
5 "centos/8" => {
6 name: "RPM RHEL 8/Rocky Linux 8",
7 component: "el/8",
8 image: "centos_8",
9 package_type: "rpm",
10 package_tag: "-1.el8",
11 equivalent: [
12 "el/8",
13 ],
14 },
15 "rocky/9" => {
16 name: "RPM RHEL 9/Rocky Linux 9",
17 component: "el/9",
18 image: "rocky_9",
19 package_type: "rpm",
20 package_tag: "-1.el9",
21 equivalent: [
22 "el/9",
23 "fedora/41",
24 "fedora/42",
25 "opensuse/15.6",
26 "sles/15.6",
27 ],
28 },
29 "debian/12" => {
30 name: "Debian 12",
31 component: "debian/bookworm",
32 image: "debian_12",
33 package_type: "deb",
34 package_tag: "",
35 equivalent: [
36 "debian/bookworm",
37 "debian/trixie",
38 ]
39 },
40 }
41 end
42
43 context DistroMapProgram do
44 it "should print image names" do
45 stdout = StringIO.new
46 stderr = StringIO.new
47 expect(DistroMapProgram.new(stdout, stderr, test_map).run(["--image-names"])).to eq 0
48 expect(stderr.string).to be_empty
49 expect(stdout.string).to eq "centos_8 rocky_9 debian_12\n"
50 end
51
52 it "should print distro markdown" do
53 stdout = StringIO.new
54 stderr = StringIO.new
55 expect(DistroMapProgram.new(stdout, stderr, test_map).run(["--distro-markdown"])).to eq 0
56 expect(stderr.string).to be_empty
57 expected = <<~EOM
58 [RPM RHEL 8/Rocky Linux 8](https://packagecloud.io/github/git-lfs/packages/el/8/git-lfs-VERSION-1.el8.x86_64.rpm/download)
59 [RPM RHEL 9/Rocky Linux 9](https://packagecloud.io/github/git-lfs/packages/el/9/git-lfs-VERSION-1.el9.x86_64.rpm/download)
60 [Debian 12](https://packagecloud.io/github/git-lfs/packages/debian/bookworm/git-lfs_VERSION_amd64.deb/download)
61 EOM
62 expect(stdout.string).to eq expected
63 end
64
65 it "should whine when no options were given" do
66 stdout = StringIO.new
67 stderr = StringIO.new
68 expect(DistroMapProgram.new(stdout, stderr, test_map).run([])).to eq 2
69 expect(stdout.string).to be_empty
70 expect(stderr.string).to eq "A mode option is required\n"
71 end
72 end
73
74 context DistroMap do
75 it "should produce the correct distro names" do
76 map = {
77 "centos/8" => [
78 "el/8",
79 ],
80 "rocky/9" => [
81 "el/9",
82 "fedora/41",
83 "fedora/42",
84 "opensuse/15.6",
85 "sles/15.6",
86 ],
87 "debian/12" => [
88 "debian/bookworm",
89 "debian/trixie",
90 ],
91 }
92 expect(DistroMap.new(test_map).distro_name_map).to eq map
93 end
94
95 it "should produce the correct image names" do
96 expect(DistroMap.new(test_map).image_names).to eq %w[centos_8 rocky_9 debian_12]
97 end
98 end