github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/engine/pkg/externalresource/internal/local/resource_controller_test.go (about) 1 // Copyright 2022 PingCAP, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package local 15 16 import ( 17 "context" 18 "testing" 19 20 "github.com/golang/mock/gomock" 21 "github.com/pingcap/tiflow/engine/pkg/client" 22 resModel "github.com/pingcap/tiflow/engine/pkg/externalresource/model" 23 "github.com/stretchr/testify/require" 24 ) 25 26 func TestRemoveFileOnExecutor(t *testing.T) { 27 clientGroup := client.NewMockExecutorGroup() 28 mockCli := client.NewMockExecutorClient(gomock.NewController(t)) 29 clientGroup.AddClient("executor-1", mockCli) 30 31 resourceTp := NewFileResourceController(clientGroup) 32 gcHandler := resourceTp.GCSingleResource 33 34 resMeta := &resModel.ResourceMeta{ 35 ID: "resource-1", 36 Job: "job-1", 37 Worker: "worker-1", 38 Executor: "executor-1", 39 } 40 41 mockCli.EXPECT(). 42 RemoveResource(gomock.Any(), "worker-1", "resource-1"). 43 Return(nil).Times(1) 44 45 err := gcHandler(context.Background(), resMeta) 46 require.NoError(t, err) 47 }