Skip to content

Commit a2af4a7

Browse files
committed
fix: resolve lint issues in e2e tests
Extract shared string constants (deployerKeda, deployerRaw, oldFuncCLIVersion) to fix goconst warnings and add nolint:dupl directives on intentionally duplicated BeforeEach blocks.
1 parent 3212271 commit a2af4a7

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

‎test/e2e/e2e_test.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ const namespace = "func-operator-system"
3030
// serviceAccountName created for the project
3131
const serviceAccountName = "func-operator-controller-manager"
3232

33+
const (
34+
deployerKeda = "keda"
35+
deployerRaw = "raw"
36+
oldFuncCLIVersion = "v1.20.2"
37+
)
38+
3339
// logFailedTestDetails logs function resource and controller logs on test failure
3440
func logFailedTestDetails(functionName, functionNamespace string) {
3541
specReport := CurrentSpecReport()

‎test/e2e/func_deploy_test.go‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,9 @@ var _ = Describe("Operator", func() {
664664
var repoDir string
665665
var functionName, functionNamespace string
666666

667-
BeforeEach(func() {
668-
if os.Getenv("DEFAULT_DEPLOYER") == "keda" || os.Getenv("DEFAULT_DEPLOYER") == "raw" {
667+
BeforeEach(func() { //nolint:dupl
668+
if os.Getenv("DEFAULT_DEPLOYER") == deployerKeda ||
669+
os.Getenv("DEFAULT_DEPLOYER") == deployerRaw {
669670
Skip("Skipping registry auth test for Keda & raw deployer, " +
670671
"as those are not supported on used CLI version (1.20.x) of this tests")
671672
}
@@ -684,7 +685,7 @@ var _ = Describe("Operator", func() {
684685
Expect(err).NotTo(HaveOccurred())
685686
utils.DeferCleanupOnSuccess(cleanupNamespaces, functionNamespace)
686687

687-
oldFuncVersion := "v1.20.2"
688+
oldFuncVersion := oldFuncCLIVersion
688689
repoDir, err = utils.InitializeRepoWithFunction(
689690
repoURL,
690691
username,

‎test/e2e/func_middleware_update_test.go‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ var _ = Describe("Middleware Update", func() {
4444
var repoDir string
4545
var functionName, functionNamespace string
4646

47-
BeforeEach(func() {
48-
if os.Getenv("DEFAULT_DEPLOYER") == "keda" || os.Getenv("DEFAULT_DEPLOYER") == "raw" {
47+
BeforeEach(func() { //nolint:dupl
48+
if os.Getenv("DEFAULT_DEPLOYER") == deployerKeda ||
49+
os.Getenv("DEFAULT_DEPLOYER") == deployerRaw {
4950
Skip("Skipping middleware test for Keda & raw deployer, " +
5051
"as those are not supported on used CLI version (1.20.x) of this tests")
5152
}
@@ -67,7 +68,7 @@ var _ = Describe("Middleware Update", func() {
6768

6869
// Initialize repository with function code using OLD func CLI version
6970
// v1.20.2 has no middleware-version label and uses instance-compatible templates
70-
oldFuncVersion := "v1.20.2"
71+
oldFuncVersion := oldFuncCLIVersion
7172
repoDir, err = utils.InitializeRepoWithFunction(
7273
repoURL,
7374
username,
@@ -253,7 +254,8 @@ var _ = Describe("Middleware Update", func() {
253254
var originalConfigMapData map[string]string
254255

255256
BeforeEach(func() {
256-
if os.Getenv("DEFAULT_DEPLOYER") == "keda" || os.Getenv("DEFAULT_DEPLOYER") == "raw" {
257+
if os.Getenv("DEFAULT_DEPLOYER") == deployerKeda ||
258+
os.Getenv("DEFAULT_DEPLOYER") == deployerRaw {
257259
Skip("Skipping middleware test for Keda & raw deployer, " +
258260
"as those are not supported on used CLI version (1.20.x) of this tests")
259261
}
@@ -302,7 +304,7 @@ var _ = Describe("Middleware Update", func() {
302304

303305
// Initialize repository with function code using OLD func CLI version
304306
// to ensure middleware will be outdated
305-
oldFuncVersion := "v1.20.2"
307+
oldFuncVersion := oldFuncCLIVersion
306308
repoDir, err = utils.InitializeRepoWithFunction(
307309
repoURL,
308310
username,

0 commit comments

Comments
 (0)