• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang github.Bool函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/google/go-github/github.Bool函数的典型用法代码示例。如果您正苦于以下问题:Golang Bool函数的具体用法?Golang Bool怎么用?Golang Bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Bool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: create

func create(desc string, pub bool, files map[string]string) (*github.Gist, error) {

	ghat := getAccessToken()

	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: ghat},
	)
	tc := oauth2.NewClient(oauth2.NoContext, ts)

	client := github.NewClient(tc)

	f := make(map[github.GistFilename]github.GistFile)

	for k := range files {
		_k := github.GistFilename(k)
		f[_k] = github.GistFile{Content: github.String(files[k])}
	}

	gist := &github.Gist{
		Description: github.String(desc),
		Public:      github.Bool(pub),
		Files:       f,
	}

	gist, _, err := client.Gists.Create(gist)

	return gist, err
}
开发者ID:chanux,项目名称:gogist,代码行数:28,代码来源:main.go


示例2: newDraftRepositoryRelease

func newDraftRepositoryRelease(id int, version string) github.RepositoryRelease {
	return github.RepositoryRelease{
		TagName: github.String(version),
		Draft:   github.Bool(true),
		ID:      github.Int(id),
	}
}
开发者ID:zachgersh,项目名称:github-release-resource,代码行数:7,代码来源:resource_suite_test.go


示例3: TestGitHubClient_Upload

func TestGitHubClient_Upload(t *testing.T) {
	client := testGithubClient(t)
	testTag := "github-client-upload-asset"
	req := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(true),
	}

	release, err := client.CreateRelease(context.TODO(), req)
	if err != nil {
		t.Fatal("CreateRelease failed:", err)
	}

	defer func() {
		if err := client.DeleteRelease(context.TODO(), *release.ID); err != nil {
			t.Fatalf("DeleteRelease failed: %s", err)
		}
	}()

	filename := filepath.Join("./testdata", "darwin_386")
	asset, err := client.UploadAsset(context.TODO(), *release.ID, filename)
	if err != nil {
		t.Fatal("UploadAsset failed:", err)
	}

	githubClient, ok := client.(*GitHubClient)
	if !ok {
		t.Fatal("Faield to asset to GithubClient")
	}

	rc, url, err := githubClient.Repositories.DownloadReleaseAsset(
		githubClient.Owner, githubClient.Repo, *asset.ID)
	if err != nil {
		t.Fatal("DownloadReleaseAsset failed:", err)
	}

	var buf bytes.Buffer
	if len(url) != 0 {
		res, err := http.Get(url)
		if err != nil {
			t.Fatal("http.Get failed:", err)
		}

		if _, err := io.Copy(&buf, res.Body); err != nil {
			t.Fatal("Copy failed:", err)
		}
		res.Body.Close()

	} else {
		if _, err := io.Copy(&buf, rc); err != nil {
			t.Fatal("Copy failed:", err)
		}
		rc.Close()

	}

	if got, want := buf.String(), "darwin_386\n"; got != want {
		t.Fatalf("file body is %q, want %q", got, want)
	}
}
开发者ID:tchssk,项目名称:ghr,代码行数:60,代码来源:github_test.go


示例4: TestGHR_UploadAssets

func TestGHR_UploadAssets(t *testing.T) {
	githubClient := testGithubClient(t)
	GHR := &GHR{
		GitHub:    githubClient,
		outStream: ioutil.Discard,
	}

	testTag := "ghr-upload-assets"
	req := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(true),
	}

	// Create an existing release before
	release, err := githubClient.CreateRelease(context.TODO(), req)
	if err != nil {
		t.Fatalf("CreateRelease failed: %s", err)
	}

	defer func() {
		if err := githubClient.DeleteRelease(context.TODO(), *release.ID); err != nil {
			t.Fatal("DeleteRelease failed:", err)
		}
	}()

	localTestAssets, err := LocalAssets(TestDir)
	if err != nil {
		t.Fatal("LocalAssets failed:", err)
	}

	if err := GHR.UploadAssets(context.TODO(), *release.ID, localTestAssets, 4); err != nil {
		t.Fatal("GHR.UploadAssets failed:", err)
	}

	assets, err := githubClient.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 4; got != want {
		t.Fatalf("upload assets number = %d, want %d", got, want)
	}

	// Delete all assets
	parallel := 4
	if err := GHR.DeleteAssets(context.TODO(), *release.ID, localTestAssets, parallel); err != nil {
		t.Fatal("GHR.DeleteAssets failed:", err)
	}

	assets, err = githubClient.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 0; got != want {
		t.Fatalf("upload assets number = %d, want %d", got, want)
	}
}
开发者ID:tchssk,项目名称:ghr,代码行数:58,代码来源:ghr_test.go


