The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/user/identity_test.go

36 lines
681 B

package user
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestIdentityGetName(t *testing.T) {
tt := []struct {
name string
user *SignedInUser
expected string
}{
{
name: "GetName on a user with empty name returns Login, if set",
user: &SignedInUser{
Login: "userLogin",
Email: "user@grafana.com",
},
expected: "userLogin",
},
{
name: "GetName on a user with empty name returns Email, if no Login is set",
user: &SignedInUser{
Email: "user@grafana.com",
},
expected: "user@grafana.com",
},
}
for _, tc := range tt {
user := tc.user
require.Equal(t, user.GetName(), tc.expected, tc.name)
}
}