Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
32 lines (26 loc) · 896 Bytes

File metadata and controls

32 lines (26 loc) · 896 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package codehost_testing
import (
"context"
"github.com/google/go-github/v55/github"
"github.com/sourcegraph/sourcegraph/lib/errors"
)
// User represents a GitHub user in the scenario.
type User struct {
s *GitHubScenario
name string
}
// Get returns the corresponding GitHub user object that was created by the `CreateUser`
//
// This method will only return a User if the Scenario that created it has been applied otherwise
// it will panic.
func (u *User) Get(ctx context.Context) (*github.User, error) {
if u.s.IsApplied() {
return u.get(ctx)
}
return nil, errors.New("cannot retrieve user before scenario is applied")
}
// get retrieves the GitHub user without panicking if not applied. It is meant as an
// internal helper method while actions are getting applied.
func (u *User) get(ctx context.Context) (*github.User, error) {
return u.s.client.GetUser(ctx, u.name)
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.