Skip to content

Commit 62881a7

Browse files
authored
Codecov (#11)
1 parent 51b1d56 commit 62881a7

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Argo CD Executor Plugin
22

3+
[![codecov](https://codecov.io/gh/crenshaw-dev/argocd-executor-plugin/branch/main/graph/badge.svg?token=SJN00EHK79)](https://codecov.io/gh/crenshaw-dev/argocd-executor-plugin)
34

45
An [Executor Plugin](https://github.com/argoproj/argo-workflows/blob/master/docs/executor_plugins.md) for
56
Argo Workflows that lets you interact with Argo CD servers. All you need is an Argo CD API token.

internal/diff_test.go

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package argocd
2+
3+
import (
4+
"testing"
5+
6+
"github.com/argoproj/gitops-engine/pkg/utils/kube"
7+
"github.com/stretchr/testify/assert"
8+
"github.com/stretchr/testify/require"
9+
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
10+
11+
"github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
12+
)
13+
14+
func Test_getRefreshType(t *testing.T) {
15+
t.Parallel()
16+
17+
var no *string
18+
normal := string(v1alpha1.RefreshTypeNormal)
19+
hard := string(v1alpha1.RefreshTypeHard)
20+
21+
t.Run("no refresh", func(t *testing.T) {
22+
assert.Equal(t, no, getRefreshType(false, false))
23+
})
24+
25+
t.Run("normal refresh", func(t *testing.T) {
26+
assert.Equal(t, &normal, getRefreshType(true, false))
27+
})
28+
29+
t.Run("hard refresh", func(t *testing.T) {
30+
assert.Equal(t, &hard, getRefreshType(false, true))
31+
assert.Equal(t, &hard, getRefreshType(true, true))
32+
})
33+
}
34+
35+
func Test_groupObjsByKey(t *testing.T) {
36+
t.Parallel()
37+
38+
t.Run("single", func(t *testing.T) {
39+
localObjs := []*unstructured.Unstructured{
40+
{
41+
Object: map[string]interface{}{
42+
"apiVersion": "apps/v1",
43+
"kind": "Deployment",
44+
"metadata": map[string]interface{}{
45+
"name": "my-deployment",
46+
"namespace": "my-namespace",
47+
},
48+
},
49+
},
50+
}
51+
grouped, err := groupObjsByKey(localObjs, localObjs, "my-namespace")
52+
require.NoError(t, err)
53+
assert.Equal(t, map[kube.ResourceKey]*unstructured.Unstructured{
54+
kube.ResourceKey{
55+
Group: "apps",
56+
Kind: "Deployment",
57+
Name: "my-deployment",
58+
Namespace: "my-namespace",
59+
}: localObjs[0],
60+
}, grouped)
61+
})
62+
}

0 commit comments

Comments
 (0)