FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sourcegraph/dev/codehost_testing/example/example_test.go at main · PriNova/sourcegraph · GitHub
PriNova
/
sourcegraph
Public
forked from
sourcegraph/sourcegraph-public-snapshot
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sourcegraph
/
dev
/
codehost_testing
/
example
/
example_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
71 lines (60 loc) · 1.8 KB
Breadcrumbs
sourcegraph
/
dev
/
codehost_testing
/
example
/
example_test.go
Copy path
File metadata and controls
71 lines (60 loc) · 1.8 KB
Raw
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package
main
import
(
"context"
"flag"
"fmt"
"os"
"testing"
scenario
"github.com/sourcegraph/sourcegraph/dev/codehost_testing"
"github.com/sourcegraph/sourcegraph/dev/codehost_testing/config"
)
var
runGithub
bool
func
TestGithubScenario
(
t
*
testing.
T
) {
if
!
runGithub
{
t
.
Skip
(
"`run.github` flag not provided - skipping github scenario as this is only an example test"
)
}
cfg
,
err
:=
config
.
FromFile
(
"config.json"
)
if
err
!=
nil
{
t
.
Fatalf
(
"error loading scenario config: %v
\n
"
,
err
)
}
scenario
,
err
:=
scenario
.
NewGitHubScenario
(
t
,
*
cfg
)
if
err
!=
nil
{
t
.
Fatalf
(
"error creating scenario: %v
\n
"
,
err
)
}
org
:=
scenario
.
CreateOrg
(
"tst-org"
)
user
:=
scenario
.
CreateUser
(
"tst-user"
)
otherUser
:=
scenario
.
CreateUser
(
"other-user"
)
admin
:=
scenario
.
GetAdmin
()
org
.
AllowPrivateForks
()
team
:=
org
.
CreateTeam
(
"team-1"
)
team
.
AddUser
(
user
)
team
.
AddUser
(
otherUser
)
adminTeam
:=
org
.
CreateTeam
(
"team-admin"
)
adminTeam
.
AddUser
(
admin
)
publicRepo
:=
org
.
CreateRepoFork
(
"sgtest/go-diff"
)
publicRepo
.
AddTeam
(
team
)
privateRepo
:=
org
.
CreateRepoFork
(
"sgtest/private"
)
privateRepo
.
AddTeam
(
adminTeam
)
fmt
.
Println
(
scenario
.
Plan
())
ctx
:=
context
.
Background
()
// Get the Organization WILL FAIL since the scenario has not been applied yet
_
,
err
=
org
.
Get
(
ctx
)
if
err
!=
nil
{
t
.
Logf
(
"failed to get github.Organization since it hasn't been applied yet: %v"
,
err
)
}
scenario
.
SetVerbose
()
if
err
:=
scenario
.
Apply
(
ctx
);
err
!=
nil
{
t
.
Fatalf
(
"error applying scenario: %v"
,
err
)
}
// Get the Organization
ghOrg
,
err
:=
org
.
Get
(
ctx
)
if
err
!=
nil
{
t
.
Fatalf
(
"failed to get github.Organization: %v"
,
err
)
}
t
.
Logf
(
"GitHub Organization: %s"
,
ghOrg
.
GetLogin
())
}
func
TestMain
(
m
*
testing.
M
) {
flag
.
BoolVar
(
&
runGithub
,
"run.github"
,
false
,
"Run example github scenario setup"
)
flag
.
Parse
()
os
.
Exit
(
m
.
Run
())
}
Back
|
FazBrowse Home
|
New Git URL