This repository has been archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
test_triggered_event_handler_test.go
65 lines (55 loc) · 2.01 KB
/
test_triggered_event_handler_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package action
import (
"net/http"
"testing"
"github.com/keptn-contrib/dynatrace-service/internal/dynatrace"
"github.com/keptn-contrib/dynatrace-service/internal/keptn"
)
type testTriggeredTestSetup struct {
t *testing.T
handler http.Handler
eClient *eventClientFake
customAttachRules *dynatrace.AttachRules
expectedAttachRules dynatrace.AttachRules
labels map[string]string
}
func (s testTriggeredTestSetup) createHandlerAndTeardown() (eventHandler, func()) {
event := baseEventData{
context: testKeptnShContext,
source: "jmeter-service",
event: "sh.keptn.event.test.finished",
project: testProject,
stage: testStage,
service: testService,
testStrategy: "performance",
labels: s.labels,
}
client, _, teardown := createDynatraceClient(s.t, s.handler)
return NewTestTriggeredEventHandler(&event, client, s.eClient, keptn.NewBridgeURLCreator(newKeptnCredentialsProviderMock()), s.customAttachRules), teardown
}
func (s testTriggeredTestSetup) createExpectedDynatraceEvent() dynatrace.AnnotationEvent {
tag := s.eClient.imageAndTag.Tag()
properties := customProperties{
"Image": s.eClient.imageAndTag.Image(),
"Keptn Service": "jmeter-service",
"KeptnContext": testKeptnShContext,
"Keptns Bridge": testKeptnsBridge,
"Project": testProject,
"Service": testService,
"Stage": testStage,
"Tag": tag,
"TestStrategy": "performance",
}
addLabelsToProperties(s.t, properties, s.labels)
return dynatrace.AnnotationEvent{
EventType: "CUSTOM_ANNOTATION",
Source: "Keptn dynatrace-service",
AnnotationType: "Start Tests: performance",
AnnotationDescription: "Start running tests: performance against helloservice",
CustomProperties: properties,
AttachRules: s.expectedAttachRules,
}
}
func (s testTriggeredTestSetup) createEventPayloadContainer() dynatrace.AnnotationEvent {
return dynatrace.AnnotationEvent{}
}