Skip to content

Commit 1ec4a23

Browse files
authored
Remove ginkgo from api tests (#399)
This is related to epic #189, although there doesn't seem to be a related issue for this directory. Signed-off-by: Todd Short <[email protected]>
1 parent 98e3e2e commit 1ec4a23

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

api/v1alpha1/operator_types_test.go

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,49 @@ import (
88
"io/fs"
99
"strconv"
1010
"strings"
11-
12-
. "github.com/onsi/ginkgo/v2"
13-
. "github.com/onsi/gomega"
11+
"testing"
1412

1513
"github.com/operator-framework/operator-controller/internal/conditionsets"
14+
15+
"golang.org/x/exp/slices" // replace with "slices" in go 1.21
1616
)
1717

18-
var _ = Describe("OperatorTypes", func() {
19-
Describe("Condition Type and Reason constants", func() {
20-
It("should register types in conditionsets.ConditionTypes", func() {
21-
types, err := parseConstants("Type")
22-
Expect(err).NotTo(HaveOccurred())
18+
func TestOperatorTypeRegistration(t *testing.T) {
19+
types, err := parseConstants("Type")
20+
if err != nil {
21+
t.Fatalf("unable to parse Type constants %v", err)
22+
}
2323

24-
for _, t := range types {
25-
Expect(t).To(BeElementOf(conditionsets.ConditionTypes), "Append Type%s to conditionsets.ConditionTypes in this package's init function.", t)
26-
}
27-
for _, t := range conditionsets.ConditionTypes {
28-
Expect(t).To(BeElementOf(types), "There must be a Type%[1]s string literal constant for type %[1]q (i.e. 'const Type%[1]s = %[1]q')", t)
29-
}
30-
})
31-
It("should register reasons in conditionsets.ConditionReasons", func() {
32-
reasons, err := parseConstants("Reason")
33-
Expect(err).NotTo(HaveOccurred())
24+
for _, tt := range types {
25+
if !slices.Contains(conditionsets.ConditionTypes, tt) {
26+
t.Errorf("append Type%s to conditionsets.ConditionTypes in this package's init function", tt)
27+
}
28+
}
3429

35-
for _, r := range reasons {
36-
Expect(r).To(BeElementOf(conditionsets.ConditionReasons), "Append Reason%s to conditionsets.ConditionReasons in this package's init function.", r)
37-
}
38-
for _, r := range conditionsets.ConditionReasons {
39-
Expect(r).To(BeElementOf(reasons), "There must be a Reason%[1]s string literal constant for reason %[1]q (i.e. 'const Reason%[1]s = %[1]q')", r)
40-
}
41-
})
42-
})
43-
})
30+
for _, tt := range conditionsets.ConditionTypes {
31+
if !slices.Contains(types, tt) {
32+
t.Errorf("there must be a Type%[1]s string literal constant for type %[1]q (i.e. 'const Type%[1]s = %[1]q')", tt)
33+
}
34+
}
35+
}
36+
37+
func TestOperatorReasonRegistration(t *testing.T) {
38+
reasons, err := parseConstants("Reason")
39+
if err != nil {
40+
t.Fatalf("unable to parse Reason constants %v", err)
41+
}
42+
43+
for _, r := range reasons {
44+
if !slices.Contains(conditionsets.ConditionReasons, r) {
45+
t.Errorf("append Reason%s to conditionsets.ConditionReasons in this package's init function.", r)
46+
}
47+
}
48+
for _, r := range conditionsets.ConditionReasons {
49+
if !slices.Contains(reasons, r) {
50+
t.Errorf("there must be a Reason%[1]s string literal constant for reason %[1]q (i.e. 'const Reason%[1]s = %[1]q')", r)
51+
}
52+
}
53+
}
4454

4555
// parseConstants parses the values of the top-level constants in the current
4656
// directory whose names start with the given prefix. When running as part of a

api/v1alpha1/v1alpha1_suite_test.go

Lines changed: 0 additions & 13 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ require (
1616
github.com/spf13/pflag v1.0.5
1717
github.com/stretchr/testify v1.8.4
1818
go.uber.org/zap v1.25.0
19+
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0
1920
k8s.io/apiextensions-apiserver v0.26.1
2021
k8s.io/apimachinery v0.26.1
2122
k8s.io/client-go v0.26.1

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
940940
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
941941
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
942942
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
943+
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0 h1:pVgRXcIictcr+lBQIFeiwuwtDIs4eL21OuM9nyAADmo=
944+
golang.org/x/exp v0.0.0-20230315142452-642cacee5cc0/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
943945
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
944946
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
945947
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=

0 commit comments

Comments
 (0)