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.
Test Setup Failed
Pull Request — master (#1)
by Victor Hugo
01:16
created

devto.TestNewClient   C

Complexity

Conditions 8

Size

Total Lines 57
Code Lines 43

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
eloc 43
dl 0
loc 57
rs 6.9813
c 0
b 0
f 0
nop 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
package devto
2
3
import (
4
	"context"
5
	"net/http"
6
	"reflect"
7
	"testing"
8
)
9
10
func TestNewClient(t *testing.T) {
11
	type args struct {
12
		ctx    context.Context
13
		config *Config
14
		bc     httpClient
15
	}
16
17
	c, err := NewConfig(true, "dummy")
18
	if err != nil {
19
		t.Fatal(err)
20
	}
21
22
	tests := []struct {
23
		name    string
24
		want    Client
25
		wantErr bool
26
		err     error
27
		args    args
28
	}{
29
		{
30
			name: "client is build sucessfully",
31
			want: Client{
32
				Context:    context.Background(),
33
				HTTPClient: http.DefaultClient,
34
				Config:     c,
35
			},
36
			wantErr: false,
37
			err:     nil,
38
			args: args{
39
				ctx:    nil,
40
				config: c,
41
				bc:     nil,
42
			},
43
		},
44
		{
45
			name:    "client fails if config is nil",
46
			want:    Client{},
47
			wantErr: true,
48
			err:     ErrMissingConfig,
49
			args: args{
50
				ctx:    nil,
51
				config: nil,
52
				bc:     nil,
53
			},
54
		},
55
	}
56
57
	for _, tt := range tests {
58
		t.Run(tt.name, func(t *testing.T) {
59
			got, err := NewClient(tt.args.ctx, tt.args.config, tt.args.bc)
60
			if tt.wantErr && err != nil {
61
				if !reflect.DeepEqual(err, tt.err) {
62
					t.Errorf("failed on error expectation, got: %v | want %v", err, tt.err)
63
				}
64
			} else {
65
				if !reflect.DeepEqual(tt.want, *got) {
66
					t.Errorf("missmatched expectation, got: %v, want: %v", got, tt.want)
67
				}
68
			}
69
		})
70
	}
71
}
72