NOISSUE - Fix create alarms test and add alarms to GitHub actions (#118)

* fix: Create alarms test

Signed-off-by: Arvindh <arvindh91@gmail.com>

* update: github actions for test

Signed-off-by: Arvindh <arvindh91@gmail.com>

---------

Signed-off-by: Arvindh <arvindh91@gmail.com>
This commit is contained in:
Arvindh
2025-04-16 16:41:41 +05:30
committed by GitHub
parent ddce4f4a46
commit 17fa535502
2 changed files with 20 additions and 1 deletions
+10
View File
@@ -126,6 +126,11 @@ jobs:
- "cmd/re/**"
- "re/api/**"
alarms:
- "alarms/**"
- "cmd/alarms/**"
- name: Create coverage directory
run: |
mkdir coverage
@@ -175,6 +180,11 @@ jobs:
run: |
go test --race -v -count=1 -coverprofile=coverage/re.out ./re/...
- name: Run alarms tests
if: steps.changes.outputs.alarms == 'true' || steps.changes.outputs.workflow == 'true'
run: |
go test --race -v -count=1 -coverprofile=coverage/alarms.out ./alarms/...
- name: Upload coverage
uses: codecov/codecov-action@v5
with:
+10 -1
View File
@@ -65,7 +65,16 @@ func TestCreateAlarm(t *testing.T) {
for _, tc := range cases {
t.Run(tc.desc, func(t *testing.T) {
repoCall := repo.On("CreateAlarm", context.Background(), mock.Anything).Return(tc.alarm, tc.err)
repoCall1 := repo.On("ListAlarms", context.Background(), alarms.PageMetadata{Offset: 0, Limit: 1}).Return(alarms.AlarmsPage{}, tc.err)
repoCall1 := repo.On("ListAlarms", context.Background(), alarms.PageMetadata{
Offset: 0, Limit: 1,
DomainID: tc.alarm.DomainID,
ChannelID: tc.alarm.ChannelID,
ClientID: tc.alarm.ClientID,
Subtopic: tc.alarm.Subtopic,
RuleID: tc.alarm.RuleID,
Severity: tc.alarm.Severity,
Status: tc.alarm.Status,
}).Return(alarms.AlarmsPage{}, tc.err)
err := svc.CreateAlarm(context.Background(), tc.alarm)
if tc.err != nil {
assert.True(t, errors.Contains(err, tc.err), fmt.Sprintf("%s: expected %s got %s\n", tc.desc, tc.err, err))