示例5: TestActivity_Watching

func TestActivity_Watching(t *testing.T) {
	watchers, _, err := client.Activity.ListWatchers("google", "go-github", nil)
	if err != nil {
		t.Fatalf("Activity.ListWatchers returned error: %v", err)
	}

	if len(watchers) == 0 {
		t.Errorf("Activity.ListWatchers('google', 'go-github') returned no watchers")
	}

	// the rest of the tests requires auth
	if !checkAuth("TestActivity_Watching") {
		return
	}

	// first, check if already watching google/go-github
	sub, _, err := client.Activity.GetRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
	}
	if sub != nil {
		t.Fatalf("Already watching google/go-github.  Please manually stop watching it first.")
	}

	// watch google/go-github
	sub = &github.Subscription{Subscribed: github.Bool(true)}
	_, _, err = client.Activity.SetRepositorySubscription("google", "go-github", sub)
	if err != nil {
		t.Fatalf("Activity.SetRepositorySubscription returned error: %v", err)
	}

	// check again and verify watching
	sub, _, err = client.Activity.GetRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
	}
	if sub == nil || !*sub.Subscribed {
		t.Fatalf("Not watching google/go-github after setting subscription.")
	}

	// delete subscription
	_, err = client.Activity.DeleteRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.DeleteRepositorySubscription returned error: %v", err)
	}

	// check again and verify not watching
	sub, _, err = client.Activity.GetRepositorySubscription("google", "go-github")
	if err != nil {
		t.Fatalf("Activity.GetRepositorySubscription returned error: %v", err)
	}
	if sub != nil {
		t.Fatalf("Still watching google/go-github after deleting subscription.")
	}
}
开发者ID:MustWin,项目名称:go-github,代码行数:55,代码来源:activity_test.go


示例6: CreateRepo

// CreateRepo will create a new repository in the organization on github.
//
// TODO: When the hook option is activated, it can only create a push hook.
// Extend this to include a optional event hook.
func (o *Organization) CreateRepo(opt RepositoryOptions) (err error) {
	err = o.connectAdminToGithub()
	if err != nil {
		return
	}

	if opt.Name == "" {
		return errors.New("Missing required name field. ")
	}

	repo := &github.Repository{}
	repo.Name = github.String(opt.Name)
	repo.Private = github.Bool(opt.Private)
	repo.AutoInit = github.Bool(opt.AutoInit)
	repo.HasIssues = github.Bool(opt.Issues)
	if opt.TeamID != 0 {
		repo.TeamID = github.Int(opt.TeamID)
	}

	_, _, err = o.githubadmin.Repositories.Create(o.Name, repo)
	if err != nil {
		return
	}

	if opt.Hook != "" {
		config := make(map[string]interface{})
		config["url"] = global.Hostname + "/event/hook"
		config["content_type"] = "json"

		hook := github.Hook{
			Name:   github.String("web"),
			Config: config,
			Events: []string{
				opt.Hook,
			},
		}

		_, _, err = o.githubadmin.Repositories.CreateHook(o.Name, opt.Name, &hook)
	}
	return
}
开发者ID:tokams,项目名称:autograder,代码行数:45,代码来源:organisation.go


示例7: NewHook

// NewHook returns a new github.Hook instance that represents the appropriate
// configuration for the Conveyor webhook.
func NewHook(url, secret string) *github.Hook {
	return &github.Hook{
		Events: []string{"push"},
		Active: github.Bool(true),
		Name:   github.String("web"),
		Config: map[string]interface{}{
			"url":          url,
			"content_type": "json",
			"secret":       secret,
		},
	}
}
开发者ID:emmetog,项目名称:conveyor,代码行数:14,代码来源:enable.go


示例8: TestRepositories_EditBranches

