Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 37 additions & 35 deletions github/actions_artifacts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,22 +454,22 @@ func TestArtifact_Marshal(t *testing.T) {
}

want := `{
"id": 1,
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"url": "u",
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"updated_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `,
"workflow_run": {
"id": 1,
"repository_id": 1,
"head_repository_id": 1,
"head_branch": "b",
"head_sha": "s"
"id":1,
"node_id":"nid",
"name":"n",
"size_in_bytes":1,
"url":"u",
"archive_download_url":"a",
"expired":false,
"created_at":` + referenceTimeStr + `,
"updated_at":` + referenceTimeStr + `,
"expires_at":` + referenceTimeStr + `,
"workflow_run":{
"id":1,
"repository_id":1,
"head_repository_id":1,
"head_branch":"b",
"head_sha":"s"
}
}`

Expand Down Expand Up @@ -505,26 +505,28 @@ func TestArtifactList_Marshal(t *testing.T) {
}

want := `{
"total_count": 1,
"artifacts": [{
"id": 1,
"node_id": "nid",
"name": "n",
"size_in_bytes": 1,
"url": "u",
"archive_download_url": "a",
"expired": false,
"created_at": ` + referenceTimeStr + `,
"updated_at": ` + referenceTimeStr + `,
"expires_at": ` + referenceTimeStr + `,
"workflow_run": {
"id": 1,
"repository_id": 1,
"head_repository_id": 1,
"head_branch": "b",
"head_sha": "s"
"total_count":1,
"artifacts":[
{
"id":1,
"node_id":"nid",
"name":"n",
"size_in_bytes":1,
"url":"u",
"archive_download_url":"a",
"expired":false,
"created_at":` + referenceTimeStr + `,
"updated_at":` + referenceTimeStr + `,
"expires_at":` + referenceTimeStr + `,
"workflow_run":{
"id":1,
"repository_id":1,
"head_repository_id":1,
"head_branch":"b",
"head_sha":"s"
}
}
}]
]
}`

testJSONMarshal(t, u, want)
Expand Down
81 changes: 45 additions & 36 deletions github/actions_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,20 +530,20 @@ func TestActionsCache_Marshal(t *testing.T) {
}

want := `{
"id": 1,
"ref": "refAction",
"key": "key1",
"version": "alpha",
"last_accessed_at": ` + referenceTimeStr + `,
"created_at": ` + referenceTimeStr + `,
"size_in_bytes": 1
"id":1,
"ref":"refAction",
"key":"key1",
"version":"alpha",
"last_accessed_at":` + referenceTimeStr + `,
"created_at":` + referenceTimeStr + `,
"size_in_bytes":1
}`

testJSONMarshal(t, u, want)
}

func TestActionsCacheList_Marshal(t *testing.T) {
testJSONMarshal(t, &ActionsCacheList{}, "{}")
testJSONMarshal(t, &ActionsCacheList{}, `{"total_count":0}`)

u := &ActionsCacheList{
TotalCount: 2,
Expand All @@ -566,46 +566,51 @@ func TestActionsCacheList_Marshal(t *testing.T) {
},
}
want := `{
"total_count": 2,
"actions_caches": [{
"id": 1,
"key": "key1",
"version": "alpha",
"last_accessed_at": ` + referenceTimeStr + `,
"created_at": ` + referenceTimeStr + `,
"size_in_bytes": 1
"total_count":2,
"actions_caches":[{
"id":1,
"key":"key1",
"version":"alpha",
"last_accessed_at":` + referenceTimeStr + `,
"created_at":` + referenceTimeStr + `,
"size_in_bytes":1
},
{
"id": 2,
"ref": "refAction",
"last_accessed_at": ` + referenceTimeStr + `,
"created_at": ` + referenceTimeStr + `,
"size_in_bytes": 1
"id":2,
"ref":"refAction",
"last_accessed_at":` + referenceTimeStr + `,
"created_at":` + referenceTimeStr + `,
"size_in_bytes":1
}]
}`
testJSONMarshal(t, u, want)
}

func TestActionsCacheUsage_Marshal(t *testing.T) {
testJSONMarshal(t, &ActionsCacheUsage{}, "{}")
want := `{
"full_name":"",
"active_caches_size_in_bytes":0,
"active_caches_count":0
}`
testJSONMarshal(t, &ActionsCacheUsage{}, want)

u := &ActionsCacheUsage{
FullName: "cache_usage1",
ActiveCachesSizeInBytes: 2,
ActiveCachesCount: 2,
}

want := `{
"full_name": "cache_usage1",
"active_caches_size_in_bytes": 2,
"active_caches_count": 2
want = `{
"full_name":"cache_usage1",
"active_caches_size_in_bytes":2,
"active_caches_count":2
}`

testJSONMarshal(t, u, want)
}

func TestActionsCacheUsageList_Marshal(t *testing.T) {
testJSONMarshal(t, &ActionsCacheUsageList{}, "{}")
testJSONMarshal(t, &ActionsCacheUsageList{}, `{"total_count":0}`)

u := &ActionsCacheUsageList{
TotalCount: 1,
Expand All @@ -619,28 +624,32 @@ func TestActionsCacheUsageList_Marshal(t *testing.T) {
}

want := `{
"total_count": 1,
"repository_cache_usages": [{
"full_name": "cache_usage1",
"active_caches_size_in_bytes": 2,
"active_caches_count": 2
"total_count":1,
"repository_cache_usages":[{
"full_name":"cache_usage1",
"active_caches_size_in_bytes":2,
"active_caches_count":2
}]
}`

testJSONMarshal(t, u, want)
}

func TestTotalCacheUsage_Marshal(t *testing.T) {
testJSONMarshal(t, &TotalCacheUsage{}, "{}")
want := `{
"total_active_caches_size_in_bytes":0,
"total_active_caches_count":0
}`
testJSONMarshal(t, &TotalCacheUsage{}, want)

u := &TotalCacheUsage{
TotalActiveCachesUsageSizeInBytes: 2,
TotalActiveCachesCount: 2,
}

want := `{
"total_active_caches_size_in_bytes": 2,
"total_active_caches_count": 2
want = `{
"total_active_caches_size_in_bytes":2,
"total_active_caches_count":2
}`

testJSONMarshal(t, u, want)
Expand Down
4 changes: 2 additions & 2 deletions github/actions_oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ func TestOIDCSubjectClaimCustomTemplate_Marshal(t *testing.T) {
}

want := `{
"use_default": false,
"include_claim_keys": [
"use_default":false,
"include_claim_keys":[
"s"
]
}`
Expand Down
12 changes: 6 additions & 6 deletions github/actions_permissions_orgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ func TestActionsAllowed_Marshal(t *testing.T) {
}

want := `{
"github_owned_allowed": false,
"verified_allowed": false,
"patterns_allowed": [
"github_owned_allowed":false,
"verified_allowed":false,
"patterns_allowed":[
"s"
]
}`
Expand All @@ -327,9 +327,9 @@ func TestActionsPermissions_Marshal(t *testing.T) {
}

want := `{
"enabled_repositories": "e",
"allowed_actions": "a",
"selected_actions_url": "sau"
"enabled_repositories":"e",
"allowed_actions":"a",
"selected_actions_url":"sau"
}`

testJSONMarshal(t, u, want)
Expand Down
Loading