Skip to content

Commit

Permalink
pkg/podres: update mocked PodResourcesListerClient
Browse files Browse the repository at this point in the history
Update mocked implementation of
k8s.io/kubelet/pkg/apis/podresources/v1.PodResourcesListerClient. The
mocked implementation is moved to a separate "mocks" subpackage as it's
for an external interface.

This patch also adds code for auto-generation for the mocked interface.
  • Loading branch information
marquiz committed Apr 18, 2023
1 parent ba4b9b3 commit e2d5ba1
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 81 deletions.
2 changes: 2 additions & 0 deletions pkg/podres/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.

package podres

//go:generate mockery --srcpkg=k8s.io/kubelet/pkg/apis/podresources/v1 --name PodResourcesListerClient

import (
"fmt"
"log"
Expand Down
78 changes: 0 additions & 78 deletions pkg/podres/mock_PodResourcesListerClient.go

This file was deleted.

132 changes: 132 additions & 0 deletions pkg/podres/mocks/PodResourcesListerClient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pkg/resourcemonitor/podresourcesscanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
v1 "k8s.io/kubelet/pkg/apis/podresources/v1"

"sigs.k8s.io/node-feature-discovery/pkg/apihelper"
"sigs.k8s.io/node-feature-discovery/pkg/podres"
mockv1 "sigs.k8s.io/node-feature-discovery/pkg/podres/mocks"
)

func TestPodScanner(t *testing.T) {
Expand All @@ -54,7 +54,7 @@ func TestPodScanner(t *testing.T) {
}

Convey("When I scan for pod resources using fake client and no namespace", t, func() {
mockPodResClient := new(podres.MockPodResourcesListerClient)
mockPodResClient := new(mockv1.PodResourcesListerClient)
mockAPIHelper := new(apihelper.MockAPIHelpers)
mockClient := &k8sclient.Clientset{}
computePodFingerprint := true
Expand Down Expand Up @@ -676,7 +676,7 @@ func TestPodScanner(t *testing.T) {
})

Convey("When I scan for pod resources using fake client and given namespace", t, func() {
mockPodResClient := new(podres.MockPodResourcesListerClient)
mockPodResClient := new(mockv1.PodResourcesListerClient)
mockAPIHelper := new(apihelper.MockAPIHelpers)
mockClient := &k8sclient.Clientset{}
computePodFingerprint := false
Expand Down

0 comments on commit e2d5ba1

Please sign in to comment.