diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6c56519..bae0649 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -17,8 +17,17 @@ jobs: make-test-cover: runs-on: ubuntu-latest steps: + - uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- - uses: actions/setup-go@v4 - uses: actions/checkout@v3 + - run: go mod download - run: make test - run: go install github.com/mattn/goveralls@latest - run: goveralls -coverprofile=cover.out -service=github diff --git a/internal/controller/configmap_controller_test.go b/internal/controller/configmap_controller_test.go index 8e1dc6d..e8d3611 100644 --- a/internal/controller/configmap_controller_test.go +++ b/internal/controller/configmap_controller_test.go @@ -9,6 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" + "k8s.io/client-go/rest" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/reconcile" @@ -82,15 +83,20 @@ func TestConfigMapReconciler_SetupWithManager(t *testing.T) { t.Setenv("CONTROLLER_NAMESPACE", tc.namespaceEnv) t.Log(222) + fakeClient := newFakeClient(tc.objects...) + fakeClientFunc := func(config *rest.Config, options client.Options) (client.Client, error) { + return fakeClient, nil + } reconciler := &ConfigMapReconciler{ - Client: newFakeClient(tc.objects...), + Client: fakeClient, Scheme: newScheme(), RulesStore: rulesstore.New(), } t.Log(333) mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ - Scheme: newScheme(), + Scheme: newScheme(), + NewClient: fakeClientFunc, }) t.Log(444) assert.NoError(t, err)