-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecupertoken_test.go
50 lines (46 loc) · 1.15 KB
/
recupertoken_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package easyapiclient_test
import (
"context"
"fmt"
"net/http"
"net/http/httptest"
"testing"
"easyapiclient"
)
func TestRecuperaToken(t *testing.T) {
type args struct {
ctx context.Context
username string
password string
}
tests := []struct {
name string
args args
wantToken string
wantScadenza int
wantErr bool
}{
// TODO: Add test cases.
}
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, client")
}))
defer ts.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
gotToken, gotScadenza, err := easyapiclient.RecuperaToken(ctx, tt.args.username, tt.args.password)
if (err != nil) != tt.wantErr {
t.Errorf("RecuperaToken() error = %v, wantErr %v", err, tt.wantErr)
return
}
if gotToken != tt.wantToken {
t.Errorf("RecuperaToken() gotToken = %v, want %v", gotToken, tt.wantToken)
}
if gotScadenza != tt.wantScadenza {
t.Errorf("RecuperaToken() gotScadenza = %v, want %v", gotScadenza, tt.wantScadenza)
}
})
}
}