Skip to content

Commit dea6765

Browse files
committed
add unit test for prometheus extension
1 parent c3c7690 commit dea6765

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// +build unit
2+
3+
package prometheus
4+
5+
import (
6+
"fmt"
7+
"testing"
8+
"time"
9+
10+
"github.com/stretchr/testify/assert"
11+
12+
"github.com/hellofresh/goengine/driver/sql"
13+
)
14+
15+
func TestPrometheusMetrics(t *testing.T) {
16+
metrics := NewMetrics()
17+
18+
testSQLProjection := sql.ProjectionNotification{
19+
No: 1,
20+
AggregateID: "C56A4180-65AA-42EC-A945-5FD21DEC0538",
21+
}
22+
23+
metrics.QueueNotification(&testSQLProjection)
24+
metrics.StartNotificationProcessing(&testSQLProjection)
25+
26+
memAddress := fmt.Sprintf("%p", &testSQLProjection)
27+
queueStartTime, ok := metrics.notificationStartTimes.Load("q" + memAddress)
28+
assert.True(t, ok)
29+
assert.IsType(t, time.Time{}, queueStartTime)
30+
31+
processingStartTime, _ := metrics.notificationStartTimes.Load("p" + memAddress)
32+
assert.True(t, ok)
33+
assert.IsType(t, time.Time{}, processingStartTime)
34+
}

0 commit comments

Comments
 (0)