-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(observability-lib): notification policy matchers check
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package api | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/grafana/grafana-foundation-sdk/go/alerting" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestObjectMatchersEqual(t *testing.T) { | ||
t.Run("returns true if the two object matchers are equal", func(t *testing.T) { | ||
a := alerting.ObjectMatchers{{"team", "=", "chainlink"}} | ||
b := alerting.ObjectMatchers{{"team", "=", "chainlink"}} | ||
|
||
result := objectMatchersEqual(a, b) | ||
require.True(t, result) | ||
}) | ||
|
||
t.Run("returns true if the two object matchers with multiple matches are equal", func(t *testing.T) { | ||
a := alerting.ObjectMatchers{ | ||
{"team", "=", "chainlink"}, | ||
{"severity", "=", "critical"}, | ||
} | ||
b := alerting.ObjectMatchers{ | ||
{"severity", "=", "critical"}, | ||
{"team", "=", "chainlink"}, | ||
} | ||
|
||
result := objectMatchersEqual(a, b) | ||
require.True(t, result) | ||
}) | ||
|
||
t.Run("returns false if the two object matchers with multiple matches are different", func(t *testing.T) { | ||
a := alerting.ObjectMatchers{ | ||
{"team", "=", "chainlink"}, | ||
{"severity", "=", "critical"}, | ||
} | ||
b := alerting.ObjectMatchers{ | ||
{"severity", "=", "warning"}, | ||
{"team", "=", "chainlink"}, | ||
} | ||
|
||
result := objectMatchersEqual(a, b) | ||
require.False(t, result) | ||
}) | ||
} |