Skip to content

Commit

Permalink
fix broken after merge unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-codefresh committed Jan 6, 2025
1 parent f087fad commit d2b88a2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 20 deletions.
2 changes: 2 additions & 0 deletions event_reporter/reporter/event_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ import (
func getMockedArgoTrackingMetadata() *ArgoTrackingMetadata {
appInstanceLabelKey := common.LabelKeyAppInstance
trackingMethod := argo.TrackingMethodLabel
installationID := ""

return &ArgoTrackingMetadata{
AppInstanceLabelKey: &appInstanceLabelKey,
TrackingMethod: &trackingMethod,
InstallationID: &installationID,
}
}

Expand Down
8 changes: 4 additions & 4 deletions reposerver/repository/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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{
Expand Down
3 changes: 1 addition & 2 deletions reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
14 changes: 0 additions & 14 deletions util/db/repository_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("[email protected]:argoproj/argoproj.git"),
"username": []byte("someOtherUsername"),
"password": []byte("someOtherPassword"),
"project": []byte("testProject"),
},
},
}

clientset := getClientset(map[string]string{}, repoSecrets...)
Expand Down

0 comments on commit d2b88a2

Please sign in to comment.