mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
Signed-off-by: fpetr <petr.frantisek@gmail.com> Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: fpetr <111520435+fpetr@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
@@ -132,7 +132,11 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
status = app.Status.Sync.Status
|
||||
applicationName = name[0]
|
||||
if app.Status.OperationState != nil && app.Status.OperationState.SyncResult != nil {
|
||||
revision = app.Status.OperationState.SyncResult.Revision
|
||||
if len(app.Status.OperationState.SyncResult.Revisions) > 0 {
|
||||
revision = app.Status.OperationState.SyncResult.Revisions[0]
|
||||
} else {
|
||||
revision = app.Status.OperationState.SyncResult.Revision
|
||||
}
|
||||
}
|
||||
} else if errors.IsNotFound(err) {
|
||||
notFound = true
|
||||
|
||||
@@ -451,6 +451,24 @@ func TestHandlerRevisionIsEnabledShortCommitSHA(t *testing.T) {
|
||||
assert.Contains(t, response, "(abc)")
|
||||
}
|
||||
|
||||
func TestHandlerRevisionIsEnabledMultipleSources(t *testing.T) {
|
||||
app := testApp()
|
||||
app.Status.OperationState.SyncResult.Revision = ""
|
||||
app.Status.OperationState.SyncResult.Revisions = []string{"aa29b85", "cf41g63"}
|
||||
|
||||
settingsMgr := settings.NewSettingsManager(t.Context(), fake.NewClientset(argoCDCm(), argoCDSecret()), "default")
|
||||
handler := NewHandler(appclientset.NewSimpleClientset(app), settingsMgr, "default", []string{})
|
||||
req, err := http.NewRequest(http.MethodGet, "/api/badge?name=test-app&revision=true", http.NoBody)
|
||||
require.NoError(t, err)
|
||||
|
||||
rr := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rr, req)
|
||||
|
||||
response := rr.Body.String()
|
||||
assert.Contains(t, response, "(aa29b85)")
|
||||
assert.NotContains(t, response, "(cf41g63)")
|
||||
}
|
||||
|
||||
func TestHandlerFeatureIsDisabled(t *testing.T) {
|
||||
argoCDCmDisabled := argoCDCm()
|
||||
delete(argoCDCmDisabled.Data, "statusbadge.enabled")
|
||||
|
||||
Reference in New Issue
Block a user