Skip to content

Commit 267d30f

Browse files
author
Per Goncalves da Silva
committed
Fix up crd-generator unit tests
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent b3020f0 commit 267d30f

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

hack/tools/crd-generator/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ the experimental CRD when feature gates are enabled.
5050
* End Tag: `</opcon:util:excludeFromCRD>`
5151

5252
Descriptive text that is excluded from the CRD description. This is similar to the use of `---`, except
53-
the three hypens excludes *all* following text.
53+
the three hyphens excludes *all* following text.

hack/tools/crd-generator/main_test.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import (
77
"path/filepath"
88
"testing"
99

10+
"github.com/google/go-cmp/cmp"
1011
"github.com/stretchr/testify/require"
1112
)
1213

14+
const (
15+
controllerToolsVersion = "v0.19.0"
16+
)
17+
1318
func TestRunGenerator(t *testing.T) {
1419
here, err := os.Getwd()
1520
require.NoError(t, err)
@@ -24,7 +29,7 @@ func TestRunGenerator(t *testing.T) {
2429
defer os.RemoveAll(dir)
2530
require.NoError(t, os.Mkdir(filepath.Join(dir, "standard"), 0o700))
2631
require.NoError(t, os.Mkdir(filepath.Join(dir, "experimental"), 0o700))
27-
runGenerator(dir, "v0.18.0")
32+
runGenerator(dir, "v0.19.0")
2833

2934
f1 := filepath.Join(dir, "standard/olm.operatorframework.io_clusterextensions.yaml")
3035
f2 := "config/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml"
@@ -60,7 +65,7 @@ func TestTags(t *testing.T) {
6065
defer os.RemoveAll(dir)
6166
require.NoError(t, os.Mkdir(filepath.Join(dir, "standard"), 0o700))
6267
require.NoError(t, os.Mkdir(filepath.Join(dir, "experimental"), 0o700))
63-
runGenerator(dir, "v0.18.0", "github.com/operator-framework/operator-controller/hack/tools/crd-generator/testdata/api/v1")
68+
runGenerator(dir, controllerToolsVersion, "github.com/operator-framework/operator-controller/hack/tools/crd-generator/testdata/api/v1")
6469

6570
f1 := filepath.Join(dir, "standard/olm.operatorframework.io_clusterextensions.yaml")
6671
f2 := "output/standard/olm.operatorframework.io_clusterextensions.yaml"
@@ -98,6 +103,10 @@ func compareFiles(t *testing.T, file1, file2 string) {
98103
}
99104
require.NoError(t, err1)
100105
require.NoError(t, err2)
106+
diff := cmp.Diff(string(b1), string(b2))
107+
if diff != "" {
108+
t.Errorf("unexpected channel diff (-expected +received):\n%s", diff)
109+
}
101110
require.Equal(t, n1, n2)
102111
require.Equal(t, b1, b2)
103112
}

hack/tools/crd-generator/testdata/output/experimental/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.18.0
6+
controller-gen.kubebuilder.io/version: v0.19.0
77
olm.operatorframework.io/generator: experimental
88
name: clusterextensions.olm.operatorframework.io
99
spec:

hack/tools/crd-generator/testdata/output/standard/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
annotations:
6-
controller-gen.kubebuilder.io/version: v0.18.0
6+
controller-gen.kubebuilder.io/version: v0.19.0
77
olm.operatorframework.io/generator: standard
88
name: clusterextensions.olm.operatorframework.io
99
spec:

0 commit comments

Comments
 (0)