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
71 lines (60 loc) · 1.8 KB

File metadata and controls

71 lines (60 loc) · 1.8 KB
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())
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.