@@ -21,7 +21,6 @@ import (
21
21
"path"
22
22
"path/filepath"
23
23
"testing"
24
- "time"
25
24
26
25
"github.com/stretchr/testify/assert"
27
26
"github.com/stretchr/testify/require"
@@ -38,54 +37,10 @@ import (
38
37
config "github.com/pipe-cd/pipecd/pkg/configv1"
39
38
"github.com/pipe-cd/pipecd/pkg/model"
40
39
"github.com/pipe-cd/pipecd/pkg/plugin/api/v1alpha1/deployment"
41
- "github.com/pipe-cd/pipecd/pkg/plugin/logpersister"
40
+ "github.com/pipe-cd/pipecd/pkg/plugin/logpersister/logpersistertest "
42
41
"github.com/pipe-cd/pipecd/pkg/plugin/toolregistry/toolregistrytest"
43
42
)
44
43
45
- // newTestLogPersister creates a new testLogPersister for testing.
46
- //
47
- // TODO: move to a common package
48
- func newTestLogPersister (t * testing.T ) testLogPersister {
49
- return testLogPersister {t }
50
- }
51
-
52
- // testLogPersister implements logpersister for testing.
53
- type testLogPersister struct {
54
- t * testing.T
55
- }
56
-
57
- func (lp testLogPersister ) StageLogPersister (deploymentID , stageID string ) logpersister.StageLogPersister {
58
- return lp
59
- }
60
-
61
- func (lp testLogPersister ) Write (log []byte ) (int , error ) {
62
- // Write the log to the test logger
63
- lp .t .Log (string (log ))
64
- return 0 , nil
65
- }
66
- func (lp testLogPersister ) Info (log string ) {
67
- lp .t .Log ("INFO" , log )
68
- }
69
- func (lp testLogPersister ) Infof (format string , a ... interface {}) {
70
- lp .t .Logf ("INFO " + format , a ... )
71
- }
72
- func (lp testLogPersister ) Success (log string ) {
73
- lp .t .Log ("SUCCESS" , log )
74
- }
75
- func (lp testLogPersister ) Successf (format string , a ... interface {}) {
76
- lp .t .Logf ("SUCCESS " + format , a ... )
77
- }
78
- func (lp testLogPersister ) Error (log string ) {
79
- lp .t .Log ("ERROR" , log )
80
- }
81
- func (lp testLogPersister ) Errorf (format string , a ... interface {}) {
82
- lp .t .Logf ("ERROR " + format , a ... )
83
- }
84
- func (lp testLogPersister ) Complete (timeout time.Duration ) error {
85
- lp .t .Logf ("Complete stage log persister with timeout: %v" , timeout )
86
- return nil
87
- }
88
-
89
44
// TODO: move to a common package
90
45
func examplesDir () string {
91
46
d , _ := os .Getwd ()
@@ -191,7 +146,7 @@ func TestDeploymentService_executeK8sSyncStage(t *testing.T) {
191
146
},
192
147
}
193
148
194
- svc := NewDeploymentService (pluginCfg , zaptest .NewLogger (t ), testRegistry , newTestLogPersister (t ))
149
+ svc := NewDeploymentService (pluginCfg , zaptest .NewLogger (t ), testRegistry , logpersistertest . NewTestLogPersister (t ))
195
150
resp , err := svc .ExecuteStage (ctx , req )
196
151
197
152
require .NoError (t , err )
0 commit comments