Skip to content

Commit 5cda731

Browse files
committed
Add unit tests for pkg/utils/client
1 parent e4115f7 commit 5cda731

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Copyright 2025 Tim Ebert.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package client_test
18+
19+
import (
20+
"testing"
21+
22+
. "github.com/onsi/ginkgo/v2"
23+
. "github.com/onsi/gomega"
24+
)
25+
26+
func TestClient(t *testing.T) {
27+
RegisterFailHandler(Fail)
28+
RunSpecs(t, "Client Utils Suite")
29+
}

pkg/utils/client/options_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
Copyright 2025 Tim Ebert.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package client_test
18+
19+
import (
20+
. "github.com/onsi/ginkgo/v2"
21+
. "github.com/onsi/gomega"
22+
"sigs.k8s.io/controller-runtime/pkg/client"
23+
24+
. "github.com/timebertt/kubernetes-controller-sharding/pkg/utils/client"
25+
)
26+
27+
var _ = Describe("ResourceVersion", func() {
28+
It("should set the resourceVersion on GetOptions", func() {
29+
opts := &client.GetOptions{}
30+
opts.ApplyOptions([]client.GetOption{ResourceVersion("1")})
31+
32+
Expect(opts.Raw.ResourceVersion).To(Equal("1"))
33+
})
34+
35+
It("should set the resourceVersion on ListOptions", func() {
36+
opts := &client.ListOptions{}
37+
opts.ApplyOptions([]client.ListOption{ResourceVersion("1")})
38+
39+
Expect(opts.Raw.ResourceVersion).To(Equal("1"))
40+
})
41+
})

0 commit comments

Comments
 (0)