mirror of
https://github.com/grafana/grafana.git
synced 2025-01-13 09:32:12 -06:00
5fc580b401
Add testing harness
44 lines
1003 B
Go
44 lines
1003 B
Go
package testutil
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
)
|
|
|
|
type SignedInUser struct{}
|
|
|
|
func (SignedInUser) NewAnonymous() (*user.SignedInUser, error) {
|
|
return readUser(`user-anonymous.json`)
|
|
}
|
|
|
|
func (SignedInUser) NewEditor() (*user.SignedInUser, error) {
|
|
return readUser(`user-editor.json`)
|
|
}
|
|
|
|
func (SignedInUser) NewGrafanaAdmin() (*user.SignedInUser, error) {
|
|
return readUser(`user-grafana-admin.json`)
|
|
}
|
|
|
|
func (SignedInUser) NewEmpty() (*user.SignedInUser, error) {
|
|
return readUser(`user-empty.json`)
|
|
}
|
|
|
|
func (SignedInUser) NewServiceAccount() (*user.SignedInUser, error) {
|
|
return readUser(`user-service-account-viewer.json`)
|
|
}
|
|
|
|
func (SignedInUser) NewViewer() (*user.SignedInUser, error) {
|
|
return readUser(`user-viewer.json`)
|
|
}
|
|
|
|
func readUser(filename string) (*user.SignedInUser, error) {
|
|
file, err := dataFS.Open(`data/` + filename)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
ret := new(user.SignedInUser)
|
|
|
|
return ret, json.NewDecoder(file).Decode(ret)
|
|
}
|