Skip to content

Add test cases for JSON resource marshaling #1916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 61 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b4bfc18
editChange event: define struct types instead of using anonymous structs
Jun 18, 2021
2256293
Apply suggestions from code review
Jun 18, 2021
4f7ea12
projectChange: define struct types instead of using anonymous structs
Jun 18, 2021
6d82637
projectCardChange: define struct types instead of using anon. structs
Jun 18, 2021
99c9b84
projectColumnChange: define struct types instead of using anon. structs
Jun 18, 2021
f3a60ad
teamChange: define struct types instead of using anonymous structs
Jun 18, 2021
82f2305
VulnerabilityAlert: define struct types instead of using anon. structs
Jun 18, 2021
11286df
Resource Tested for JSON marshalling : FeedLink
sagar23sj Jun 24, 2021
1255d90
Resource Tested for JSON marshalling : Feeds
sagar23sj Jun 24, 2021
05e95d3
Bump version of go-github library (#1921)
gmlewis Jun 26, 2021
19e2a7b
feeds: define struct types instead of using anonymous structs
Jul 8, 2021
30283c9
errorResponse: define struct types instead of using anonymous structs
Jul 8, 2021
56aff56
fixup! teamChange: define struct types instead of using anonymous str…
Jul 8, 2021
684b1c9
updateurls: use consistent method receiver name for Endpoint struct
Jul 8, 2021
81b5de3
Parse 'reviewed' event object 'state' property (#1886)
Jul 8, 2021
a0bec87
Add auto_merge field in PullRequest struct (#1896)
slayer321 Jul 8, 2021
c26abbd
Add missing fields to Repository Vulnerability Alert (#1898)
OhZedTee Jul 8, 2021
050b379
Add test cases for JSON resource marshalling (#1910)
sagar23sj Jun 24, 2021
def222d
Adds test cases for JSON resource marshalling (#1911)
sagar23sj Jun 24, 2021
5a4a6b4
Bump version of go-github library (#1921)
gmlewis Jun 26, 2021
ebfdd03
Parse 'reviewed' event object 'state' property (#1886)
Jul 8, 2021
93fcacd
Add auto_merge field in PullRequest struct (#1896)
slayer321 Jul 8, 2021
9036cc0
Add missing fields to Repository Vulnerability Alert (#1898)
OhZedTee Jul 8, 2021
c2ddceb
Merge #1900
gmlewis Jul 8, 2021
72cc2f6
Add deprecated field comments to Repository Object (#1952)
OhZedTee Jul 8, 2021
c9fec82
Modify GetBranch to handle redirects (#1901)
n1lesh Jul 8, 2021
5067660
Add test cases for JSON resource marshaling (#1902)
sagar23sj Jul 8, 2021
2e47bff
Fix tests for merge of #1902 (#1954)
gmlewis Jul 8, 2021
55353a5
Fix Code Scanning Alert tool field (#1904)
ganeshkumarsv Jul 8, 2021
9bd4751
Add test cases for JSON resources marshaling (#1906)
sagar23sj Jul 8, 2021
cfcb8e1
Enable `Client.RateLimits` to bypass the rate limit check (#1907)
sa-spag Jul 8, 2021
4a83d0e
Add test cases for JSON resource marshaling (#1908)
sagar23sj Jul 8, 2021
d15bdce
Add test cases for JSON resource marshaling (#1909)
sagar23sj Jul 8, 2021
589c054
Add test cases for JSON resource marshaling (#1912)
sagar23sj Jul 8, 2021
d2ec695
Add test cases for JSON resource marshaling (#1913)
sagar23sj Jul 8, 2021
d4a5105
Add test cases for JSON resource marshaling (#1914)
sagar23sj Jul 8, 2021
c081d6c
Add test cases for JSON resource marshaling (#1915)
sagar23sj Jul 8, 2021
3e1f0a4
Add test cases for JSON resource marshaling (#1917)
sagar23sj Jul 8, 2021
caaa4c9
Add test cases for JSON resource marshaling (#1918)
sagar23sj Jul 8, 2021
b11061d
Add test cases for JSON resource marshaling (#1919)
sagar23sj Jul 8, 2021
b60bde1
Handle MIME parameters in Content-Type Header (#1922)
sagar23sj Jul 8, 2021
5d22159
Add test cases for JSON resource marshaling (#1923)
sagar23sj Jul 8, 2021
670f4d7
Add test cases for JSON resource marshaling (#1924)
sagar23sj Jul 8, 2021
c2dfd88
Add test cases for JSON resource marshaling (#1925)
sagar23sj Jul 8, 2021
78dce32
Add test cases for JSON resource marshaling (#1926)
sagar23sj Jul 8, 2021
82d8bd2
Add test cases for JSON resource marshaling (#1927)
sagar23sj Jul 8, 2021
908fe35
Add test cases for JSON resource marshaling (#1928)
sagar23sj Jul 8, 2021
0491dfa
Add test cases for JSON resource marshaling (#1929)
sagar23sj Jul 8, 2021
9973e43
Add test cases for JSON resource marshaling (#1930)
sagar23sj Jul 8, 2021
dbca249
Add test cases for JSON resource marshaling (#1937)
sagar23sj Jul 8, 2021
53b7d44
Add test cases for JSON resource marshaling (#1938)
sagar23sj Jul 8, 2021
55a9b44
Add test for JSON marshaling for Teams (#1941)
emiscode Jul 8, 2021
0f0b9a5
Fix test from #1938 and #1904 (#1956)
gmlewis Jul 8, 2021
be31e40
Added RequiredConversationResolution protection field (#1946)
g4s8 Jul 8, 2021
a7a3d8c
Add test cases for JSON resource marshaling (#1951)
sagar23sj Jul 8, 2021
b338ce6
Bump version of go-github library (#1957)
gmlewis Jul 9, 2021
7aec002
Resource Tested for JSON marshalling : FeedLink
sagar23sj Jun 24, 2021
3029263
Resource Tested for JSON marshalling : Feeds
sagar23sj Jun 24, 2021
4aad5f5
fixed failing test-case
sagar23sj Jul 8, 2021
87898a0
Resource Tested for JSON marshalling : FeedLinks
sagar23sj Jul 8, 2021
c50bff0
Merge branch 'test-cases/activity' of github.com:sagar23sj/go-github …
sagar23sj Jul 9, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# go-github #

[![go-github release (latest SemVer)](https://img.shields.io/github/v/release/google/go-github?sort=semver)](https://github.com/google/go-github/releases)
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v35/github)
[![GoDoc](https://img.shields.io/static/v1?label=godoc&message=reference&color=blue)](https://pkg.go.dev/github.com/google/go-github/v37/github)
[![Test Status](https://github.com/google/go-github/workflows/tests/badge.svg)](https://github.com/google/go-github/actions?query=workflow%3Atests)
[![Test Coverage](https://codecov.io/gh/google/go-github/branch/master/graph/badge.svg)](https://codecov.io/gh/google/go-github)
[![Discuss at go-github@googlegroups.com](https://img.shields.io/badge/discuss-go--github%40googlegroups.com-blue.svg)](https://groups.google.com/group/go-github)
Expand All @@ -24,29 +24,29 @@ If you're interested in using the [GraphQL API v4][], the recommended library is
go-github is compatible with modern Go releases in module mode, with Go installed:

```bash
go get github.com/google/go-github/v35
go get github.com/google/go-github/v37
```

will resolve and add the package to the current development module, along with its dependencies.

Alternatively the same can be achieved if you use import in a package:

```go
import "github.com/google/go-github/v35/github"
import "github.com/google/go-github/v37/github"
```

and run `go get` without parameters.

Finally, to use the top-of-trunk version of this repo, use the following command:

```bash
go get github.com/google/go-github/v35@master
go get github.com/google/go-github/v37@master
```

## Usage ##

```go
import "github.com/google/go-github/v35/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/google/go-github/v37/github" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/google/go-github/github" // with go modules disabled
```

Expand Down Expand Up @@ -246,7 +246,7 @@ For complete usage of go-github, see the full [package docs][].
[oauth2]: https://github.com/golang/oauth2
[oauth2 docs]: https://godoc.org/golang.org/x/oauth2
[personal API token]: https://github.com/blog/1509-personal-api-tokens
[package docs]: https://pkg.go.dev/github.com/google/go-github/v35/github
[package docs]: https://pkg.go.dev/github.com/google/go-github/v37/github
[GraphQL API v4]: https://developer.github.com/v4/
[shurcooL/githubv4]: https://github.com/shurcooL/githubv4

Expand Down
2 changes: 1 addition & 1 deletion example/appengine/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"net/http"
"os"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/oauth2"
"google.golang.org/appengine"
"google.golang.org/appengine/log"
Expand Down
2 changes: 1 addition & 1 deletion example/basicauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"syscall"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/crypto/ssh/terminal"
)

Expand Down
2 changes: 1 addition & 1 deletion example/commitpr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
"strings"
"time"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/migrations/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/newrepo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"log"
"os"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/newreposecret/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.15

require (
github.com/GoKillers/libsodium-go v0.0.0-20171022220152-dd733721c3cb
github.com/google/go-github/v35 v35.0.0
github.com/google/go-github/v37 v37.0.0
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
gopkg.in/yaml.v2 v2.3.0 // indirect
)
2 changes: 1 addition & 1 deletion example/newreposecret/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"os"

sodium "github.com/GoKillers/libsodium-go/cryptobox"
"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/oauth2"
)

Expand Down
2 changes: 1 addition & 1 deletion example/simple/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
)

// Fetch all the public organizations' membership of a user.
Expand Down
2 changes: 1 addition & 1 deletion example/tokenauth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"log"
"syscall"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/oauth2"
)
Expand Down
2 changes: 1 addition & 1 deletion example/topics/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"context"
"fmt"

"github.com/google/go-github/v35/github"
"github.com/google/go-github/v37/github"
)

// Fetch and lists all the public topics associated with the specified GitHub topic
Expand Down
74 changes: 74 additions & 0 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package github

import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -294,6 +295,15 @@ func TestActionsSerivice_DownloadArtifact(t *testing.T) {
_, _, err = client.Actions.DownloadArtifact(ctx, "\n", "\n", -1, true)
return err
})

// Add custom round tripper
client.client.Transport = roundTripperFunc(func(r *http.Request) (*http.Response, error) {
return nil, errors.New("failed to download artifact")
})
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.DownloadArtifact(ctx, "o", "r", 1, true)
return err
})
}

func TestActionsService_DownloadArtifact_invalidOwner(t *testing.T) {
Expand Down Expand Up @@ -419,3 +429,67 @@ func TestActionsService_DeleteArtifact_notFound(t *testing.T) {
t.Errorf("Actions.DeleteArtifact return status %d, want %d", got, want)
}
}

func TestArtifact_Marshal(t *testing.T) {
testJSONMarshal(t, &Artifact{}, "{}")

u := &Artifact{
ID: Int64(1),
NodeID: String("nid"),
Name: String("n"),
SizeInBytes: Int64(1),
ArchiveDownloadURL: String("a"),
Expired: Bool(false),
CreatedAt: &Timestamp{referenceTime},
ExpiresAt: &Timestamp{referenceTime},
}

want := `{
"id": 1,
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `
}`

testJSONMarshal(t, u, want)
}

func TestArtifactList_Marshal(t *testing.T) {
testJSONMarshal(t, &ArtifactList{}, "{}")

u := &ArtifactList{
TotalCount: Int64(1),
Artifacts: []*Artifact{
{
ID: Int64(1),
NodeID: String("nid"),
Name: String("n"),
SizeInBytes: Int64(1),
ArchiveDownloadURL: String("a"),
Expired: Bool(false),
CreatedAt: &Timestamp{referenceTime},
ExpiresAt: &Timestamp{referenceTime},
},
},
}

want := `{
"total_count": 1,
"artifacts": [{
"id": 1,
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `
}]
}`

testJSONMarshal(t, u, want)
}
128 changes: 128 additions & 0 deletions github/actions_runner_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,131 @@ func TestActionsService_RemoveRunnerGroupRunners(t *testing.T) {
return client.Actions.RemoveRunnerGroupRunners(ctx, "o", 2, 42)
})
}

func TestRunnerGroup_Marshal(t *testing.T) {
testJSONMarshal(t, &RunnerGroup{}, "{}")

u := &RunnerGroup{
ID: Int64(1),
Name: String("n"),
Visibility: String("v"),
Default: Bool(true),
SelectedRepositoriesURL: String("s"),
RunnersURL: String("r"),
Inherited: Bool(true),
AllowsPublicRepositories: Bool(true),
}

want := `{
"id": 1,
"name": "n",
"visibility": "v",
"default": true,
"selected_repositories_url": "s",
"runners_url": "r",
"inherited": true,
"allows_public_repositories": true
}`

testJSONMarshal(t, u, want)
}

func TestRunnerGroups_Marshal(t *testing.T) {
testJSONMarshal(t, &RunnerGroups{}, "{}")

u := &RunnerGroups{
TotalCount: int(1),
RunnerGroups: []*RunnerGroup{
{
ID: Int64(1),
Name: String("n"),
Visibility: String("v"),
Default: Bool(true),
SelectedRepositoriesURL: String("s"),
RunnersURL: String("r"),
Inherited: Bool(true),
AllowsPublicRepositories: Bool(true),
},
},
}

want := `{
"total_count": 1,
"runner_groups": [{
"id": 1,
"name": "n",
"visibility": "v",
"default": true,
"selected_repositories_url": "s",
"runners_url": "r",
"inherited": true,
"allows_public_repositories": true
}]
}`

testJSONMarshal(t, u, want)
}

func TestCreateRunnerGroupRequest_Marshal(t *testing.T) {
testJSONMarshal(t, &CreateRunnerGroupRequest{}, "{}")

u := &CreateRunnerGroupRequest{
Name: String("n"),
Visibility: String("v"),
SelectedRepositoryIDs: []int64{1},
Runners: []int64{1},
}

want := `{
"name": "n",
"visibility": "v",
"selected_repository_ids": [1],
"runners": [1]
}`

testJSONMarshal(t, u, want)
}

func TestUpdateRunnerGroupRequest_Marshal(t *testing.T) {
testJSONMarshal(t, &UpdateRunnerGroupRequest{}, "{}")

u := &UpdateRunnerGroupRequest{
Name: String("n"),
Visibility: String("v"),
}

want := `{
"name": "n",
"visibility": "v"
}`

testJSONMarshal(t, u, want)
}

func TestSetRepoAccessRunnerGroupRequest_Marshal(t *testing.T) {
testJSONMarshal(t, &SetRepoAccessRunnerGroupRequest{}, "{}")

u := &SetRepoAccessRunnerGroupRequest{
SelectedRepositoryIDs: []int64{1},
}

want := `{
"selected_repository_ids": [1]
}`

testJSONMarshal(t, u, want)
}

func TestSetRunnerGroupRunnersRequest_Marshal(t *testing.T) {
testJSONMarshal(t, &SetRunnerGroupRunnersRequest{}, "{}")

u := &SetRunnerGroupRunnersRequest{
Runners: []int64{1},
}

want := `{
"runners": [1]
}`

testJSONMarshal(t, u, want)
}
Loading