From 485e53b0ad1666a750cd4f80599b9d5fb6907e60 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Fri, 14 Jun 2019 00:55:27 -0400 Subject: [PATCH 1/2] Add gen-stringify-test.go --- github/gen-accessors.go | 5 +- github/gen-stringify-test.go | 358 +++++++ github/github-stringify_test.go | 1661 +++++++++++++++++++++++++++++++ github/github.go | 1 + github/github_test.go | 11 + 5 files changed, 2034 insertions(+), 2 deletions(-) create mode 100644 github/gen-stringify-test.go create mode 100644 github/github-stringify_test.go diff --git a/github/gen-accessors.go b/github/gen-accessors.go index fe92206fcf8..4c5e8eec7e7 100644 --- a/github/gen-accessors.go +++ b/github/gen-accessors.go @@ -7,8 +7,9 @@ // gen-accessors generates accessor methods for structs with pointer fields. // -// It is meant to be used by the go-github authors in conjunction with the -// go generate tool before sending a commit to GitHub. +// It is meant to be used by go-github contributors in conjunction with the +// go generate tool before sending a PR to GitHub. +// Please see the CONTRIBUTING.md file for more information. package main import ( diff --git a/github/gen-stringify-test.go b/github/gen-stringify-test.go new file mode 100644 index 00000000000..1315d4d0a9c --- /dev/null +++ b/github/gen-stringify-test.go @@ -0,0 +1,358 @@ +// Copyright 2019 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build ignore + +// gen-stringify-test generates test methods to test the String methods. +// +// These tests eliminate most of the code coverage problems so that real +// code coverage issues can be more readily identified. +// +// It is meant to be used by go-github contributors in conjunction with the +// go generate tool before sending a PR to GitHub. +// Please see the CONTRIBUTING.md file for more information. +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/format" + "go/parser" + "go/token" + "io/ioutil" + "log" + "os" + "strings" + "text/template" +) + +const ( + ignoreFilePrefix1 = "gen-" + ignoreFilePrefix2 = "github-" + outputFileSuffix = "-stringify_test.go" +) + +var ( + verbose = flag.Bool("v", false, "Print verbose log messages") + + sourceTmpl = template.Must(template.New("source").Funcs(funcMap).Parse(source)) + + // blacklistStructMethod lists "struct.method" combos to skip. + blacklistStructMethod = map[string]bool{} + // blacklistStruct lists structs to skip. + blacklistStruct = map[string]bool{ + "RateLimits": true, + } + + funcMap = template.FuncMap{ + "isNotLast": func(index int, slice []*structField) string { + if index+1 < len(slice) { + return ", " + } + return "" + }, + "processZeroValue": func(v string) string { + switch v { + case "Bool(false)": + return "false" + case "Float64(0.0)": + return "0" + case "0", "Int(0)", "Int64(0)": + return "0" + case `""`, `String("")`: + return `""` + case "Timestamp{}", "&Timestamp{}": + return "github.Timestamp{0001-01-01 00:00:00 +0000 UTC}" + case "nil": + return "map[]" + } + log.Fatalf("Unhandled zero value: %q", v) + return "" + }, + } +) + +func main() { + flag.Parse() + fset := token.NewFileSet() + + pkgs, err := parser.ParseDir(fset, ".", sourceFilter, 0) + if err != nil { + log.Fatal(err) + return + } + + for pkgName, pkg := range pkgs { + t := &templateData{ + filename: pkgName + outputFileSuffix, + Year: 2019, + Package: pkgName, + Imports: map[string]string{"testing": "testing"}, + StringFuncs: map[string]bool{}, + StructFields: map[string][]*structField{}, + } + for filename, f := range pkg.Files { + logf("Processing %v...", filename) + if err := t.processAST(f); err != nil { + log.Fatal(err) + } + } + if err := t.dump(); err != nil { + log.Fatal(err) + } + } + logf("Done.") +} + +func sourceFilter(fi os.FileInfo) bool { + return !strings.HasSuffix(fi.Name(), "_test.go") && + !strings.HasPrefix(fi.Name(), ignoreFilePrefix1) && + !strings.HasPrefix(fi.Name(), ignoreFilePrefix2) +} + +type templateData struct { + filename string + Year int + Package string + Imports map[string]string + StringFuncs map[string]bool + StructFields map[string][]*structField +} + +type structField struct { + sortVal string // Lower-case version of "ReceiverType.FieldName". + ReceiverVar string // The one-letter variable name to match the ReceiverType. + ReceiverType string + FieldName string + FieldType string + ZeroValue string + NamedStruct bool // Getter for named struct. +} + +func (t *templateData) processAST(f *ast.File) error { + for _, decl := range f.Decls { + fn, ok := decl.(*ast.FuncDecl) + if ok { + if fn.Recv != nil && len(fn.Recv.List) > 0 { + id, ok := fn.Recv.List[0].Type.(*ast.Ident) + if ok && fn.Name.Name == "String" { + logf("Got FuncDecl: Name=%q, id.Name=%#v", fn.Name.Name, id.Name) + t.StringFuncs[id.Name] = true + } else { + logf("Ignoring FuncDecl: Name=%q, Type=%T", fn.Name.Name, fn.Recv.List[0].Type) + } + } else { + logf("Ignoring FuncDecl: Name=%q, fn=%#v", fn.Name.Name, fn) + } + continue + } + + gd, ok := decl.(*ast.GenDecl) + if !ok { + logf("Ignoring AST decl type %T", decl) + continue + } + for _, spec := range gd.Specs { + ts, ok := spec.(*ast.TypeSpec) + if !ok { + continue + } + // Skip unexported identifiers. + if !ts.Name.IsExported() { + logf("Struct %v is unexported; skipping.", ts.Name) + continue + } + // Check if the struct is blacklisted. + if blacklistStruct[ts.Name.Name] { + logf("Struct %v is blacklisted; skipping.", ts.Name) + continue + } + st, ok := ts.Type.(*ast.StructType) + if !ok { + logf("Ignoring AST type %T, Name=%q", ts.Type, ts.Name.String()) + continue + } + for _, field := range st.Fields.List { + if len(field.Names) == 0 { + continue + } + + fieldName := field.Names[0] + if id, ok := field.Type.(*ast.Ident); ok { + t.addIdent(id, ts.Name.String(), fieldName.String()) + continue + } + + if _, ok := field.Type.(*ast.MapType); ok { + t.addMapType(ts.Name.String(), fieldName.String()) + continue + } + + se, ok := field.Type.(*ast.StarExpr) + if !ok { + logf("Ignoring type %T for Name=%q, FieldName=%q", field.Type, ts.Name.String(), fieldName.String()) + continue + } + + // Skip unexported identifiers. + if !fieldName.IsExported() { + logf("Field %v is unexported; skipping.", fieldName) + continue + } + // Check if "struct.method" is blacklisted. + if key := fmt.Sprintf("%v.Get%v", ts.Name, fieldName); blacklistStructMethod[key] { + logf("Method %v is blacklisted; skipping.", key) + continue + } + + switch x := se.X.(type) { + case *ast.ArrayType: + case *ast.Ident: + t.addIdentPtr(x, ts.Name.String(), fieldName.String()) + case *ast.MapType: + case *ast.SelectorExpr: + default: + logf("processAST: type %q, field %q, unknown %T: %+v", ts.Name, fieldName, x, x) + } + } + } + } + return nil +} + +func (t *templateData) addMapType(receiverType, fieldName string) { + t.StructFields[receiverType] = append(t.StructFields[receiverType], newStructField(receiverType, fieldName, "map[]", "nil", false)) +} + +func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) { + var zeroValue string + var namedStruct = false + switch x.String() { + case "int": + zeroValue = "0" + case "int64": + zeroValue = "0" + case "float64": + zeroValue = "0.0" + case "string": + zeroValue = `""` + case "bool": + zeroValue = "false" + case "Timestamp": + zeroValue = "Timestamp{}" + default: + zeroValue = "nil" + namedStruct = true + } + + t.StructFields[receiverType] = append(t.StructFields[receiverType], newStructField(receiverType, fieldName, x.String(), zeroValue, namedStruct)) +} + +func (t *templateData) addIdentPtr(x *ast.Ident, receiverType, fieldName string) { + var zeroValue string + var namedStruct = false + switch x.String() { + case "int": + zeroValue = "Int(0)" + case "int64": + zeroValue = "Int64(0)" + case "float64": + zeroValue = "Float64(0.0)" + case "string": + zeroValue = `String("")` + case "bool": + zeroValue = "Bool(false)" + case "Timestamp": + zeroValue = "&Timestamp{}" + default: + zeroValue = "nil" + namedStruct = true + } + + t.StructFields[receiverType] = append(t.StructFields[receiverType], newStructField(receiverType, fieldName, x.String(), zeroValue, namedStruct)) +} + +func (t *templateData) dump() error { + if len(t.StructFields) == 0 { + logf("No StructFields for %v; skipping.", t.filename) + return nil + } + + // Remove unused structs. + var toDelete []string + for k := range t.StructFields { + if !t.StringFuncs[k] { + toDelete = append(toDelete, k) + continue + } + } + for _, k := range toDelete { + delete(t.StructFields, k) + } + + var buf bytes.Buffer + if err := sourceTmpl.Execute(&buf, t); err != nil { + return err + } + clean, err := format.Source(buf.Bytes()) + if err != nil { + log.Printf("failed-to-format source:\n%v", buf.String()) + return err + } + + logf("Writing %v...", t.filename) + return ioutil.WriteFile(t.filename, clean, 0644) +} + +func newStructField(receiverType, fieldName, fieldType, zeroValue string, namedStruct bool) *structField { + return &structField{ + sortVal: strings.ToLower(receiverType) + "." + strings.ToLower(fieldName), + ReceiverVar: strings.ToLower(receiverType[:1]), + ReceiverType: receiverType, + FieldName: fieldName, + FieldType: fieldType, + ZeroValue: zeroValue, + NamedStruct: namedStruct, + } +} + +func logf(fmt string, args ...interface{}) { + if *verbose { + log.Printf(fmt, args...) + } +} + +const source = `// Copyright {{.Year}} The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen-stringify-tests; DO NOT EDIT. + +package {{ $package := .Package}}{{$package}} +{{with .Imports}} +import ( + {{- range . -}} + "{{.}}" + {{end -}} +) +{{end}} +func Float64(v float64) *float64 { return &v } +{{range $key, $value := .StructFields}} +func Test{{ $key }}_String(t *testing.T) { + v := {{ $key }}{ {{range .}}{{if .NamedStruct}} + {{ .FieldName }}: &{{ .FieldType }}{},{{else}} + {{ .FieldName }}: {{.ZeroValue}},{{end}}{{end}} + } + want := ` + "`" + `{{ $package }}.{{ $key }}{{ $slice := . }}{ +{{- range $ind, $val := .}}{{if .NamedStruct}}{{ .FieldName }}:{{ $package }}.{{ .FieldType }}{}{{else}}{{ .FieldName }}:{{ processZeroValue .ZeroValue }}{{end}}{{ isNotLast $ind $slice }}{{end}}}` + "`" + ` + if got := v.String(); got != want { + t.Errorf("{{ $key }}.String = %v, want %v", got, want) + } +} +{{end}} +` diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go new file mode 100644 index 00000000000..2271a9d2b11 --- /dev/null +++ b/github/github-stringify_test.go @@ -0,0 +1,1661 @@ +// Copyright 2019 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Code generated by gen-stringify-tests; DO NOT EDIT. + +package github + +import ( + "testing" +) + +func Float64(v float64) *float64 { return &v } + +func TestAdminStats_String(t *testing.T) { + v := AdminStats{ + Issues: &IssueStats{}, + Hooks: &HookStats{}, + Milestones: &MilestoneStats{}, + Orgs: &OrgStats{}, + Comments: &CommentStats{}, + Pages: &PageStats{}, + Users: &UserStats{}, + Gists: &GistStats{}, + Pulls: &PullStats{}, + Repos: &RepoStats{}, + } + want := `github.AdminStats{Issues:github.IssueStats{}, Hooks:github.HookStats{}, Milestones:github.MilestoneStats{}, Orgs:github.OrgStats{}, Comments:github.CommentStats{}, Pages:github.PageStats{}, Users:github.UserStats{}, Gists:github.GistStats{}, Pulls:github.PullStats{}, Repos:github.RepoStats{}}` + if got := v.String(); got != want { + t.Errorf("AdminStats.String = %v, want %v", got, want) + } +} + +func TestAuthorization_String(t *testing.T) { + v := Authorization{ + ID: Int64(0), + URL: String(""), + Token: String(""), + TokenLastEight: String(""), + HashedToken: String(""), + App: &AuthorizationApp{}, + Note: String(""), + NoteURL: String(""), + UpdatedAt: &Timestamp{}, + CreatedAt: &Timestamp{}, + Fingerprint: String(""), + User: &User{}, + } + want := `github.Authorization{ID:0, URL:"", Token:"", TokenLastEight:"", HashedToken:"", App:github.AuthorizationApp{}, Note:"", NoteURL:"", UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Fingerprint:"", User:github.User{}}` + if got := v.String(); got != want { + t.Errorf("Authorization.String = %v, want %v", got, want) + } +} + +func TestAuthorizationApp_String(t *testing.T) { + v := AuthorizationApp{ + URL: String(""), + Name: String(""), + ClientID: String(""), + } + want := `github.AuthorizationApp{URL:"", Name:"", ClientID:""}` + if got := v.String(); got != want { + t.Errorf("AuthorizationApp.String = %v, want %v", got, want) + } +} + +func TestAuthorizationRequest_String(t *testing.T) { + v := AuthorizationRequest{ + Note: String(""), + NoteURL: String(""), + ClientID: String(""), + ClientSecret: String(""), + Fingerprint: String(""), + } + want := `github.AuthorizationRequest{Note:"", NoteURL:"", ClientID:"", ClientSecret:"", Fingerprint:""}` + if got := v.String(); got != want { + t.Errorf("AuthorizationRequest.String = %v, want %v", got, want) + } +} + +func TestAuthorizationUpdateRequest_String(t *testing.T) { + v := AuthorizationUpdateRequest{ + Note: String(""), + NoteURL: String(""), + Fingerprint: String(""), + } + want := `github.AuthorizationUpdateRequest{Note:"", NoteURL:"", Fingerprint:""}` + if got := v.String(); got != want { + t.Errorf("AuthorizationUpdateRequest.String = %v, want %v", got, want) + } +} + +func TestCheckRun_String(t *testing.T) { + v := CheckRun{ + ID: Int64(0), + NodeID: String(""), + HeadSHA: String(""), + ExternalID: String(""), + URL: String(""), + HTMLURL: String(""), + DetailsURL: String(""), + Status: String(""), + Conclusion: String(""), + StartedAt: &Timestamp{}, + CompletedAt: &Timestamp{}, + Output: &CheckRunOutput{}, + Name: String(""), + CheckSuite: &CheckSuite{}, + App: &App{}, + } + want := `github.CheckRun{ID:0, NodeID:"", HeadSHA:"", ExternalID:"", URL:"", HTMLURL:"", DetailsURL:"", Status:"", Conclusion:"", StartedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, CompletedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Output:github.CheckRunOutput{}, Name:"", CheckSuite:github.CheckSuite{}, App:github.App{}}` + if got := v.String(); got != want { + t.Errorf("CheckRun.String = %v, want %v", got, want) + } +} + +func TestCheckSuite_String(t *testing.T) { + v := CheckSuite{ + ID: Int64(0), + NodeID: String(""), + HeadBranch: String(""), + HeadSHA: String(""), + URL: String(""), + BeforeSHA: String(""), + AfterSHA: String(""), + Status: String(""), + Conclusion: String(""), + App: &App{}, + Repository: &Repository{}, + HeadCommit: &Commit{}, + } + want := `github.CheckSuite{ID:0, NodeID:"", HeadBranch:"", HeadSHA:"", URL:"", BeforeSHA:"", AfterSHA:"", Status:"", Conclusion:"", App:github.App{}, Repository:github.Repository{}, HeadCommit:github.Commit{}}` + if got := v.String(); got != want { + t.Errorf("CheckSuite.String = %v, want %v", got, want) + } +} + +func TestCodeResult_String(t *testing.T) { + v := CodeResult{ + Name: String(""), + Path: String(""), + SHA: String(""), + HTMLURL: String(""), + Repository: &Repository{}, + } + want := `github.CodeResult{Name:"", Path:"", SHA:"", HTMLURL:"", Repository:github.Repository{}}` + if got := v.String(); got != want { + t.Errorf("CodeResult.String = %v, want %v", got, want) + } +} + +func TestCombinedStatus_String(t *testing.T) { + v := CombinedStatus{ + State: String(""), + Name: String(""), + SHA: String(""), + TotalCount: Int(0), + CommitURL: String(""), + RepositoryURL: String(""), + } + want := `github.CombinedStatus{State:"", Name:"", SHA:"", TotalCount:0, CommitURL:"", RepositoryURL:""}` + if got := v.String(); got != want { + t.Errorf("CombinedStatus.String = %v, want %v", got, want) + } +} + +func TestCommentStats_String(t *testing.T) { + v := CommentStats{ + TotalCommitComments: Int(0), + TotalGistComments: Int(0), + TotalIssueComments: Int(0), + TotalPullRequestComments: Int(0), + } + want := `github.CommentStats{TotalCommitComments:0, TotalGistComments:0, TotalIssueComments:0, TotalPullRequestComments:0}` + if got := v.String(); got != want { + t.Errorf("CommentStats.String = %v, want %v", got, want) + } +} + +func TestCommit_String(t *testing.T) { + v := Commit{ + SHA: String(""), + Author: &CommitAuthor{}, + Committer: &CommitAuthor{}, + Message: String(""), + Tree: &Tree{}, + Stats: &CommitStats{}, + HTMLURL: String(""), + URL: String(""), + Verification: &SignatureVerification{}, + NodeID: String(""), + CommentCount: Int(0), + } + want := `github.Commit{SHA:"", Author:github.CommitAuthor{}, Committer:github.CommitAuthor{}, Message:"", Tree:github.Tree{}, Stats:github.CommitStats{}, HTMLURL:"", URL:"", Verification:github.SignatureVerification{}, NodeID:"", CommentCount:0}` + if got := v.String(); got != want { + t.Errorf("Commit.String = %v, want %v", got, want) + } +} + +func TestCommitAuthor_String(t *testing.T) { + v := CommitAuthor{ + Name: String(""), + Email: String(""), + Login: String(""), + } + want := `github.CommitAuthor{Name:"", Email:"", Login:""}` + if got := v.String(); got != want { + t.Errorf("CommitAuthor.String = %v, want %v", got, want) + } +} + +func TestCommitFile_String(t *testing.T) { + v := CommitFile{ + SHA: String(""), + Filename: String(""), + Additions: Int(0), + Deletions: Int(0), + Changes: Int(0), + Status: String(""), + Patch: String(""), + BlobURL: String(""), + RawURL: String(""), + ContentsURL: String(""), + PreviousFilename: String(""), + } + want := `github.CommitFile{SHA:"", Filename:"", Additions:0, Deletions:0, Changes:0, Status:"", Patch:"", BlobURL:"", RawURL:"", ContentsURL:"", PreviousFilename:""}` + if got := v.String(); got != want { + t.Errorf("CommitFile.String = %v, want %v", got, want) + } +} + +func TestCommitStats_String(t *testing.T) { + v := CommitStats{ + Additions: Int(0), + Deletions: Int(0), + Total: Int(0), + } + want := `github.CommitStats{Additions:0, Deletions:0, Total:0}` + if got := v.String(); got != want { + t.Errorf("CommitStats.String = %v, want %v", got, want) + } +} + +func TestCommitsComparison_String(t *testing.T) { + v := CommitsComparison{ + BaseCommit: &RepositoryCommit{}, + MergeBaseCommit: &RepositoryCommit{}, + Status: String(""), + AheadBy: Int(0), + BehindBy: Int(0), + TotalCommits: Int(0), + HTMLURL: String(""), + PermalinkURL: String(""), + DiffURL: String(""), + PatchURL: String(""), + URL: String(""), + } + want := `github.CommitsComparison{BaseCommit:github.RepositoryCommit{}, MergeBaseCommit:github.RepositoryCommit{}, Status:"", AheadBy:0, BehindBy:0, TotalCommits:0, HTMLURL:"", PermalinkURL:"", DiffURL:"", PatchURL:"", URL:""}` + if got := v.String(); got != want { + t.Errorf("CommitsComparison.String = %v, want %v", got, want) + } +} + +func TestContributorStats_String(t *testing.T) { + v := ContributorStats{ + Author: &Contributor{}, + Total: Int(0), + } + want := `github.ContributorStats{Author:github.Contributor{}, Total:0}` + if got := v.String(); got != want { + t.Errorf("ContributorStats.String = %v, want %v", got, want) + } +} + +func TestDiscussionComment_String(t *testing.T) { + v := DiscussionComment{ + Author: &User{}, + Body: String(""), + BodyHTML: String(""), + BodyVersion: String(""), + CreatedAt: &Timestamp{}, + LastEditedAt: &Timestamp{}, + DiscussionURL: String(""), + HTMLURL: String(""), + NodeID: String(""), + Number: Int(0), + UpdatedAt: &Timestamp{}, + URL: String(""), + Reactions: &Reactions{}, + } + want := `github.DiscussionComment{Author:github.User{}, Body:"", BodyHTML:"", BodyVersion:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, LastEditedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, DiscussionURL:"", HTMLURL:"", NodeID:"", Number:0, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, URL:"", Reactions:github.Reactions{}}` + if got := v.String(); got != want { + t.Errorf("DiscussionComment.String = %v, want %v", got, want) + } +} + +func TestDraftReviewComment_String(t *testing.T) { + v := DraftReviewComment{ + Path: String(""), + Position: Int(0), + Body: String(""), + } + want := `github.DraftReviewComment{Path:"", Position:0, Body:""}` + if got := v.String(); got != want { + t.Errorf("DraftReviewComment.String = %v, want %v", got, want) + } +} + +func TestEvent_String(t *testing.T) { + v := Event{ + Type: String(""), + Public: Bool(false), + Repo: &Repository{}, + Actor: &User{}, + Org: &Organization{}, + ID: String(""), + } + want := `github.Event{Type:"", Public:false, Repo:github.Repository{}, Actor:github.User{}, Org:github.Organization{}, ID:""}` + if got := v.String(); got != want { + t.Errorf("Event.String = %v, want %v", got, want) + } +} + +func TestGPGKey_String(t *testing.T) { + v := GPGKey{ + ID: Int64(0), + PrimaryKeyID: Int64(0), + KeyID: String(""), + PublicKey: String(""), + CanSign: Bool(false), + CanEncryptComms: Bool(false), + CanEncryptStorage: Bool(false), + CanCertify: Bool(false), + } + want := `github.GPGKey{ID:0, PrimaryKeyID:0, KeyID:"", PublicKey:"", CanSign:false, CanEncryptComms:false, CanEncryptStorage:false, CanCertify:false}` + if got := v.String(); got != want { + t.Errorf("GPGKey.String = %v, want %v", got, want) + } +} + +func TestGist_String(t *testing.T) { + v := Gist{ + ID: String(""), + Description: String(""), + Public: Bool(false), + Owner: &User{}, + Files: nil, + Comments: Int(0), + HTMLURL: String(""), + GitPullURL: String(""), + GitPushURL: String(""), + NodeID: String(""), + } + want := `github.Gist{ID:"", Description:"", Public:false, Owner:github.User{}, Files:map[], Comments:0, HTMLURL:"", GitPullURL:"", GitPushURL:"", NodeID:""}` + if got := v.String(); got != want { + t.Errorf("Gist.String = %v, want %v", got, want) + } +} + +func TestGistComment_String(t *testing.T) { + v := GistComment{ + ID: Int64(0), + URL: String(""), + Body: String(""), + User: &User{}, + } + want := `github.GistComment{ID:0, URL:"", Body:"", User:github.User{}}` + if got := v.String(); got != want { + t.Errorf("GistComment.String = %v, want %v", got, want) + } +} + +func TestGistCommit_String(t *testing.T) { + v := GistCommit{ + URL: String(""), + Version: String(""), + User: &User{}, + ChangeStatus: &CommitStats{}, + CommittedAt: &Timestamp{}, + NodeID: String(""), + } + want := `github.GistCommit{URL:"", Version:"", User:github.User{}, ChangeStatus:github.CommitStats{}, CommittedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("GistCommit.String = %v, want %v", got, want) + } +} + +func TestGistFile_String(t *testing.T) { + v := GistFile{ + Size: Int(0), + Filename: String(""), + Language: String(""), + Type: String(""), + RawURL: String(""), + Content: String(""), + } + want := `github.GistFile{Size:0, Filename:"", Language:"", Type:"", RawURL:"", Content:""}` + if got := v.String(); got != want { + t.Errorf("GistFile.String = %v, want %v", got, want) + } +} + +func TestGistFork_String(t *testing.T) { + v := GistFork{ + URL: String(""), + User: &User{}, + ID: String(""), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + NodeID: String(""), + } + want := `github.GistFork{URL:"", User:github.User{}, ID:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("GistFork.String = %v, want %v", got, want) + } +} + +func TestGistStats_String(t *testing.T) { + v := GistStats{ + TotalGists: Int(0), + PrivateGists: Int(0), + PublicGists: Int(0), + } + want := `github.GistStats{TotalGists:0, PrivateGists:0, PublicGists:0}` + if got := v.String(); got != want { + t.Errorf("GistStats.String = %v, want %v", got, want) + } +} + +func TestGitObject_String(t *testing.T) { + v := GitObject{ + Type: String(""), + SHA: String(""), + URL: String(""), + } + want := `github.GitObject{Type:"", SHA:"", URL:""}` + if got := v.String(); got != want { + t.Errorf("GitObject.String = %v, want %v", got, want) + } +} + +func TestGitignore_String(t *testing.T) { + v := Gitignore{ + Name: String(""), + Source: String(""), + } + want := `github.Gitignore{Name:"", Source:""}` + if got := v.String(); got != want { + t.Errorf("Gitignore.String = %v, want %v", got, want) + } +} + +func TestGrant_String(t *testing.T) { + v := Grant{ + ID: Int64(0), + URL: String(""), + App: &AuthorizationApp{}, + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + } + want := `github.Grant{ID:0, URL:"", App:github.AuthorizationApp{}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` + if got := v.String(); got != want { + t.Errorf("Grant.String = %v, want %v", got, want) + } +} + +func TestHook_String(t *testing.T) { + v := Hook{ + URL: String(""), + ID: Int64(0), + Config: nil, + Active: Bool(false), + } + want := `github.Hook{URL:"", ID:0, Config:map[], Active:false}` + if got := v.String(); got != want { + t.Errorf("Hook.String = %v, want %v", got, want) + } +} + +func TestHookStats_String(t *testing.T) { + v := HookStats{ + TotalHooks: Int(0), + ActiveHooks: Int(0), + InactiveHooks: Int(0), + } + want := `github.HookStats{TotalHooks:0, ActiveHooks:0, InactiveHooks:0}` + if got := v.String(); got != want { + t.Errorf("HookStats.String = %v, want %v", got, want) + } +} + +func TestImport_String(t *testing.T) { + v := Import{ + VCSURL: String(""), + VCS: String(""), + VCSUsername: String(""), + VCSPassword: String(""), + TFVCProject: String(""), + UseLFS: String(""), + HasLargeFiles: Bool(false), + LargeFilesSize: Int(0), + LargeFilesCount: Int(0), + Status: String(""), + CommitCount: Int(0), + StatusText: String(""), + AuthorsCount: Int(0), + Percent: Int(0), + PushPercent: Int(0), + URL: String(""), + HTMLURL: String(""), + AuthorsURL: String(""), + RepositoryURL: String(""), + Message: String(""), + FailedStep: String(""), + HumanName: String(""), + } + want := `github.Import{VCSURL:"", VCS:"", VCSUsername:"", VCSPassword:"", TFVCProject:"", UseLFS:"", HasLargeFiles:false, LargeFilesSize:0, LargeFilesCount:0, Status:"", CommitCount:0, StatusText:"", AuthorsCount:0, Percent:0, PushPercent:0, URL:"", HTMLURL:"", AuthorsURL:"", RepositoryURL:"", Message:"", FailedStep:"", HumanName:""}` + if got := v.String(); got != want { + t.Errorf("Import.String = %v, want %v", got, want) + } +} + +func TestInstallation_String(t *testing.T) { + v := Installation{ + ID: Int64(0), + AppID: Int64(0), + TargetID: Int64(0), + Account: &User{}, + AccessTokensURL: String(""), + RepositoriesURL: String(""), + HTMLURL: String(""), + TargetType: String(""), + SingleFileName: String(""), + RepositorySelection: String(""), + Permissions: &InstallationPermissions{}, + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + } + want := `github.Installation{ID:0, AppID:0, TargetID:0, Account:github.User{}, AccessTokensURL:"", RepositoriesURL:"", HTMLURL:"", TargetType:"", SingleFileName:"", RepositorySelection:"", Permissions:github.InstallationPermissions{}, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` + if got := v.String(); got != want { + t.Errorf("Installation.String = %v, want %v", got, want) + } +} + +func TestInvitation_String(t *testing.T) { + v := Invitation{ + ID: Int64(0), + NodeID: String(""), + Login: String(""), + Email: String(""), + Role: String(""), + Inviter: &User{}, + TeamCount: Int(0), + InvitationTeamURL: String(""), + } + want := `github.Invitation{ID:0, NodeID:"", Login:"", Email:"", Role:"", Inviter:github.User{}, TeamCount:0, InvitationTeamURL:""}` + if got := v.String(); got != want { + t.Errorf("Invitation.String = %v, want %v", got, want) + } +} + +func TestIssue_String(t *testing.T) { + v := Issue{ + ID: Int64(0), + Number: Int(0), + State: String(""), + Locked: Bool(false), + Title: String(""), + Body: String(""), + User: &User{}, + Assignee: &User{}, + Comments: Int(0), + ClosedBy: &User{}, + URL: String(""), + HTMLURL: String(""), + CommentsURL: String(""), + EventsURL: String(""), + LabelsURL: String(""), + RepositoryURL: String(""), + Milestone: &Milestone{}, + PullRequestLinks: &PullRequestLinks{}, + Repository: &Repository{}, + Reactions: &Reactions{}, + NodeID: String(""), + ActiveLockReason: String(""), + } + want := `github.Issue{ID:0, Number:0, State:"", Locked:false, Title:"", Body:"", User:github.User{}, Assignee:github.User{}, Comments:0, ClosedBy:github.User{}, URL:"", HTMLURL:"", CommentsURL:"", EventsURL:"", LabelsURL:"", RepositoryURL:"", Milestone:github.Milestone{}, PullRequestLinks:github.PullRequestLinks{}, Repository:github.Repository{}, Reactions:github.Reactions{}, NodeID:"", ActiveLockReason:""}` + if got := v.String(); got != want { + t.Errorf("Issue.String = %v, want %v", got, want) + } +} + +func TestIssueComment_String(t *testing.T) { + v := IssueComment{ + ID: Int64(0), + NodeID: String(""), + Body: String(""), + User: &User{}, + Reactions: &Reactions{}, + AuthorAssociation: String(""), + URL: String(""), + HTMLURL: String(""), + IssueURL: String(""), + } + want := `github.IssueComment{ID:0, NodeID:"", Body:"", User:github.User{}, Reactions:github.Reactions{}, AuthorAssociation:"", URL:"", HTMLURL:"", IssueURL:""}` + if got := v.String(); got != want { + t.Errorf("IssueComment.String = %v, want %v", got, want) + } +} + +func TestIssueStats_String(t *testing.T) { + v := IssueStats{ + TotalIssues: Int(0), + OpenIssues: Int(0), + ClosedIssues: Int(0), + } + want := `github.IssueStats{TotalIssues:0, OpenIssues:0, ClosedIssues:0}` + if got := v.String(); got != want { + t.Errorf("IssueStats.String = %v, want %v", got, want) + } +} + +func TestKey_String(t *testing.T) { + v := Key{ + ID: Int64(0), + Key: String(""), + URL: String(""), + Title: String(""), + ReadOnly: Bool(false), + } + want := `github.Key{ID:0, Key:"", URL:"", Title:"", ReadOnly:false}` + if got := v.String(); got != want { + t.Errorf("Key.String = %v, want %v", got, want) + } +} + +func TestLabel_String(t *testing.T) { + v := Label{ + ID: Int64(0), + URL: String(""), + Name: String(""), + Color: String(""), + Description: String(""), + Default: Bool(false), + NodeID: String(""), + } + want := `github.Label{ID:0, URL:"", Name:"", Color:"", Description:"", Default:false, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("Label.String = %v, want %v", got, want) + } +} + +func TestLabelResult_String(t *testing.T) { + v := LabelResult{ + ID: Int64(0), + URL: String(""), + Name: String(""), + Color: String(""), + Default: Bool(false), + Description: String(""), + Score: Float64(0.0), + } + want := `github.LabelResult{ID:0, URL:"", Name:"", Color:"", Default:false, Description:"", Score:0}` + if got := v.String(); got != want { + t.Errorf("LabelResult.String = %v, want %v", got, want) + } +} + +func TestLargeFile_String(t *testing.T) { + v := LargeFile{ + RefName: String(""), + Path: String(""), + OID: String(""), + Size: Int(0), + } + want := `github.LargeFile{RefName:"", Path:"", OID:"", Size:0}` + if got := v.String(); got != want { + t.Errorf("LargeFile.String = %v, want %v", got, want) + } +} + +func TestLicense_String(t *testing.T) { + v := License{ + Key: String(""), + Name: String(""), + URL: String(""), + SPDXID: String(""), + HTMLURL: String(""), + Featured: Bool(false), + Description: String(""), + Implementation: String(""), + Body: String(""), + } + want := `github.License{Key:"", Name:"", URL:"", SPDXID:"", HTMLURL:"", Featured:false, Description:"", Implementation:"", Body:""}` + if got := v.String(); got != want { + t.Errorf("License.String = %v, want %v", got, want) + } +} + +func TestMembership_String(t *testing.T) { + v := Membership{ + URL: String(""), + State: String(""), + Role: String(""), + OrganizationURL: String(""), + Organization: &Organization{}, + User: &User{}, + } + want := `github.Membership{URL:"", State:"", Role:"", OrganizationURL:"", Organization:github.Organization{}, User:github.User{}}` + if got := v.String(); got != want { + t.Errorf("Membership.String = %v, want %v", got, want) + } +} + +func TestMigration_String(t *testing.T) { + v := Migration{ + ID: Int64(0), + GUID: String(""), + State: String(""), + LockRepositories: Bool(false), + ExcludeAttachments: Bool(false), + URL: String(""), + CreatedAt: String(""), + UpdatedAt: String(""), + } + want := `github.Migration{ID:0, GUID:"", State:"", LockRepositories:false, ExcludeAttachments:false, URL:"", CreatedAt:"", UpdatedAt:""}` + if got := v.String(); got != want { + t.Errorf("Migration.String = %v, want %v", got, want) + } +} + +func TestMilestone_String(t *testing.T) { + v := Milestone{ + URL: String(""), + HTMLURL: String(""), + LabelsURL: String(""), + ID: Int64(0), + Number: Int(0), + State: String(""), + Title: String(""), + Description: String(""), + Creator: &User{}, + OpenIssues: Int(0), + ClosedIssues: Int(0), + NodeID: String(""), + } + want := `github.Milestone{URL:"", HTMLURL:"", LabelsURL:"", ID:0, Number:0, State:"", Title:"", Description:"", Creator:github.User{}, OpenIssues:0, ClosedIssues:0, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("Milestone.String = %v, want %v", got, want) + } +} + +func TestMilestoneStats_String(t *testing.T) { + v := MilestoneStats{ + TotalMilestones: Int(0), + OpenMilestones: Int(0), + ClosedMilestones: Int(0), + } + want := `github.MilestoneStats{TotalMilestones:0, OpenMilestones:0, ClosedMilestones:0}` + if got := v.String(); got != want { + t.Errorf("MilestoneStats.String = %v, want %v", got, want) + } +} + +func TestNewTeam_String(t *testing.T) { + v := NewTeam{ + Name: "", + Description: String(""), + ParentTeamID: Int64(0), + Permission: String(""), + Privacy: String(""), + LDAPDN: String(""), + } + want := `github.NewTeam{Name:"", Description:"", ParentTeamID:0, Permission:"", Privacy:"", LDAPDN:""}` + if got := v.String(); got != want { + t.Errorf("NewTeam.String = %v, want %v", got, want) + } +} + +func TestOrgStats_String(t *testing.T) { + v := OrgStats{ + TotalOrgs: Int(0), + DisabledOrgs: Int(0), + TotalTeams: Int(0), + TotalTeamMembers: Int(0), + } + want := `github.OrgStats{TotalOrgs:0, DisabledOrgs:0, TotalTeams:0, TotalTeamMembers:0}` + if got := v.String(); got != want { + t.Errorf("OrgStats.String = %v, want %v", got, want) + } +} + +func TestOrganization_String(t *testing.T) { + v := Organization{ + Login: String(""), + ID: Int64(0), + NodeID: String(""), + AvatarURL: String(""), + HTMLURL: String(""), + Name: String(""), + Company: String(""), + Blog: String(""), + Location: String(""), + Email: String(""), + Description: String(""), + PublicRepos: Int(0), + PublicGists: Int(0), + Followers: Int(0), + Following: Int(0), + TotalPrivateRepos: Int(0), + OwnedPrivateRepos: Int(0), + PrivateGists: Int(0), + DiskUsage: Int(0), + Collaborators: Int(0), + BillingEmail: String(""), + Type: String(""), + Plan: &Plan{}, + TwoFactorRequirementEnabled: Bool(false), + DefaultRepoPermission: String(""), + DefaultRepoSettings: String(""), + MembersCanCreateRepos: Bool(false), + URL: String(""), + EventsURL: String(""), + HooksURL: String(""), + IssuesURL: String(""), + MembersURL: String(""), + PublicMembersURL: String(""), + ReposURL: String(""), + } + want := `github.Organization{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Description:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, BillingEmail:"", Type:"", Plan:github.Plan{}, TwoFactorRequirementEnabled:false, DefaultRepoPermission:"", DefaultRepoSettings:"", MembersCanCreateRepos:false, URL:"", EventsURL:"", HooksURL:"", IssuesURL:"", MembersURL:"", PublicMembersURL:"", ReposURL:""}` + if got := v.String(); got != want { + t.Errorf("Organization.String = %v, want %v", got, want) + } +} + +func TestPageStats_String(t *testing.T) { + v := PageStats{ + TotalPages: Int(0), + } + want := `github.PageStats{TotalPages:0}` + if got := v.String(); got != want { + t.Errorf("PageStats.String = %v, want %v", got, want) + } +} + +func TestPlan_String(t *testing.T) { + v := Plan{ + Name: String(""), + Space: Int(0), + Collaborators: Int(0), + PrivateRepos: Int(0), + } + want := `github.Plan{Name:"", Space:0, Collaborators:0, PrivateRepos:0}` + if got := v.String(); got != want { + t.Errorf("Plan.String = %v, want %v", got, want) + } +} + +func TestPreReceiveHook_String(t *testing.T) { + v := PreReceiveHook{ + ID: Int64(0), + Name: String(""), + Enforcement: String(""), + ConfigURL: String(""), + } + want := `github.PreReceiveHook{ID:0, Name:"", Enforcement:"", ConfigURL:""}` + if got := v.String(); got != want { + t.Errorf("PreReceiveHook.String = %v, want %v", got, want) + } +} + +func TestProject_String(t *testing.T) { + v := Project{ + ID: Int64(0), + URL: String(""), + HTMLURL: String(""), + ColumnsURL: String(""), + OwnerURL: String(""), + Name: String(""), + Body: String(""), + Number: Int(0), + State: String(""), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + NodeID: String(""), + Creator: &User{}, + } + want := `github.Project{ID:0, URL:"", HTMLURL:"", ColumnsURL:"", OwnerURL:"", Name:"", Body:"", Number:0, State:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, NodeID:"", Creator:github.User{}}` + if got := v.String(); got != want { + t.Errorf("Project.String = %v, want %v", got, want) + } +} + +func TestPullRequest_String(t *testing.T) { + v := PullRequest{ + ID: Int64(0), + Number: Int(0), + State: String(""), + Title: String(""), + Body: String(""), + User: &User{}, + Draft: Bool(false), + Merged: Bool(false), + Mergeable: Bool(false), + MergeableState: String(""), + MergedBy: &User{}, + MergeCommitSHA: String(""), + Comments: Int(0), + Commits: Int(0), + Additions: Int(0), + Deletions: Int(0), + ChangedFiles: Int(0), + URL: String(""), + HTMLURL: String(""), + IssueURL: String(""), + StatusesURL: String(""), + DiffURL: String(""), + PatchURL: String(""), + CommitsURL: String(""), + CommentsURL: String(""), + ReviewCommentsURL: String(""), + ReviewCommentURL: String(""), + ReviewComments: Int(0), + Assignee: &User{}, + Milestone: &Milestone{}, + MaintainerCanModify: Bool(false), + AuthorAssociation: String(""), + NodeID: String(""), + Links: &PRLinks{}, + Head: &PullRequestBranch{}, + Base: &PullRequestBranch{}, + ActiveLockReason: String(""), + } + want := `github.PullRequest{ID:0, Number:0, State:"", Title:"", Body:"", User:github.User{}, Draft:false, Merged:false, Mergeable:false, MergeableState:"", MergedBy:github.User{}, MergeCommitSHA:"", Comments:0, Commits:0, Additions:0, Deletions:0, ChangedFiles:0, URL:"", HTMLURL:"", IssueURL:"", StatusesURL:"", DiffURL:"", PatchURL:"", CommitsURL:"", CommentsURL:"", ReviewCommentsURL:"", ReviewCommentURL:"", ReviewComments:0, Assignee:github.User{}, Milestone:github.Milestone{}, MaintainerCanModify:false, AuthorAssociation:"", NodeID:"", Links:github.PRLinks{}, Head:github.PullRequestBranch{}, Base:github.PullRequestBranch{}, ActiveLockReason:""}` + if got := v.String(); got != want { + t.Errorf("PullRequest.String = %v, want %v", got, want) + } +} + +func TestPullRequestComment_String(t *testing.T) { + v := PullRequestComment{ + ID: Int64(0), + NodeID: String(""), + InReplyTo: Int64(0), + Body: String(""), + Path: String(""), + DiffHunk: String(""), + PullRequestReviewID: Int64(0), + Position: Int(0), + OriginalPosition: Int(0), + CommitID: String(""), + OriginalCommitID: String(""), + User: &User{}, + Reactions: &Reactions{}, + AuthorAssociation: String(""), + URL: String(""), + HTMLURL: String(""), + PullRequestURL: String(""), + } + want := `github.PullRequestComment{ID:0, NodeID:"", InReplyTo:0, Body:"", Path:"", DiffHunk:"", PullRequestReviewID:0, Position:0, OriginalPosition:0, CommitID:"", OriginalCommitID:"", User:github.User{}, Reactions:github.Reactions{}, AuthorAssociation:"", URL:"", HTMLURL:"", PullRequestURL:""}` + if got := v.String(); got != want { + t.Errorf("PullRequestComment.String = %v, want %v", got, want) + } +} + +func TestPullRequestReview_String(t *testing.T) { + v := PullRequestReview{ + ID: Int64(0), + NodeID: String(""), + User: &User{}, + Body: String(""), + CommitID: String(""), + HTMLURL: String(""), + PullRequestURL: String(""), + State: String(""), + } + want := `github.PullRequestReview{ID:0, NodeID:"", User:github.User{}, Body:"", CommitID:"", HTMLURL:"", PullRequestURL:"", State:""}` + if got := v.String(); got != want { + t.Errorf("PullRequestReview.String = %v, want %v", got, want) + } +} + +func TestPullRequestReviewDismissalRequest_String(t *testing.T) { + v := PullRequestReviewDismissalRequest{ + Message: String(""), + } + want := `github.PullRequestReviewDismissalRequest{Message:""}` + if got := v.String(); got != want { + t.Errorf("PullRequestReviewDismissalRequest.String = %v, want %v", got, want) + } +} + +func TestPullRequestReviewRequest_String(t *testing.T) { + v := PullRequestReviewRequest{ + NodeID: String(""), + CommitID: String(""), + Body: String(""), + Event: String(""), + } + want := `github.PullRequestReviewRequest{NodeID:"", CommitID:"", Body:"", Event:""}` + if got := v.String(); got != want { + t.Errorf("PullRequestReviewRequest.String = %v, want %v", got, want) + } +} + +func TestPullStats_String(t *testing.T) { + v := PullStats{ + TotalPulls: Int(0), + MergedPulls: Int(0), + MergablePulls: Int(0), + UnmergablePulls: Int(0), + } + want := `github.PullStats{TotalPulls:0, MergedPulls:0, MergablePulls:0, UnmergablePulls:0}` + if got := v.String(); got != want { + t.Errorf("PullStats.String = %v, want %v", got, want) + } +} + +func TestPushEvent_String(t *testing.T) { + v := PushEvent{ + PushID: Int64(0), + Head: String(""), + Ref: String(""), + Size: Int(0), + Before: String(""), + DistinctSize: Int(0), + After: String(""), + Created: Bool(false), + Deleted: Bool(false), + Forced: Bool(false), + BaseRef: String(""), + Compare: String(""), + Repo: &PushEventRepository{}, + HeadCommit: &PushEventCommit{}, + Pusher: &User{}, + Sender: &User{}, + Installation: &Installation{}, + } + want := `github.PushEvent{PushID:0, Head:"", Ref:"", Size:0, Before:"", DistinctSize:0, After:"", Created:false, Deleted:false, Forced:false, BaseRef:"", Compare:"", Repo:github.PushEventRepository{}, HeadCommit:github.PushEventCommit{}, Pusher:github.User{}, Sender:github.User{}, Installation:github.Installation{}}` + if got := v.String(); got != want { + t.Errorf("PushEvent.String = %v, want %v", got, want) + } +} + +func TestPushEventCommit_String(t *testing.T) { + v := PushEventCommit{ + Message: String(""), + Author: &CommitAuthor{}, + URL: String(""), + Distinct: Bool(false), + SHA: String(""), + ID: String(""), + TreeID: String(""), + Timestamp: &Timestamp{}, + Committer: &CommitAuthor{}, + } + want := `github.PushEventCommit{Message:"", Author:github.CommitAuthor{}, URL:"", Distinct:false, SHA:"", ID:"", TreeID:"", Timestamp:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Committer:github.CommitAuthor{}}` + if got := v.String(); got != want { + t.Errorf("PushEventCommit.String = %v, want %v", got, want) + } +} + +func TestRate_String(t *testing.T) { + v := Rate{ + Limit: 0, + Remaining: 0, + Reset: Timestamp{}, + } + want := `github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` + if got := v.String(); got != want { + t.Errorf("Rate.String = %v, want %v", got, want) + } +} + +func TestReaction_String(t *testing.T) { + v := Reaction{ + ID: Int64(0), + User: &User{}, + NodeID: String(""), + Content: String(""), + } + want := `github.Reaction{ID:0, User:github.User{}, NodeID:"", Content:""}` + if got := v.String(); got != want { + t.Errorf("Reaction.String = %v, want %v", got, want) + } +} + +func TestReference_String(t *testing.T) { + v := Reference{ + Ref: String(""), + URL: String(""), + Object: &GitObject{}, + NodeID: String(""), + } + want := `github.Reference{Ref:"", URL:"", Object:github.GitObject{}, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("Reference.String = %v, want %v", got, want) + } +} + +func TestReleaseAsset_String(t *testing.T) { + v := ReleaseAsset{ + ID: Int64(0), + URL: String(""), + Name: String(""), + Label: String(""), + State: String(""), + ContentType: String(""), + Size: Int(0), + DownloadCount: Int(0), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + BrowserDownloadURL: String(""), + Uploader: &User{}, + NodeID: String(""), + } + want := `github.ReleaseAsset{ID:0, URL:"", Name:"", Label:"", State:"", ContentType:"", Size:0, DownloadCount:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, BrowserDownloadURL:"", Uploader:github.User{}, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("ReleaseAsset.String = %v, want %v", got, want) + } +} + +func TestRename_String(t *testing.T) { + v := Rename{ + From: String(""), + To: String(""), + } + want := `github.Rename{From:"", To:""}` + if got := v.String(); got != want { + t.Errorf("Rename.String = %v, want %v", got, want) + } +} + +func TestRepoStats_String(t *testing.T) { + v := RepoStats{ + TotalRepos: Int(0), + RootRepos: Int(0), + ForkRepos: Int(0), + OrgRepos: Int(0), + TotalPushes: Int(0), + TotalWikis: Int(0), + } + want := `github.RepoStats{TotalRepos:0, RootRepos:0, ForkRepos:0, OrgRepos:0, TotalPushes:0, TotalWikis:0}` + if got := v.String(); got != want { + t.Errorf("RepoStats.String = %v, want %v", got, want) + } +} + +func TestRepoStatus_String(t *testing.T) { + v := RepoStatus{ + ID: Int64(0), + NodeID: String(""), + URL: String(""), + State: String(""), + TargetURL: String(""), + Description: String(""), + Context: String(""), + Creator: &User{}, + } + want := `github.RepoStatus{ID:0, NodeID:"", URL:"", State:"", TargetURL:"", Description:"", Context:"", Creator:github.User{}}` + if got := v.String(); got != want { + t.Errorf("RepoStatus.String = %v, want %v", got, want) + } +} + +func TestRepository_String(t *testing.T) { + v := Repository{ + ID: Int64(0), + NodeID: String(""), + Owner: &User{}, + Name: String(""), + FullName: String(""), + Description: String(""), + Homepage: String(""), + CodeOfConduct: &CodeOfConduct{}, + DefaultBranch: String(""), + MasterBranch: String(""), + CreatedAt: &Timestamp{}, + PushedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + HTMLURL: String(""), + CloneURL: String(""), + GitURL: String(""), + MirrorURL: String(""), + SSHURL: String(""), + SVNURL: String(""), + Language: String(""), + Fork: Bool(false), + ForksCount: Int(0), + NetworkCount: Int(0), + OpenIssuesCount: Int(0), + StargazersCount: Int(0), + SubscribersCount: Int(0), + WatchersCount: Int(0), + Size: Int(0), + AutoInit: Bool(false), + Parent: &Repository{}, + Source: &Repository{}, + Organization: &Organization{}, + AllowRebaseMerge: Bool(false), + AllowSquashMerge: Bool(false), + AllowMergeCommit: Bool(false), + Archived: Bool(false), + Disabled: Bool(false), + License: &License{}, + Private: Bool(false), + HasIssues: Bool(false), + HasWiki: Bool(false), + HasPages: Bool(false), + HasProjects: Bool(false), + HasDownloads: Bool(false), + LicenseTemplate: String(""), + GitignoreTemplate: String(""), + TeamID: Int64(0), + URL: String(""), + ArchiveURL: String(""), + AssigneesURL: String(""), + BlobsURL: String(""), + BranchesURL: String(""), + CollaboratorsURL: String(""), + CommentsURL: String(""), + CommitsURL: String(""), + CompareURL: String(""), + ContentsURL: String(""), + ContributorsURL: String(""), + DeploymentsURL: String(""), + DownloadsURL: String(""), + EventsURL: String(""), + ForksURL: String(""), + GitCommitsURL: String(""), + GitRefsURL: String(""), + GitTagsURL: String(""), + HooksURL: String(""), + IssueCommentURL: String(""), + IssueEventsURL: String(""), + IssuesURL: String(""), + KeysURL: String(""), + LabelsURL: String(""), + LanguagesURL: String(""), + MergesURL: String(""), + MilestonesURL: String(""), + NotificationsURL: String(""), + PullsURL: String(""), + ReleasesURL: String(""), + StargazersURL: String(""), + StatusesURL: String(""), + SubscribersURL: String(""), + SubscriptionURL: String(""), + TagsURL: String(""), + TreesURL: String(""), + TeamsURL: String(""), + } + want := `github.Repository{ID:0, NodeID:"", Owner:github.User{}, Name:"", FullName:"", Description:"", Homepage:"", CodeOfConduct:github.CodeOfConduct{}, DefaultBranch:"", MasterBranch:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PushedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HTMLURL:"", CloneURL:"", GitURL:"", MirrorURL:"", SSHURL:"", SVNURL:"", Language:"", Fork:false, ForksCount:0, NetworkCount:0, OpenIssuesCount:0, StargazersCount:0, SubscribersCount:0, WatchersCount:0, Size:0, AutoInit:false, Parent:github.Repository{}, Source:github.Repository{}, Organization:github.Organization{}, AllowRebaseMerge:false, AllowSquashMerge:false, AllowMergeCommit:false, Archived:false, Disabled:false, License:github.License{}, Private:false, HasIssues:false, HasWiki:false, HasPages:false, HasProjects:false, HasDownloads:false, LicenseTemplate:"", GitignoreTemplate:"", TeamID:0, URL:"", ArchiveURL:"", AssigneesURL:"", BlobsURL:"", BranchesURL:"", CollaboratorsURL:"", CommentsURL:"", CommitsURL:"", CompareURL:"", ContentsURL:"", ContributorsURL:"", DeploymentsURL:"", DownloadsURL:"", EventsURL:"", ForksURL:"", GitCommitsURL:"", GitRefsURL:"", GitTagsURL:"", HooksURL:"", IssueCommentURL:"", IssueEventsURL:"", IssuesURL:"", KeysURL:"", LabelsURL:"", LanguagesURL:"", MergesURL:"", MilestonesURL:"", NotificationsURL:"", PullsURL:"", ReleasesURL:"", StargazersURL:"", StatusesURL:"", SubscribersURL:"", SubscriptionURL:"", TagsURL:"", TreesURL:"", TeamsURL:""}` + if got := v.String(); got != want { + t.Errorf("Repository.String = %v, want %v", got, want) + } +} + +func TestRepositoryComment_String(t *testing.T) { + v := RepositoryComment{ + HTMLURL: String(""), + URL: String(""), + ID: Int64(0), + CommitID: String(""), + User: &User{}, + Reactions: &Reactions{}, + Body: String(""), + Path: String(""), + Position: Int(0), + } + want := `github.RepositoryComment{HTMLURL:"", URL:"", ID:0, CommitID:"", User:github.User{}, Reactions:github.Reactions{}, Body:"", Path:"", Position:0}` + if got := v.String(); got != want { + t.Errorf("RepositoryComment.String = %v, want %v", got, want) + } +} + +func TestRepositoryCommit_String(t *testing.T) { + v := RepositoryCommit{ + NodeID: String(""), + SHA: String(""), + Commit: &Commit{}, + Author: &User{}, + Committer: &User{}, + HTMLURL: String(""), + URL: String(""), + CommentsURL: String(""), + Stats: &CommitStats{}, + } + want := `github.RepositoryCommit{NodeID:"", SHA:"", Commit:github.Commit{}, Author:github.User{}, Committer:github.User{}, HTMLURL:"", URL:"", CommentsURL:"", Stats:github.CommitStats{}}` + if got := v.String(); got != want { + t.Errorf("RepositoryCommit.String = %v, want %v", got, want) + } +} + +func TestRepositoryContent_String(t *testing.T) { + v := RepositoryContent{ + Type: String(""), + Target: String(""), + Encoding: String(""), + Size: Int(0), + Name: String(""), + Path: String(""), + Content: String(""), + SHA: String(""), + URL: String(""), + GitURL: String(""), + HTMLURL: String(""), + DownloadURL: String(""), + } + want := `github.RepositoryContent{Type:"", Target:"", Encoding:"", Size:0, Name:"", Path:"", Content:"", SHA:"", URL:"", GitURL:"", HTMLURL:"", DownloadURL:""}` + if got := v.String(); got != want { + t.Errorf("RepositoryContent.String = %v, want %v", got, want) + } +} + +func TestRepositoryLicense_String(t *testing.T) { + v := RepositoryLicense{ + Name: String(""), + Path: String(""), + SHA: String(""), + Size: Int(0), + URL: String(""), + HTMLURL: String(""), + GitURL: String(""), + DownloadURL: String(""), + Type: String(""), + Content: String(""), + Encoding: String(""), + License: &License{}, + } + want := `github.RepositoryLicense{Name:"", Path:"", SHA:"", Size:0, URL:"", HTMLURL:"", GitURL:"", DownloadURL:"", Type:"", Content:"", Encoding:"", License:github.License{}}` + if got := v.String(); got != want { + t.Errorf("RepositoryLicense.String = %v, want %v", got, want) + } +} + +func TestRepositoryRelease_String(t *testing.T) { + v := RepositoryRelease{ + TagName: String(""), + TargetCommitish: String(""), + Name: String(""), + Body: String(""), + Draft: Bool(false), + Prerelease: Bool(false), + ID: Int64(0), + CreatedAt: &Timestamp{}, + PublishedAt: &Timestamp{}, + URL: String(""), + HTMLURL: String(""), + AssetsURL: String(""), + UploadURL: String(""), + ZipballURL: String(""), + TarballURL: String(""), + Author: &User{}, + NodeID: String(""), + } + want := `github.RepositoryRelease{TagName:"", TargetCommitish:"", Name:"", Body:"", Draft:false, Prerelease:false, ID:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, PublishedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, URL:"", HTMLURL:"", AssetsURL:"", UploadURL:"", ZipballURL:"", TarballURL:"", Author:github.User{}, NodeID:""}` + if got := v.String(); got != want { + t.Errorf("RepositoryRelease.String = %v, want %v", got, want) + } +} + +func TestSourceImportAuthor_String(t *testing.T) { + v := SourceImportAuthor{ + ID: Int64(0), + RemoteID: String(""), + RemoteName: String(""), + Email: String(""), + Name: String(""), + URL: String(""), + ImportURL: String(""), + } + want := `github.SourceImportAuthor{ID:0, RemoteID:"", RemoteName:"", Email:"", Name:"", URL:"", ImportURL:""}` + if got := v.String(); got != want { + t.Errorf("SourceImportAuthor.String = %v, want %v", got, want) + } +} + +func TestTeam_String(t *testing.T) { + v := Team{ + ID: Int64(0), + NodeID: String(""), + Name: String(""), + Description: String(""), + URL: String(""), + Slug: String(""), + Permission: String(""), + Privacy: String(""), + MembersCount: Int(0), + ReposCount: Int(0), + Organization: &Organization{}, + MembersURL: String(""), + RepositoriesURL: String(""), + Parent: &Team{}, + LDAPDN: String(""), + } + want := `github.Team{ID:0, NodeID:"", Name:"", Description:"", URL:"", Slug:"", Permission:"", Privacy:"", MembersCount:0, ReposCount:0, Organization:github.Organization{}, MembersURL:"", RepositoriesURL:"", Parent:github.Team{}, LDAPDN:""}` + if got := v.String(); got != want { + t.Errorf("Team.String = %v, want %v", got, want) + } +} + +func TestTeamDiscussion_String(t *testing.T) { + v := TeamDiscussion{ + Author: &User{}, + Body: String(""), + BodyHTML: String(""), + BodyVersion: String(""), + CommentsCount: Int(0), + CommentsURL: String(""), + CreatedAt: &Timestamp{}, + LastEditedAt: &Timestamp{}, + HTMLURL: String(""), + NodeID: String(""), + Number: Int(0), + Pinned: Bool(false), + Private: Bool(false), + TeamURL: String(""), + Title: String(""), + UpdatedAt: &Timestamp{}, + URL: String(""), + Reactions: &Reactions{}, + } + want := `github.TeamDiscussion{Author:github.User{}, Body:"", BodyHTML:"", BodyVersion:"", CommentsCount:0, CommentsURL:"", CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, LastEditedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, HTMLURL:"", NodeID:"", Number:0, Pinned:false, Private:false, TeamURL:"", Title:"", UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, URL:"", Reactions:github.Reactions{}}` + if got := v.String(); got != want { + t.Errorf("TeamDiscussion.String = %v, want %v", got, want) + } +} + +func TestTeamLDAPMapping_String(t *testing.T) { + v := TeamLDAPMapping{ + ID: Int64(0), + LDAPDN: String(""), + URL: String(""), + Name: String(""), + Slug: String(""), + Description: String(""), + Privacy: String(""), + Permission: String(""), + MembersURL: String(""), + RepositoriesURL: String(""), + } + want := `github.TeamLDAPMapping{ID:0, LDAPDN:"", URL:"", Name:"", Slug:"", Description:"", Privacy:"", Permission:"", MembersURL:"", RepositoriesURL:""}` + if got := v.String(); got != want { + t.Errorf("TeamLDAPMapping.String = %v, want %v", got, want) + } +} + +func TestTextMatch_String(t *testing.T) { + v := TextMatch{ + ObjectURL: String(""), + ObjectType: String(""), + Property: String(""), + Fragment: String(""), + } + want := `github.TextMatch{ObjectURL:"", ObjectType:"", Property:"", Fragment:""}` + if got := v.String(); got != want { + t.Errorf("TextMatch.String = %v, want %v", got, want) + } +} + +func TestTree_String(t *testing.T) { + v := Tree{ + SHA: String(""), + Truncated: Bool(false), + } + want := `github.Tree{SHA:"", Truncated:false}` + if got := v.String(); got != want { + t.Errorf("Tree.String = %v, want %v", got, want) + } +} + +func TestTreeEntry_String(t *testing.T) { + v := TreeEntry{ + SHA: String(""), + Path: String(""), + Mode: String(""), + Type: String(""), + Size: Int(0), + Content: String(""), + URL: String(""), + } + want := `github.TreeEntry{SHA:"", Path:"", Mode:"", Type:"", Size:0, Content:"", URL:""}` + if got := v.String(); got != want { + t.Errorf("TreeEntry.String = %v, want %v", got, want) + } +} + +func TestUser_String(t *testing.T) { + v := User{ + Login: String(""), + ID: Int64(0), + NodeID: String(""), + AvatarURL: String(""), + HTMLURL: String(""), + GravatarID: String(""), + Name: String(""), + Company: String(""), + Blog: String(""), + Location: String(""), + Email: String(""), + Hireable: Bool(false), + Bio: String(""), + PublicRepos: Int(0), + PublicGists: Int(0), + Followers: Int(0), + Following: Int(0), + CreatedAt: &Timestamp{}, + UpdatedAt: &Timestamp{}, + SuspendedAt: &Timestamp{}, + Type: String(""), + SiteAdmin: Bool(false), + TotalPrivateRepos: Int(0), + OwnedPrivateRepos: Int(0), + PrivateGists: Int(0), + DiskUsage: Int(0), + Collaborators: Int(0), + TwoFactorAuthentication: Bool(false), + Plan: &Plan{}, + URL: String(""), + EventsURL: String(""), + FollowingURL: String(""), + FollowersURL: String(""), + GistsURL: String(""), + OrganizationsURL: String(""), + ReceivedEventsURL: String(""), + ReposURL: String(""), + StarredURL: String(""), + SubscriptionsURL: String(""), + } + want := `github.User{Login:"", ID:0, NodeID:"", AvatarURL:"", HTMLURL:"", GravatarID:"", Name:"", Company:"", Blog:"", Location:"", Email:"", Hireable:false, Bio:"", PublicRepos:0, PublicGists:0, Followers:0, Following:0, CreatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, UpdatedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, SuspendedAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Type:"", SiteAdmin:false, TotalPrivateRepos:0, OwnedPrivateRepos:0, PrivateGists:0, DiskUsage:0, Collaborators:0, TwoFactorAuthentication:false, Plan:github.Plan{}, URL:"", EventsURL:"", FollowingURL:"", FollowersURL:"", GistsURL:"", OrganizationsURL:"", ReceivedEventsURL:"", ReposURL:"", StarredURL:"", SubscriptionsURL:""}` + if got := v.String(); got != want { + t.Errorf("User.String = %v, want %v", got, want) + } +} + +func TestUserLDAPMapping_String(t *testing.T) { + v := UserLDAPMapping{ + ID: Int64(0), + LDAPDN: String(""), + Login: String(""), + AvatarURL: String(""), + GravatarID: String(""), + Type: String(""), + SiteAdmin: Bool(false), + URL: String(""), + EventsURL: String(""), + FollowingURL: String(""), + FollowersURL: String(""), + GistsURL: String(""), + OrganizationsURL: String(""), + ReceivedEventsURL: String(""), + ReposURL: String(""), + StarredURL: String(""), + SubscriptionsURL: String(""), + } + want := `github.UserLDAPMapping{ID:0, LDAPDN:"", Login:"", AvatarURL:"", GravatarID:"", Type:"", SiteAdmin:false, URL:"", EventsURL:"", FollowingURL:"", FollowersURL:"", GistsURL:"", OrganizationsURL:"", ReceivedEventsURL:"", ReposURL:"", StarredURL:"", SubscriptionsURL:""}` + if got := v.String(); got != want { + t.Errorf("UserLDAPMapping.String = %v, want %v", got, want) + } +} + +func TestUserMigration_String(t *testing.T) { + v := UserMigration{ + ID: Int64(0), + GUID: String(""), + State: String(""), + LockRepositories: Bool(false), + ExcludeAttachments: Bool(false), + URL: String(""), + CreatedAt: String(""), + UpdatedAt: String(""), + } + want := `github.UserMigration{ID:0, GUID:"", State:"", LockRepositories:false, ExcludeAttachments:false, URL:"", CreatedAt:"", UpdatedAt:""}` + if got := v.String(); got != want { + t.Errorf("UserMigration.String = %v, want %v", got, want) + } +} + +func TestUserStats_String(t *testing.T) { + v := UserStats{ + TotalUsers: Int(0), + AdminUsers: Int(0), + SuspendedUsers: Int(0), + } + want := `github.UserStats{TotalUsers:0, AdminUsers:0, SuspendedUsers:0}` + if got := v.String(); got != want { + t.Errorf("UserStats.String = %v, want %v", got, want) + } +} + +func TestWebHookAuthor_String(t *testing.T) { + v := WebHookAuthor{ + Email: String(""), + Name: String(""), + Username: String(""), + } + want := `github.WebHookAuthor{Email:"", Name:"", Username:""}` + if got := v.String(); got != want { + t.Errorf("WebHookAuthor.String = %v, want %v", got, want) + } +} + +func TestWebHookCommit_String(t *testing.T) { + v := WebHookCommit{ + Author: &WebHookAuthor{}, + Committer: &WebHookAuthor{}, + Distinct: Bool(false), + ID: String(""), + Message: String(""), + } + want := `github.WebHookCommit{Author:github.WebHookAuthor{}, Committer:github.WebHookAuthor{}, Distinct:false, ID:"", Message:""}` + if got := v.String(); got != want { + t.Errorf("WebHookCommit.String = %v, want %v", got, want) + } +} + +func TestWebHookPayload_String(t *testing.T) { + v := WebHookPayload{ + After: String(""), + Before: String(""), + Compare: String(""), + Created: Bool(false), + Deleted: Bool(false), + Forced: Bool(false), + HeadCommit: &WebHookCommit{}, + Pusher: &User{}, + Ref: String(""), + Repo: &Repository{}, + Sender: &User{}, + } + want := `github.WebHookPayload{After:"", Before:"", Compare:"", Created:false, Deleted:false, Forced:false, HeadCommit:github.WebHookCommit{}, Pusher:github.User{}, Ref:"", Repo:github.Repository{}, Sender:github.User{}}` + if got := v.String(); got != want { + t.Errorf("WebHookPayload.String = %v, want %v", got, want) + } +} + +func TestWeeklyCommitActivity_String(t *testing.T) { + v := WeeklyCommitActivity{ + Total: Int(0), + Week: &Timestamp{}, + } + want := `github.WeeklyCommitActivity{Total:0, Week:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}` + if got := v.String(); got != want { + t.Errorf("WeeklyCommitActivity.String = %v, want %v", got, want) + } +} + +func TestWeeklyStats_String(t *testing.T) { + v := WeeklyStats{ + Week: &Timestamp{}, + Additions: Int(0), + Deletions: Int(0), + Commits: Int(0), + } + want := `github.WeeklyStats{Week:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Additions:0, Deletions:0, Commits:0}` + if got := v.String(); got != want { + t.Errorf("WeeklyStats.String = %v, want %v", got, want) + } +} diff --git a/github/github.go b/github/github.go index 45a72d7acbe..b1323f9e767 100644 --- a/github/github.go +++ b/github/github.go @@ -4,6 +4,7 @@ // license that can be found in the LICENSE file. //go:generate go run gen-accessors.go +//go:generate go run gen-stringify-test.go package github diff --git a/github/github_test.go b/github/github_test.go index 47f009cf50a..8dd75e4d7e6 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -221,6 +221,17 @@ func TestClient_rateLimits(t *testing.T) { } } +func TestRateLimits_String(t *testing.T) { + v := RateLimits{ + Core: &Rate{}, + Search: &Rate{}, + } + want := `github.RateLimits{Core:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}, Search:github.Rate{Limit:0, Remaining:0, Reset:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}}}` + if got := v.String(); got != want { + t.Errorf("RateLimits.String = %v, want %v", got, want) + } +} + func TestNewRequest(t *testing.T) { c := NewClient(nil) From 36ea4183d548afa056a2f8ce4b8117bd7e00d71d Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Thu, 20 Jun 2019 21:41:22 -0400 Subject: [PATCH 2/2] Move sourceTmpl after funcMap --- github/gen-stringify-test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/gen-stringify-test.go b/github/gen-stringify-test.go index 1315d4d0a9c..7803801e632 100644 --- a/github/gen-stringify-test.go +++ b/github/gen-stringify-test.go @@ -39,8 +39,6 @@ const ( var ( verbose = flag.Bool("v", false, "Print verbose log messages") - sourceTmpl = template.Must(template.New("source").Funcs(funcMap).Parse(source)) - // blacklistStructMethod lists "struct.method" combos to skip. blacklistStructMethod = map[string]bool{} // blacklistStruct lists structs to skip. @@ -74,6 +72,8 @@ var ( return "" }, } + + sourceTmpl = template.Must(template.New("source").Funcs(funcMap).Parse(source)) ) func main() { @@ -89,7 +89,7 @@ func main() { for pkgName, pkg := range pkgs { t := &templateData{ filename: pkgName + outputFileSuffix, - Year: 2019, + Year: 2019, // No need to change this once set (even in following years). Package: pkgName, Imports: map[string]string{"testing": "testing"}, StringFuncs: map[string]bool{},