|
31 | 31 |
|
32 | 32 | before { allow(file_fetcher_instance).to receive(:commit).and_return("sha") }
|
33 | 33 |
|
34 |
| - context "with a workflow file" do |
| 34 | + context "with workflow files" do |
35 | 35 | before do
|
| 36 | + stub_request(:get, url + "?ref=sha"). |
| 37 | + with(headers: { "Authorization" => "token token" }). |
| 38 | + to_return( |
| 39 | + status: 200, |
| 40 | + body: fixture("github", "contents_githubaction_repo_base_basic.json"), |
| 41 | + headers: { "content-type" => "application/json" } |
| 42 | + ) |
36 | 43 | stub_request(:get, url + ".github/workflows?ref=sha").
|
37 | 44 | with(headers: { "Authorization" => "token token" }).
|
38 | 45 | to_return(
|
39 | 46 | status: 200,
|
40 |
| - body: fixture("github", "contents_workflows_repo.json"), |
| 47 | + body: fixture("github", "contents_githubaction_repo_workflows.json"), |
41 | 48 | headers: { "content-type" => "application/json" }
|
42 | 49 | )
|
43 | 50 |
|
|
62 | 69 | end
|
63 | 70 |
|
64 | 71 | let(:workflow_file_fixture) do
|
65 |
| - fixture("github", "contents_workflow_file.json") |
| 72 | + fixture("github", "contents_githubaction_workflow_file.json") |
66 | 73 | end
|
67 | 74 |
|
68 | 75 | it "fetches the workflow files" do
|
|
105 | 112 | to match_array(%w(.github/workflows/integration-workflow.yml))
|
106 | 113 | end
|
107 | 114 | end
|
| 115 | + |
| 116 | + context "with an additional composite action file" do |
| 117 | + let(:composite_action_file_fixture) do |
| 118 | + fixture("github", "contents_githubaction_composite_file.json") |
| 119 | + end |
| 120 | + |
| 121 | + before do |
| 122 | + stub_request(:get, url + "?ref=sha"). |
| 123 | + with(headers: { "Authorization" => "token token" }). |
| 124 | + to_return( |
| 125 | + status: 200, |
| 126 | + body: fixture("github", "contents_githubaction_repo_base_composite.json"), |
| 127 | + headers: { "content-type" => "application/json" } |
| 128 | + ) |
| 129 | + |
| 130 | + stub_request( |
| 131 | + :get, |
| 132 | + File.join(url, "action.yml?ref=sha") |
| 133 | + ).with(headers: { "Authorization" => "token token" }). |
| 134 | + to_return( |
| 135 | + status: 200, |
| 136 | + body: composite_action_file_fixture, |
| 137 | + headers: { "content-type" => "application/json" } |
| 138 | + ) |
| 139 | + end |
| 140 | + |
| 141 | + it "fetches all action files" do |
| 142 | + expect(file_fetcher_instance.files.map(&:name)). |
| 143 | + to match_array( |
| 144 | + %w(action.yml |
| 145 | + .github/workflows/sherlock-workflow.yaml |
| 146 | + .github/workflows/integration-workflow.yml) |
| 147 | + ) |
| 148 | + end |
| 149 | + end |
108 | 150 | end
|
109 | 151 |
|
110 | 152 | context "with an empty workflow directory" do
|
111 | 153 | before do
|
| 154 | + stub_request(:get, url + "?ref=sha"). |
| 155 | + with(headers: { "Authorization" => "token token" }). |
| 156 | + to_return( |
| 157 | + status: 200, |
| 158 | + body: fixture("github", "contents_githubaction_repo_base_basic.json"), |
| 159 | + headers: { "content-type" => "application/json" } |
| 160 | + ) |
112 | 161 | stub_request(:get, url + ".github/workflows?ref=sha").
|
113 | 162 | with(headers: { "Authorization" => "token token" }).
|
114 | 163 | to_return(
|
|
126 | 175 |
|
127 | 176 | context "with a repo without a .github/workflows directory" do
|
128 | 177 | before do
|
| 178 | + stub_request(:get, url + "?ref=sha"). |
| 179 | + with(headers: { "Authorization" => "token token" }). |
| 180 | + to_return( |
| 181 | + status: 200, |
| 182 | + body: "[]", |
| 183 | + headers: { "content-type" => "application/json" } |
| 184 | + ) |
129 | 185 | stub_request(:get, url + ".github/workflows?ref=sha").
|
130 | 186 | with(headers: { "Authorization" => "token token" }).
|
131 | 187 | to_return(
|
|
140 | 196 | to raise_error(Dependabot::DependencyFileNotFound)
|
141 | 197 | end
|
142 | 198 | end
|
| 199 | + |
| 200 | + context "with a repo containg only a composite action file" do |
| 201 | + let(:composite_action_file_fixture) do |
| 202 | + fixture("github", "contents_githubaction_composite_file.json") |
| 203 | + end |
| 204 | + |
| 205 | + before do |
| 206 | + stub_request(:get, url + "?ref=sha"). |
| 207 | + with(headers: { "Authorization" => "token token" }). |
| 208 | + to_return( |
| 209 | + status: 200, |
| 210 | + body: fixture("github", "contents_githubaction_repo_base_composite.json"), |
| 211 | + headers: { "content-type" => "application/json" } |
| 212 | + ) |
| 213 | + stub_request(:get, url + ".github/workflows?ref=sha"). |
| 214 | + with(headers: { "Authorization" => "token token" }). |
| 215 | + to_return( |
| 216 | + status: 404, |
| 217 | + body: fixture("github", "not_found.json"), |
| 218 | + headers: { "content-type" => "application/json" } |
| 219 | + ) |
| 220 | + |
| 221 | + stub_request( |
| 222 | + :get, |
| 223 | + File.join(url, "action.yml?ref=sha") |
| 224 | + ).with(headers: { "Authorization" => "token token" }). |
| 225 | + to_return( |
| 226 | + status: 200, |
| 227 | + body: composite_action_file_fixture, |
| 228 | + headers: { "content-type" => "application/json" } |
| 229 | + ) |
| 230 | + end |
| 231 | + |
| 232 | + it "fetches the composite action file" do |
| 233 | + expect(file_fetcher_instance.files.map(&:name)). |
| 234 | + to match_array( |
| 235 | + %w(action.yml) |
| 236 | + ) |
| 237 | + end |
| 238 | + end |
143 | 239 | end
|
0 commit comments