pipeline fix
This commit is contained in:
@@ -8,7 +8,7 @@ RSpec.describe WarpEngine::CiPipelineService do
|
||||
it "returns latest pipeline for each active repo" do
|
||||
repo = create(:ci_repository, repo_owner: "org", repo_name: "game")
|
||||
pipeline = { "number" => 5, "status" => "success", "created_at" => "2026-08-06T12:00:00Z" }
|
||||
allow(client).to receive(:latest_pipeline).with("org", "game").and_return(pipeline)
|
||||
allow(client).to receive(:latest_pipeline).with(repo.woodpecker_repo_id).and_return(pipeline)
|
||||
|
||||
entries = service.dashboard
|
||||
|
||||
@@ -37,7 +37,7 @@ RSpec.describe WarpEngine::CiPipelineService do
|
||||
result = service.trigger(repo, branch: "main")
|
||||
|
||||
expect(result["number"]).to eq(6)
|
||||
expect(client).to have_received(:trigger_pipeline).with("org", "game", branch: "main")
|
||||
expect(client).to have_received(:trigger_pipeline).with(repo.woodpecker_repo_id, branch: "main")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ RSpec.describe WarpEngine::CiPipelineService do
|
||||
it "returns paginated pipelines" do
|
||||
repo = build(:ci_repository, repo_owner: "org", repo_name: "game")
|
||||
pipelines = [{ "number" => 1 }, { "number" => 2 }]
|
||||
allow(client).to receive(:list_pipelines).with("org", "game", page: 1).and_return(pipelines)
|
||||
allow(client).to receive(:list_pipelines).with(repo.woodpecker_repo_id, page: 1).and_return(pipelines)
|
||||
|
||||
expect(service.list_pipelines(repo)).to eq(pipelines)
|
||||
end
|
||||
|
||||
@@ -67,23 +67,23 @@ RSpec.describe WarpEngine::WoodpeckerClient do
|
||||
describe "pipelines" do
|
||||
it "lists pipelines" do
|
||||
pipelines = [{ "number" => 1, "status" => "success" }]
|
||||
stub_wp(:get, "/api/repos/org/game/pipelines?page=1&perPage=25", body: pipelines)
|
||||
stub_wp(:get, "/api/repos/42/pipelines?page=1&perPage=25", body: pipelines)
|
||||
|
||||
expect(client.list_pipelines("org", "game")).to eq(pipelines)
|
||||
expect(client.list_pipelines(42)).to eq(pipelines)
|
||||
end
|
||||
|
||||
it "gets latest pipeline" do
|
||||
pipeline = { "number" => 5, "status" => "running" }
|
||||
stub_wp(:get, "/api/repos/org/game/pipelines/latest", body: pipeline)
|
||||
stub_wp(:get, "/api/repos/42/pipelines/latest", body: pipeline)
|
||||
|
||||
expect(client.latest_pipeline("org", "game")).to eq(pipeline)
|
||||
expect(client.latest_pipeline(42)).to eq(pipeline)
|
||||
end
|
||||
|
||||
it "triggers a pipeline" do
|
||||
pipeline = { "number" => 6, "status" => "pending" }
|
||||
stub_wp(:post, "/api/repos/org/game/pipelines", body: pipeline)
|
||||
stub_wp(:post, "/api/repos/42/pipelines", body: pipeline)
|
||||
|
||||
expect(client.trigger_pipeline("org", "game", branch: "main")).to eq(pipeline)
|
||||
expect(client.trigger_pipeline(42, branch: "main")).to eq(pipeline)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -115,5 +115,13 @@ RSpec.describe WarpEngine::WoodpeckerClient do
|
||||
|
||||
expect { client.list_repos }.to raise_error(WarpEngine::WoodpeckerClient::ConnectionError)
|
||||
end
|
||||
|
||||
it "raises ApiError when a 200 response is not JSON" do
|
||||
stub_request(:get, "#{base_url}/api/repos")
|
||||
.to_return(status: 200, body: "<!doctype html><html></html>",
|
||||
headers: { "Content-Type" => "text/html" })
|
||||
|
||||
expect { client.list_repos }.to raise_error(WarpEngine::WoodpeckerClient::ApiError, /Expected JSON/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user