func TestRepositories_EditBranches(t *testing.T) {
	if !checkAuth("TestRepositories_EditBranches") {
		return
	}

	// get authenticated user
	me, _, err := client.Users.Get("")
	if err != nil {
		t.Fatalf("Users.Get('') returned error: %v", err)
	}

	repo, err := createRandomTestRepository(*me.Login, true)
	if err != nil {
		t.Fatalf("createRandomTestRepository returned error: %v", err)
	}

	branch, _, err := client.Repositories.GetBranch(*repo.Owner.Login, *repo.Name, "master")
	if err != nil {
		t.Fatalf("Repositories.GetBranch() returned error: %v", err)
	}

	if *branch.Protection.Enabled {
		t.Fatalf("Branch %v of repo %v is already protected", "master", *repo.Name)
	}

	branch.Protection.Enabled = github.Bool(true)
	branch.Protection.RequiredStatusChecks = &github.RequiredStatusChecks{
		EnforcementLevel: github.String("everyone"),
		Contexts:         &[]string{"continous-integration"},
	}
	branch, _, err = client.Repositories.EditBranch(*repo.Owner.Login, *repo.Name, "master", branch)
	if err != nil {
		t.Fatalf("Repositories.EditBranch() returned error: %v", err)
	}

	if !*branch.Protection.Enabled {
		t.Fatalf("Branch %v of repo %v should be protected, but is not!", "master", *repo.Name)
	}
	if *branch.Protection.RequiredStatusChecks.EnforcementLevel != "everyone" {
		t.Fatalf("RequiredStatusChecks should be enabled for everyone, set for: %v", *branch.Protection.RequiredStatusChecks.EnforcementLevel)
	}

	wantedContexts := []string{"continous-integration"}
	if !reflect.DeepEqual(*branch.Protection.RequiredStatusChecks.Contexts, wantedContexts) {
		t.Fatalf("RequiredStatusChecks.Contexts should be: %v but is: %v", wantedContexts, *branch.Protection.RequiredStatusChecks.Contexts)
	}

	_, err = client.Repositories.Delete(*repo.Owner.Login, *repo.Name)
	if err != nil {
		t.Fatalf("Repositories.Delete() returned error: %v", err)
	}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:52,代码来源:repos_test.go


示例9: TestGitHubClient_ListAssets

func TestGitHubClient_ListAssets(t *testing.T) {
	client := testGithubClient(t)
	testTag := "github-list-assets"
	req := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(true),
	}

	release, err := client.CreateRelease(context.TODO(), req)
	if err != nil {
		t.Fatal("CreateRelease failed:", err)
	}

	defer func() {
		if err := client.DeleteRelease(context.TODO(), *release.ID); err != nil {
			t.Fatalf("DeleteRelease failed: %s", err)
		}
	}()

	for _, filename := range []string{"darwin_386", "darwin_amd64"} {
		filename := filepath.Join("./testdata", filename)
		if _, err := client.UploadAsset(context.TODO(), *release.ID, filename); err != nil {
			t.Fatal("UploadAsset failed:", err)
		}
	}

	assets, err := client.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 2; got != want {
		t.Fatalf("ListAssets number = %d, want %d", got, want)
	}

	if err := client.DeleteAsset(context.TODO(), *assets[0].ID); err != nil {
		t.Fatal("DeleteAsset failed:", err)
	}

	assets, err = client.ListAssets(context.TODO(), *release.ID)
	if err != nil {
		t.Fatal("ListAssets failed:", err)
	}

	if got, want := len(assets), 1; got != want {
		t.Fatalf("ListAssets number = %d, want %d", got, want)
	}
}
开发者ID:tchssk,项目名称:ghr,代码行数:48,代码来源:github_test.go


示例10: createRepo

// create a new private repository named name for the given team
func createRepo(name string, team int) {
	repo := &github.Repository{
		Name:    github.String(name),
		Private: github.Bool(false), // TODO Update once github has given me private repos
	}
	r, _, err := client.Repositories.Create(courseOrg, repo)
	if err != nil {
		fmt.Printf("Failed to create repo: %s: %v\n", name, err)
		return
	}
	fmt.Printf("Created repository: %s for team %d;\n  URL: %s\n", name, team, *r.URL)
	_, err = client.Organizations.AddTeamRepo(team, courseOrg, name)
	if err != nil {
		fmt.Printf("Failed to add team %d to repo: %s: %v\n", team, name, err)
	}
	fmt.Println("Added team to repository:", name)
}
开发者ID:uis-dat320-fall2014,项目名称:course-info,代码行数:18,代码来源:addteams.go


