GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

main.TestFillCSVData   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nop 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
1
// Copyright 2018 Fedir RYKHTIK. All rights reserved.
2
// Use of this source code is governed by the GNU GPL 3.0
3
// license that can be found in the LICENSE file.
4
5
package main
6
7
import (
8
	"fmt"
9
	"reflect"
10
	"testing"
11
	"time"
12
13
	"github.com/fedir/ghstat/github"
14
)
15
16
var jsonResponse = `
17
{
18
  "id": 3577919,
19
  "name": "beego",
20
  "full_name": "astaxie/beego",
21
  "owner": {
22
	"login": "astaxie",
23
	"id": 233907,
24
	"avatar_url": "https://avatars3.githubusercontent.com/u/233907?v=4",
25
	"gravatar_id": "",
26
	"url": "https://api.github.com/users/astaxie",
27
	"html_url": "https://github.com/astaxie",
28
	"followers_url": "https://api.github.com/users/astaxie/followers",
29
	"following_url": "https://api.github.com/users/astaxie/following{/other_user}",
30
	"gists_url": "https://api.github.com/users/astaxie/gists{/gist_id}",
31
	"starred_url": "https://api.github.com/users/astaxie/starred{/owner}{/repo}",
32
	"subscriptions_url": "https://api.github.com/users/astaxie/subscriptions",
33
	"organizations_url": "https://api.github.com/users/astaxie/orgs",
34
	"repos_url": "https://api.github.com/users/astaxie/repos",
35
	"events_url": "https://api.github.com/users/astaxie/events{/privacy}",
36
	"received_events_url": "https://api.github.com/users/astaxie/received_events",
37
	"type": "User",
38
	"site_admin": false
39
  },
40
  "private": false,
41
  "html_url": "https://github.com/astaxie/beego",
42
  "description": "beego is an open-source, high-performance web framework for the Go programming language.",
43
  "fork": false,
44
  "url": "https://api.github.com/repos/astaxie/beego",
45
  "forks_url": "https://api.github.com/repos/astaxie/beego/forks",
46
  "keys_url": "https://api.github.com/repos/astaxie/beego/keys{/key_id}",
47
  "collaborators_url": "https://api.github.com/repos/astaxie/beego/collaborators{/collaborator}",
48
  "teams_url": "https://api.github.com/repos/astaxie/beego/teams",
49
  "hooks_url": "https://api.github.com/repos/astaxie/beego/hooks",
50
  "issue_events_url": "https://api.github.com/repos/astaxie/beego/issues/events{/number}",
51
  "events_url": "https://api.github.com/repos/astaxie/beego/events",
52
  "assignees_url": "https://api.github.com/repos/astaxie/beego/assignees{/user}",
53
  "branches_url": "https://api.github.com/repos/astaxie/beego/branches{/branch}",
54
  "tags_url": "https://api.github.com/repos/astaxie/beego/tags",
55
  "blobs_url": "https://api.github.com/repos/astaxie/beego/git/blobs{/sha}",
56
  "git_tags_url": "https://api.github.com/repos/astaxie/beego/git/tags{/sha}",
57
  "git_refs_url": "https://api.github.com/repos/astaxie/beego/git/refs{/sha}",
58
  "trees_url": "https://api.github.com/repos/astaxie/beego/git/trees{/sha}",
59
  "statuses_url": "https://api.github.com/repos/astaxie/beego/statuses/{sha}",
60
  "languages_url": "https://api.github.com/repos/astaxie/beego/languages",
61
  "stargazers_url": "https://api.github.com/repos/astaxie/beego/stargazers",
62
  "contributors_url": "https://api.github.com/repos/astaxie/beego/contributors",
63
  "subscribers_url": "https://api.github.com/repos/astaxie/beego/subscribers",
64
  "subscription_url": "https://api.github.com/repos/astaxie/beego/subscription",
65
  "commits_url": "https://api.github.com/repos/astaxie/beego/commits{/sha}",
66
  "git_commits_url": "https://api.github.com/repos/astaxie/beego/git/commits{/sha}",
67
  "comments_url": "https://api.github.com/repos/astaxie/beego/comments{/number}",
68
  "issue_comment_url": "https://api.github.com/repos/astaxie/beego/issues/comments{/number}",
69
  "contents_url": "https://api.github.com/repos/astaxie/beego/contents/{+path}",
70
  "compare_url": "https://api.github.com/repos/astaxie/beego/compare/{base}...{head}",
71
  "merges_url": "https://api.github.com/repos/astaxie/beego/merges",
72
  "archive_url": "https://api.github.com/repos/astaxie/beego/{archive_format}{/ref}",
73
  "downloads_url": "https://api.github.com/repos/astaxie/beego/downloads",
74
  "issues_url": "https://api.github.com/repos/astaxie/beego/issues{/number}",
75
  "pulls_url": "https://api.github.com/repos/astaxie/beego/pulls{/number}",
76
  "milestones_url": "https://api.github.com/repos/astaxie/beego/milestones{/number}",
77
  "notifications_url": "https://api.github.com/repos/astaxie/beego/notifications{?since,all,participating}",
78
  "labels_url": "https://api.github.com/repos/astaxie/beego/labels{/name}",
79
  "releases_url": "https://api.github.com/repos/astaxie/beego/releases{/id}",
80
  "deployments_url": "https://api.github.com/repos/astaxie/beego/deployments",
81
  "created_at": "2012-02-29T02:32:08Z",
82
  "updated_at": "2018-03-10T14:56:13Z",
83
  "pushed_at": "2018-03-10T09:17:53Z",
84
  "git_url": "git://github.com/astaxie/beego.git",
85
  "ssh_url": "[email protected]:astaxie/beego.git",
86
  "clone_url": "https://github.com/astaxie/beego.git",
87
  "svn_url": "https://github.com/astaxie/beego",
88
  "homepage": "beego.me",
89
  "size": 4396,
90
  "stargazers_count": 14391,
91
  "watchers_count": 14391,
92
  "language": "Go",
93
  "has_issues": true,
94
  "has_projects": true,
95
  "has_downloads": true,
96
  "has_wiki": true,
97
  "has_pages": false,
98
  "forks_count": 3166,
99
  "mirror_url": null,
100
  "archived": false,
101
  "open_issues_count": 448,
102
  "license": {
103
	"key": "other",
104
	"name": "Other",
105
	"spdx_id": null,
106
	"url": null
107
  },
108
  "forks": 3166,
109
  "open_issues": 448,
110
  "watchers": 14391,
111
  "default_branch": "master",
112
  "network_count": 3166,
113
  "subscribers_count": 1042
114
}
115
`
116
117
func TestParseRepositoryData(t *testing.T) {
118
	repositoryDataExtracted := github.ParseRepositoryData([]byte(jsonResponse))
119
	repositoryDataExpected := &github.Repository{
120
		Name:        "beego",
121
		FullName:    "astaxie/beego",
122
		Watchers:    14391,
123
		Forks:       3166,
124
		OpenIssues:  448,
125
		Language:    "Go",
126
		CreatedAt:   time.Date(2012, 2, 29, 2, 32, 8, 0, time.UTC),
127
		HasIssues:   true,
128
		Description: "beego is an open-source, high-performance web framework for the Go programming language.",
129
	}
130
	if !reflect.DeepEqual(repositoryDataExtracted, repositoryDataExpected) {
131
		fmt.Printf("%v", repositoryDataExtracted)
132
		fmt.Printf("%v", repositoryDataExpected)
133
		t.Fail()
134
	}
135
}
136
137
func TestParseRepositoryDataNegative(t *testing.T) {
138
	repositoryDataExtracted := github.ParseRepositoryData([]byte(jsonResponse))
139
	repositoryDataExpected := &github.Repository{
140
		Name:        "beego",
141
		FullName:    "astaxie/beego",
142
		Watchers:    14391,
143
		Forks:       3167,
144
		OpenIssues:  448,
145
		Language:    "Go",
146
		CreatedAt:   time.Date(2012, 2, 29, 2, 32, 8, 0, time.UTC),
147
		HasIssues:   true,
148
		Description: "beego is an open-source, high-performance web framework for the Go programming language.",
149
	}
150
	if reflect.DeepEqual(repositoryDataExtracted, repositoryDataExpected) {
151
		fmt.Printf("%v", repositoryDataExtracted)
152
		fmt.Printf("%v", repositoryDataExpected)
153
		t.Fail()
154
	}
155
}
156
157
func TestMainProgram(t *testing.T) {
158
	main()
159
}
160
161
// TODO
162
func TestFillCSVData(t *testing.T) {
163
}
164