mirror of https://github.com/grafana/grafana
Cloud Aggregation: make it work for users with no name (#96509)
parent
29cdfdff87
commit
9223cd8f59
@ -0,0 +1,36 @@ |
||||
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) |
||||
} |
||||
} |
Loading…
Reference in new issue