Return error status
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
import requests
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app.main import app
|
||||
@@ -106,3 +107,16 @@ def test_build_history(monkeypatch):
|
||||
assert second["status"] == "running"
|
||||
assert second["duration_seconds"] == 1
|
||||
assert second["commits"] == []
|
||||
|
||||
|
||||
def test_build_history_error_returns_empty(monkeypatch):
|
||||
def raise_error(limit=5):
|
||||
raise requests.RequestException("boom")
|
||||
|
||||
monkeypatch.setattr("app.services.builds.fetch_builds", raise_error)
|
||||
|
||||
response = client.get("/builds")
|
||||
assert response.status_code == 503
|
||||
body = response.json()
|
||||
assert body["builds"] == []
|
||||
assert body["error"] == "jenkins_unavailable"
|
||||
|
||||
Reference in New Issue
Block a user