示例11: Create

// Create will create a Gist(https://gist.github.com/)
//
// If gist was created http.Response.StatusCode will be
// http.StatusCreated.(201)
func Create(githubToken string, gistParam CreateParams) (string, *http.Response, error) {

	client := connectGithub(githubToken)

	gf := &github.GistFile{
		Filename: github.String(gistParam.FileName),
		Content:  github.String(gistParam.Content),
	}

	gist := &github.Gist{
		Description: github.String(gistParam.Description),
		Public:      github.Bool(gistParam.Public),
		Files:       map[github.GistFilename]github.GistFile{"": *gf},
	}

	gst, resp, err := client.Gists.Create(gist)

	return *gst.HTMLURL, resp.Response, err
}
开发者ID:0x7cc,项目名称:x16,代码行数:23,代码来源:gist.go


示例12: CreateDeployment

func (b *GithubBackend) CreateDeployment(ref string, env string) error {
	client := b.getClient()
	user, repo := b.parseGithubInfo()

	status_req := github.DeploymentRequest{
		Ref:         &ref,
		Task:        github.String("deploy"),
		AutoMerge:   github.Bool(false),
		Environment: &env,
	}

	_, _, err := client.Repositories.CreateDeployment(user, repo, &status_req)

	if err != nil {
		return err
	}

	return nil
}
开发者ID:ryanlfoster,项目名称:shipper,代码行数:19,代码来源:github.go


示例13: TestGHR_CreateRelease

func TestGHR_CreateRelease(t *testing.T) {
	t.Parallel()

	githubClient := testGithubClient(t)
	GHR := &GHR{
		GitHub:    githubClient,
		outStream: ioutil.Discard,
	}

	testTag := "create-release"
	req := &github.RepositoryRelease{
		TagName: &testTag,
		Draft:   github.Bool(false),
	}

	recreate := false
	release, err := GHR.CreateRelease(context.TODO(), req, recreate)
	if err != nil {
		t.Fatal("CreateRelease failed:", err)
	}

	defer GHR.DeleteRelease(context.TODO(), *release.ID, testTag)
}
开发者ID:tchssk,项目名称:ghr,代码行数:23,代码来源:ghr_test.go


示例14: CreateRepo

// CreateRepo creates a repository in the github user account
func (repo GithubRepository) CreateRepo(username, reponame, org string, private bool) (*domain.Repository, error) {
	rp := &github.Repository{
		Name:    github.String(reponame),
		Private: github.Bool(private),
	}
	rp, _, err := repo.client.Repositories.Create(org, rp)

	if err != nil {
		return nil, err
	}

	r := &domain.Repository{
		Name:        rp.Name,
		FullName:    rp.FullName,
		Description: rp.Description,
		Private:     rp.Private,
		HTMLURL:     rp.HTMLURL,
		CloneURL:    rp.CloneURL,
		SSHURL:      rp.SSHURL,
	}

	return r, nil
}
开发者ID:Tinker-Ware,项目名称:gh-service,代码行数:24,代码来源:github.go


