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.

github.TestContributionStatisticsJSONResponseData   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 14
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nop 1
dl 0
loc 14
rs 9.75
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 github
6
7
import (
8
	"fmt"
9
	"reflect"
10
	"testing"
11
)
12
13
var contributionStatisticsJSONResponse = `
14
[
15
  {
16
    "total": 5,
17
    "weeks": [
18
      {
19
        "w": 1520121600,
20
        "a": 100,
21
        "d": 5,
22
        "c": 4
23
      },
24
      {
25
        "w": 1520726400,
26
        "a": 10,
27
        "d": 5,
28
        "c": 1
29
      },
30
      {
31
        "w": 1521331200,
32
        "a": 0,
33
        "d": 0,
34
        "c": 0
35
      }
36
    ],
37
    "author": {
38
      "login": "fedir",
39
      "id": 306586,
40
      "avatar_url": "https://avatars1.githubusercontent.com/u/306586?v=4",
41
      "gravatar_id": "",
42
      "url": "https://api.github.com/users/fedir",
43
      "html_url": "https://github.com/fedir",
44
      "followers_url": "https://api.github.com/users/fedir/followers",
45
      "following_url": "https://api.github.com/users/fedir/following{/other_user}",
46
      "gists_url": "https://api.github.com/users/fedir/gists{/gist_id}",
47
      "starred_url": "https://api.github.com/users/fedir/starred{/owner}{/repo}",
48
      "subscriptions_url": "https://api.github.com/users/fedir/subscriptions",
49
      "organizations_url": "https://api.github.com/users/fedir/orgs",
50
      "repos_url": "https://api.github.com/users/fedir/repos",
51
      "events_url": "https://api.github.com/users/fedir/events{/privacy}",
52
      "received_events_url": "https://api.github.com/users/fedir/received_events",
53
      "type": "User",
54
      "site_admin": false
55
    }
56
  }
57
]
58
`
59
60
func TestContributionStatisticsJSONResponseData(t *testing.T) {
61
	contributionStatistics := extractContributionStatisticsFromJSON([]byte(contributionStatisticsJSONResponse), false)
62
	contributionStatisticsExpected := ContributionStatistics{
63
		TotalCommits:              5,
64
		TotalAdditions:            110,
65
		TotalDeletions:            10,
66
		TotalCodeChanges:          120,
67
		MediumCommitSize:          24,
68
		AverageContributionPeriod: 7,
69
	}
70
	if !reflect.DeepEqual(contributionStatistics, contributionStatisticsExpected) {
71
		fmt.Println(contributionStatistics)
72
		fmt.Println(contributionStatisticsExpected)
73
		t.Fail()
74
	}
75
}
76