Files
atlantis/server/metrics/scope_test.go
Alberto Rojas 949ee3fa5f metrics: Add Metrics tags to multiple Scopes (#2687)
* metrics: Add Metrics tags to multiple Scopes

* metrics: Fix base_repo and pr_number

* metrics: Refactor SetScope to SetScopeTags

* metrics: Add SetGitScopeTags function

* metrics: docs reword project_context SetScopeTags description

* metrics: test Add TestNewScope_PrometheusTaggingCapabilities
2022-11-19 08:31:46 -06:00

35 lines
699 B
Go

package metrics_test
import (
"testing"
"github.com/runatlantis/atlantis/server/core/config/valid"
"github.com/runatlantis/atlantis/server/metrics"
)
var (
prometheusConfig = valid.Metrics{
Prometheus: &valid.Prometheus{
Endpoint: "/metrics",
},
}
)
func TestNewScope_PrometheusTaggingCapabilities(t *testing.T) {
scope, _, _, err := metrics.NewScope(prometheusConfig, nil, "test")
if err != nil {
t.Fatalf("got an error: %s", err.Error())
}
scope.Tagged(map[string]string{
"base_repo": "runatlantis/atlantis",
"pr_number": "2687",
})
want := true
got := scope.Capabilities().Tagging()
if want != got {
t.Errorf("Scope does not have Capability to do Tagging")
}
}