-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(operator): consider corner cases in KACR controller (#1270)
Signed-off-by: Florian Bacher <[email protected]>
- Loading branch information
Showing
7 changed files
with
417 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
operator/apis/lifecycle/v1alpha3/keptnworkload_types_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package v1alpha3 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
func TestKeptnWorkload_GetNameWithoutAppPrefix(t *testing.T) { | ||
type fields struct { | ||
ObjectMeta v1.ObjectMeta | ||
Spec KeptnWorkloadSpec | ||
} | ||
tests := []struct { | ||
name string | ||
fields fields | ||
want string | ||
}{ | ||
{ | ||
name: "remove app prefix", | ||
fields: fields{ | ||
ObjectMeta: v1.ObjectMeta{ | ||
Name: "my-app-my-workload", | ||
}, | ||
Spec: KeptnWorkloadSpec{ | ||
AppName: "my-app", | ||
}, | ||
}, | ||
want: "my-workload", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
w := KeptnWorkload{ | ||
ObjectMeta: tt.fields.ObjectMeta, | ||
Spec: tt.fields.Spec, | ||
} | ||
got := w.GetNameWithoutAppPrefix() | ||
|
||
require.Equal(t, tt.want, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.