1
1
package logging
2
2
3
3
import (
4
- "context"
5
4
"testing"
6
5
7
6
"github.com/aws/aws-sdk-go/aws"
8
7
"github.com/aws/aws-sdk-go/aws/awserr"
9
- "github.com/aws/aws-sdk-go/aws/request"
10
8
"github.com/aws/aws-sdk-go/service/cloudwatchlogs"
11
9
"github.com/aws/aws-sdk-go/service/cloudwatchlogs/cloudwatchlogsiface"
12
10
)
13
11
14
12
func TestCloudWatchLogProvider (t * testing.T ) {
15
13
t .Run ("Init" , func (t * testing.T ) {
16
14
client := CallbackCloudWatchLogs {
17
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
15
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
18
16
return & cloudwatchlogs.DescribeLogGroupsOutput {
19
17
LogGroups : []* cloudwatchlogs.LogGroup {
20
18
& cloudwatchlogs.LogGroup {LogGroupName : input .LogGroupNamePrefix },
21
19
},
22
20
}, nil
23
21
},
24
22
25
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
23
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
26
24
return nil , nil
27
25
},
28
26
29
- CreateLogStreamFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
27
+ CreateLogStreamFn : func (input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
30
28
return nil , nil
31
29
},
32
30
@@ -45,15 +43,15 @@ func TestCloudWatchLogProvider(t *testing.T) {
45
43
46
44
t .Run ("Init Error Exists" , func (t * testing.T ) {
47
45
client := CallbackCloudWatchLogs {
48
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
46
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
49
47
return nil , awserr .New ("Invalid" , "Invalid" , nil )
50
48
},
51
49
52
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
50
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
53
51
return nil , nil
54
52
},
55
53
56
- CreateLogStreamFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
54
+ CreateLogStreamFn : func (input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
57
55
return nil , nil
58
56
},
59
57
@@ -72,17 +70,17 @@ func TestCloudWatchLogProvider(t *testing.T) {
72
70
73
71
t .Run ("Init Error Unable to Create" , func (t * testing.T ) {
74
72
client := CallbackCloudWatchLogs {
75
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
73
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
76
74
return & cloudwatchlogs.DescribeLogGroupsOutput {
77
75
LogGroups : []* cloudwatchlogs.LogGroup {},
78
76
}, nil
79
77
},
80
78
81
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
79
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
82
80
return nil , awserr .New ("Invalid" , "Invalid" , nil )
83
81
},
84
82
85
- CreateLogStreamFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
83
+ CreateLogStreamFn : func (input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
86
84
return nil , nil
87
85
},
88
86
@@ -101,19 +99,19 @@ func TestCloudWatchLogProvider(t *testing.T) {
101
99
102
100
t .Run ("Write" , func (t * testing.T ) {
103
101
client := CallbackCloudWatchLogs {
104
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
102
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
105
103
return & cloudwatchlogs.DescribeLogGroupsOutput {
106
104
LogGroups : []* cloudwatchlogs.LogGroup {
107
105
& cloudwatchlogs.LogGroup {LogGroupName : input .LogGroupNamePrefix },
108
106
},
109
107
}, nil
110
108
},
111
109
112
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
110
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
113
111
return nil , nil
114
112
},
115
113
116
- CreateLogStreamFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
114
+ CreateLogStreamFn : func (input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
117
115
return nil , nil
118
116
},
119
117
@@ -143,19 +141,19 @@ func TestCloudWatchLogProvider(t *testing.T) {
143
141
t .Run ("Write Error" , func (t * testing.T ) {
144
142
writeCount := 0
145
143
client := CallbackCloudWatchLogs {
146
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
144
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
147
145
return & cloudwatchlogs.DescribeLogGroupsOutput {
148
146
LogGroups : []* cloudwatchlogs.LogGroup {
149
147
& cloudwatchlogs.LogGroup {LogGroupName : input .LogGroupNamePrefix },
150
148
},
151
149
}, nil
152
150
},
153
151
154
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
152
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
155
153
return nil , nil
156
154
},
157
155
158
- CreateLogStreamFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
156
+ CreateLogStreamFn : func (input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
159
157
return nil , nil
160
158
},
161
159
@@ -187,7 +185,7 @@ func TestCloudWatchLogProvider(t *testing.T) {
187
185
func TestCloudWatchLogGroupExists (t * testing.T ) {
188
186
t .Run ("Success" , func (t * testing.T ) {
189
187
client := CallbackCloudWatchLogs {
190
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
188
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
191
189
return & cloudwatchlogs.DescribeLogGroupsOutput {
192
190
LogGroups : []* cloudwatchlogs.LogGroup {
193
191
& cloudwatchlogs.LogGroup {LogGroupName : input .LogGroupNamePrefix },
@@ -203,7 +201,7 @@ func TestCloudWatchLogGroupExists(t *testing.T) {
203
201
204
202
t .Run ("Error" , func (t * testing.T ) {
205
203
client := CallbackCloudWatchLogs {
206
- DescribeLogGroupsFn : func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
204
+ DescribeLogGroupsFn : func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
207
205
return nil , awserr .New ("Invalid" , "Invalid" , nil )
208
206
},
209
207
}
@@ -217,7 +215,7 @@ func TestCloudWatchLogGroupExists(t *testing.T) {
217
215
func TestCreateCloudWatchLogGroup (t * testing.T ) {
218
216
t .Run ("Success" , func (t * testing.T ) {
219
217
client := CallbackCloudWatchLogs {
220
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
218
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
221
219
return nil , nil
222
220
},
223
221
}
@@ -229,7 +227,7 @@ func TestCreateCloudWatchLogGroup(t *testing.T) {
229
227
230
228
t .Run ("Error" , func (t * testing.T ) {
231
229
client := CallbackCloudWatchLogs {
232
- CreateLogGroupFn : func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
230
+ CreateLogGroupFn : func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
233
231
return nil , awserr .New ("Invalid" , "Invalid" , nil )
234
232
},
235
233
}
@@ -243,22 +241,22 @@ func TestCreateCloudWatchLogGroup(t *testing.T) {
243
241
type CallbackCloudWatchLogs struct {
244
242
cloudwatchlogsiface.CloudWatchLogsAPI
245
243
246
- DescribeLogGroupsFn func (ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error )
247
- CreateLogGroupFn func (ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error )
248
- CreateLogStreamFn func (ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error )
244
+ DescribeLogGroupsFn func (input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error )
245
+ CreateLogGroupFn func (input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error )
246
+ CreateLogStreamFn func (input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error )
249
247
PutLogEventsFn func (input * cloudwatchlogs.PutLogEventsInput ) (* cloudwatchlogs.PutLogEventsOutput , error )
250
248
}
251
249
252
- func (cwl CallbackCloudWatchLogs ) DescribeLogGroupsWithContext ( ctx context. Context , input * cloudwatchlogs.DescribeLogGroupsInput , opts ... request. Option ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
253
- return cwl .DescribeLogGroupsFn (ctx , input )
250
+ func (cwl CallbackCloudWatchLogs ) DescribeLogGroups ( input * cloudwatchlogs.DescribeLogGroupsInput ) (* cloudwatchlogs.DescribeLogGroupsOutput , error ) {
251
+ return cwl .DescribeLogGroupsFn (input )
254
252
}
255
253
256
- func (cwl CallbackCloudWatchLogs ) CreateLogGroupWithContext ( ctx context. Context , input * cloudwatchlogs.CreateLogGroupInput , opts ... request. Option ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
257
- return cwl .CreateLogGroupFn (ctx , input )
254
+ func (cwl CallbackCloudWatchLogs ) CreateLogGroup ( input * cloudwatchlogs.CreateLogGroupInput ) (* cloudwatchlogs.CreateLogGroupOutput , error ) {
255
+ return cwl .CreateLogGroupFn (input )
258
256
}
259
257
260
- func (cwl CallbackCloudWatchLogs ) CreateLogStreamWithContext ( ctx context. Context , input * cloudwatchlogs.CreateLogStreamInput , opts ... request. Option ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
261
- return cwl .CreateLogStreamFn (ctx , input )
258
+ func (cwl CallbackCloudWatchLogs ) CreateLogStream ( input * cloudwatchlogs.CreateLogStreamInput ) (* cloudwatchlogs.CreateLogStreamOutput , error ) {
259
+ return cwl .CreateLogStreamFn (input )
262
260
}
263
261
264
262
func (cwl CallbackCloudWatchLogs ) PutLogEvents (input * cloudwatchlogs.PutLogEventsInput ) (* cloudwatchlogs.PutLogEventsOutput , error ) {
0 commit comments