示例15:

						On("Get", repositoryOwner, repositoryName, issueNumber).
						Return(nil, nil, errors.New("an error"))
				})

				It("fails with a gateway error", func() {
					handle()
					Expect(responseRecorder.Code).To(Equal(http.StatusBadGateway))
				})
			})

			Context("with the PR being already merged", func() {
				BeforeEach(func() {
					pullRequests.
						On("Get", repositoryOwner, repositoryName, issueNumber).
						Return(&github.PullRequest{
							Merged: github.Bool(true),
						}, nil, nil)
				})

				It("removes the 'merging' label from the PR", func() {
					issues.
						On("RemoveLabelForIssue", repositoryOwner, repositoryName, issueNumber, grh.MergingLabel).
						Return(nil, nil, nil)

					handle()
					Expect(responseRecorder.Code).To(Equal(http.StatusOK))
				})
			})

			Context("with the PR not being mergeable", func() {
				BeforeEach(func() {
开发者ID:salemove,项目名称:github-review-helper,代码行数:31,代码来源:merge_command_test.go


示例16: PostProject

// PostProject ...
func PostProject(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
	user, err := session.GetUser(r)
	if err != nil {
		log.Fatal(err)
	}
	projectName := r.PostFormValue("name")
	if projectName == "" {
		log.Println("Missing projectName")
		http.Redirect(w, r, "/", http.StatusSeeOther)
		return
	}
	repoDescription := "Repository for " + projectName + " created by Hugoku"
	ts := oauth2.StaticTokenSource(
		&oauth2.Token{AccessToken: user.Token.AccessToken},
	)
	tc := oauth2.NewClient(oauth2.NoContext, ts)
	client := github.NewClient(tc)

	log.Printf("Creating %s...", projectName)

	buildInfo, err := ci.Deploy(user.Username, projectName)

	log.Printf("Build duration: %s\n", buildInfo.BuildDuration)

	if err != nil {
		log.Fatalf("Error while trying to create project: %s", err)
	}

	if !repo.Exists(client, user.Username, projectName) {
		gitHubStartTime := time.Now()
		repo := &github.Repository{
			Name:        github.String(projectName),
			Private:     github.Bool(false),
			Description: github.String(repoDescription),
		}
		repo, _, err = client.Repositories.Create("", repo)
		if err != nil {
			log.Fatalf("Error while trying to create repo: %s", err)
		}

		// Push the repo
		wd, _ := os.Getwd()
		err := os.Chdir(wd + "/repos/" + user.Username + "/" + projectName + "/")
		if err != nil {
			log.Fatal(err)
		}
		cmd.Run("git", []string{"init", "--quiet"})
		cmd.Run("git", []string{"add", "."})
		cmd.Run("git", []string{"commit", "-m", "'initial source code'"})
		cmd.Run("git", []string{"remote", "add", "origin", "[email protected]:" + user.Username + "/" + projectName + ".git"})
		cmd.Run("git", []string{"push", "--quiet", "-u", "origin", "master"})
		err = os.Chdir(wd)
		if err != nil {
			log.Fatal(err)
		}
		githubTime := time.Since(gitHubStartTime)
		log.Printf("Git repo creation duration: %s\n", githubTime)
	}
	project := store.Project{Name: projectName, Description: repoDescription, BuildsInfo: []store.BuildInfo{buildInfo}, LastBuildInfo: buildInfo}
	user.Projects = append(user.Projects, project)

	err = store.SaveUser(user)

	http.Redirect(w, r, "/", http.StatusSeeOther)
}
开发者ID:gophergala2016,项目名称:hugoku,代码行数:66,代码来源:projects.go


示例17:

		existingAssets := []github.ReleaseAsset{
			{
				ID:   github.Int(456789),
				Name: github.String("unicorns.txt"),
			},
			{
				ID:    github.Int(3450798),
				Name:  github.String("rainbows.txt"),
				State: github.String("new"),
			},
		}

		existingReleases := []github.RepositoryRelease{
			{
				ID:    github.Int(1),
				Draft: github.Bool(true),
			},
			{
				ID:      github.Int(112),
				TagName: github.String("some-tag-name"),
				Assets:  []github.ReleaseAsset{existingAssets[0]},
				Draft:   github.Bool(false),
			},
		}

		BeforeEach(func() {
			githubClient.ListReleasesReturns(existingReleases, nil)

			githubClient.ListReleaseAssetsReturns(existingAssets, nil)

			namePath := filepath.Join(sourcesDir, "name")
开发者ID:zachgersh,项目名称:github-release-resource,代码行数:31,代码来源:out_command_test.go


示例18: createRandomTestRepository

func createRandomTestRepository(owner string, autoinit bool) (*github.Repository, error) {
	// create random repo name that does not currently exist
	var repoName string
	for {
		repoName = fmt.Sprintf("test-%d", rand.Int())
		_, resp, err := client.Repositories.Get(owner, repoName)
		if err != nil {
			if resp.StatusCode == http.StatusNotFound {
				// found a non-existent repo, perfect
				break
			}

			return nil, err
		}
	}

	// create the repository
	repo, _, err := client.Repositories.Create("", &github.Repository{Name: github.String(repoName), AutoInit: github.Bool(autoinit)})
	if err != nil {
		return nil, err
	}

	return repo, nil
}
开发者ID:MustWin,项目名称:go-github,代码行数:24,代码来源:github_test.go


示例19:

		inRequest = resource.InRequest{}
	})

	AfterEach(func() {
		Ω(os.RemoveAll(tmpDir)).Should(Succeed())
	})

	buildRelease := func(id int, tag string, draft bool) *github.RepositoryRelease {
		return &github.RepositoryRelease{
			ID:      github.Int(id),
			TagName: github.String(tag),
			HTMLURL: github.String("http://google.com"),
			Name:    github.String("release-name"),
			Body:    github.String("*markdown*"),
			Draft:   github.Bool(draft),
		}
	}

	buildNilTagRelease := func(id int) *github.RepositoryRelease {
		return &github.RepositoryRelease{
			ID:      github.Int(id),
			HTMLURL: github.String("http://google.com"),
			Name:    github.String("release-name"),
			Body:    github.String("*markdown*"),
			Draft:   github.Bool(true),
		}
	}

	buildAsset := func(id int, name string) github.ReleaseAsset {
		return github.ReleaseAsset{
开发者ID:zachgersh,项目名称:github-release-resource,代码行数:30,代码来源:in_command_test.go


示例20: TestGHR_CreateReleaseWithExistingRelease

func TestGHR_CreateReleaseWithExistingRelease(t *testing.T) {
	t.Parallel()

	githubClient := testGithubClient(t)
	GHR := &GHR{
		GitHub:    githubClient,
		outStream: ioutil.Discard,
	}

	testTag := "create-with-existing"
	existingReq := &github.RepositoryRelease{
		TagName: github.String(testTag),
		Draft:   github.Bool(false),
	}
	cases := []struct {
		request    *github.RepositoryRelease
		recreate   bool
		newRelease bool
	}{
		// 0: When same tag as existing release is used
		{
			&github.RepositoryRelease{
				TagName: github.String(testTag),
				Draft:   github.Bool(false),
			},
			false,
			false,
		},

		// 1: When draft release is requested
		{
			&github.RepositoryRelease{
				TagName: github.String(testTag),
				Draft:   github.Bool(true),
			},
			false,
			true,
		},

		// 2: When recreate is requtested
		{
			&github.RepositoryRelease{
				TagName: github.String(testTag),
				Draft:   github.Bool(false),
			},
			true,
			true,
		},

		// 3: When different tag is requtested
		{
			&github.RepositoryRelease{
				TagName: github.String("v2.0.0"),
				Draft:   github.Bool(false),
			},
			false,
			true,
		},
	}

	for i, tc := range cases {
		// Prevent a lot of requests at same time to GitHub API
		time.Sleep(1 * time.Second)

		// Create an existing release before
		existing, err := githubClient.CreateRelease(context.TODO(), existingReq)
		if err != nil {
			t.Fatalf("#%d CreateRelease failed: %s", i, err)
		}

		// Create a release for THIS TEST
		created, err := GHR.CreateRelease(context.TODO(), tc.request, tc.recreate)
		if err != nil {
			t.Fatalf("#%d GHR.CreateRelease failed: %s", i, err)
		}

		// Clean up existing release
		if !tc.recreate {
			err = GHR.DeleteRelease(context.TODO(), *existing.ID, *existingReq.TagName)
			if err != nil {
				t.Fatalf("#%d GHR.DeleteRelease (existing) failed: %s", i, err)
			}
		}

		if !tc.newRelease {
			if *created.ID != *existing.ID {
				t.Fatalf("#%d created ID %d, want %d (same as existing release ID)",
					i, *created.ID, *existing.ID)
			}
			continue
		}

		// Clean up newly created release before. When draft request,
		// tag is not created. So it need to be deleted separately by Github client.
		if *tc.request.Draft {
			// Clean up newly created release before checking
			if err := githubClient.DeleteRelease(context.TODO(), *created.ID); err != nil {
				t.Fatalf("#%d GitHub.DeleteRelease (created) failed: %s", i, err)
			}
		} else {
//.........这里部分代码省略.........
开发者ID:tchssk,项目名称:ghr,代码行数:101,代码来源:ghr_test.go



注:本文中的github.com/google/go-github/github.Bool函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang github.NewClient函数代码示例发布时间:2022-05-23
下一篇:
Golang repository.Repo类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap