Skip to content

Commit

Permalink
event-reporter: fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-codefresh committed Sep 27, 2024
1 parent 7e1f1c2 commit 472aa63
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions event_reporter/reporter/event_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package reporter

import (
"encoding/json"
"github.com/argoproj/argo-cd/v2/event_reporter/utils"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -18,7 +19,13 @@ import (

func TestGetResourceEventPayload(t *testing.T) {
t.Run("Deleting timestamp is empty", func(t *testing.T) {
app := v1alpha1.Application{}
app := v1alpha1.Application{
Spec: v1alpha1.ApplicationSpec{
Source: &v1alpha1.ApplicationSource{
RepoURL: "test",
},
},
}
rs := v1alpha1.ResourceStatus{}

man := "{ \"key\" : \"manifest\" }"
Expand All @@ -30,10 +37,14 @@ func TestGetResourceEventPayload(t *testing.T) {
CompiledManifest: "{ \"key\" : \"manifest\" }",
}
appTree := v1alpha1.ApplicationTree{}
revisionMetadata := v1alpha1.RevisionMetadata{
Author: "demo usert",
Date: metav1.Time{},
Message: "some message",
revisionMetadata := utils.AppSyncRevisionsMetadata{
SyncRevisions: []*utils.RevisionWithMetadata{&utils.RevisionWithMetadata{
Metadata: &v1alpha1.RevisionMetadata{
Author: "demo usert",
Date: metav1.Time{},
Message: "some message",
},
}},
}

event, err := getResourceEventPayload(&app, &rs, &actualState, &desiredState, &appTree, true, "", nil, &revisionMetadata, nil, common.LabelKeyAppInstance, argo.TrackingMethodLabel, &repoApiclient.ApplicationVersions{})
Expand All @@ -48,7 +59,7 @@ func TestGetResourceEventPayload(t *testing.T) {
assert.Equal(t, "{ \"key\" : \"manifest\" }", eventPayload.Source.ActualManifest)
})

t.Run("Deleting timestamp is empty", func(t *testing.T) {
t.Run("Deleting timestamp not empty", func(t *testing.T) {
app := v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
DeletionTimestamp: &metav1.Time{},
Expand All @@ -64,10 +75,8 @@ func TestGetResourceEventPayload(t *testing.T) {
CompiledManifest: "{ \"key\" : \"manifest\" }",
}
appTree := v1alpha1.ApplicationTree{}
revisionMetadata := v1alpha1.RevisionMetadata{
Author: "demo usert",
Date: metav1.Time{},
Message: "some message",
revisionMetadata := utils.AppSyncRevisionsMetadata{
SyncRevisions: []*utils.RevisionWithMetadata{},
}

event, err := getResourceEventPayload(&app, &rs, &actualState, &desiredState, &appTree, true, "", nil, &revisionMetadata, nil, common.LabelKeyAppInstance, argo.TrackingMethodLabel, &repoApiclient.ApplicationVersions{})
Expand Down

0 comments on commit 472aa63

Please sign in to comment.