From d2b88a2f8c98d222f7d9298843d9181e0be1427c Mon Sep 17 00:00:00 2001 From: oleksandr-codefresh Date: Mon, 6 Jan 2025 16:10:25 +0200 Subject: [PATCH] fix broken after merge unit tests --- event_reporter/reporter/event_payload_test.go | 2 ++ reposerver/repository/repository.go | 8 ++++---- reposerver/repository/repository_test.go | 3 +-- util/db/repository_secrets_test.go | 14 -------------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/event_reporter/reporter/event_payload_test.go b/event_reporter/reporter/event_payload_test.go index 87e22e7a2cb36..0069705e7260e 100644 --- a/event_reporter/reporter/event_payload_test.go +++ b/event_reporter/reporter/event_payload_test.go @@ -21,10 +21,12 @@ import ( func getMockedArgoTrackingMetadata() *ArgoTrackingMetadata { appInstanceLabelKey := common.LabelKeyAppInstance trackingMethod := argo.TrackingMethodLabel + installationID := "" return &ArgoTrackingMetadata{ AppInstanceLabelKey: &appInstanceLabelKey, TrackingMethod: &trackingMethod, + InstallationID: &installationID, } } diff --git a/reposerver/repository/repository.go b/reposerver/repository/repository.go index 4dd30345eb1cb..4ed48b24c949a 100644 --- a/reposerver/repository/repository.go +++ b/reposerver/repository/repository.go @@ -1576,8 +1576,8 @@ func GenerateManifests(ctx context.Context, appPath, repoRoot, revision string, return nil, err } - resManifests := make([]*apiclient.Manifest, len(manifests)) - for i, m := range manifests { + resManifests := make([]*apiclient.Manifest, 0) + for _, m := range manifests { if q.AppLabelKey != "" && q.AppName != "" && !kube.IsCRD(m.obj) { err = resourceTracking.SetAppInstance(m.obj, q.AppLabelKey, q.AppName, q.Namespace, v1alpha1.TrackingMethod(q.TrackingMethod), q.InstallationID) if err != nil { @@ -1590,12 +1590,12 @@ func GenerateManifests(ctx context.Context, appPath, repoRoot, revision string, return nil, err } - resManifests[i] = &apiclient.Manifest{ + resManifests = append(resManifests, &apiclient.Manifest{ CompiledManifest: string(manifestStr), RawManifest: string(m.rawManifest), Path: m.path, Line: int32(m.line), - } + }) } res := apiclient.ManifestResponse{ diff --git a/reposerver/repository/repository_test.go b/reposerver/repository/repository_test.go index b4d3824580aab..ade6e70834b18 100644 --- a/reposerver/repository/repository_test.go +++ b/reposerver/repository/repository_test.go @@ -113,7 +113,6 @@ func newServiceWithMocks(t *testing.T, root string, signed bool) (*Service, *git gitClient.On("CommitSHA").Return(mock.Anything, nil) gitClient.On("Root").Return(root) gitClient.On("IsAnnotatedTag").Return(false) - gitClient.On("RevisionMetadata", mock.Anything).Return(nil, errors.New("cant fetch metadata")) if signed { gitClient.On("VerifyCommitSignature", mock.Anything).Return(testSignature, nil) } else { @@ -683,7 +682,7 @@ func TestRecurseManifestsInDir(t *testing.T) { res1, err := service.GenerateManifest(context.Background(), &q) require.NoError(t, err) - assert.Len(t, res1.Manifests, 2) + assert.Len(t, res1.Manifests, 4) } func TestInvalidManifestsInDir(t *testing.T) { diff --git a/util/db/repository_secrets_test.go b/util/db/repository_secrets_test.go index 3dc160f0b71a1..0a74a9806f5cb 100644 --- a/util/db/repository_secrets_test.go +++ b/util/db/repository_secrets_test.go @@ -206,20 +206,6 @@ func TestSecretsRepositoryBackend_GetRepository(t *testing.T) { "project": []byte("testProject"), }, }, - &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Namespace: testNamespace, - Name: "other-user-managed", - Labels: map[string]string{common.LabelKeySecretType: common.LabelValueSecretTypeRepository}, - }, - Data: map[string][]byte{ - "name": []byte("Scoped UserManagedRepo"), - "url": []byte("git@github.com:argoproj/argoproj.git"), - "username": []byte("someOtherUsername"), - "password": []byte("someOtherPassword"), - "project": []byte("testProject"), - }, - }, } clientset := getClientset(map[string]string{}, repoSecrets...)