-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbsearch_test.go
55 lines (48 loc) · 1.29 KB
/
dbsearch_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
51
52
53
54
55
// Copyright 2019 Alberto Bregliano. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package token_test
import (
"context"
"testing"
"time"
"github.com/axamon/token"
// mysql import
_ "github.com/go-sql-driver/mysql"
)
func TestCheckCredentialsDBCtx(t *testing.T) {
ctxshort, cancel := context.WithTimeout(context.Background(), time.Microsecond)
defer cancel()
type args struct {
ctx context.Context
c *token.Credentials
}
tests := []struct {
name string
args args
want bool
wantErr bool
}{
// TODO: Add test cases.
{name: "Should go in error",
args: args{ctx: context.TODO(), c: &token.Credentials{User: "pippo", Hashpass: "fsd"}},
want: false,
wantErr: true},
{name: "Should timeout",
args: args{ctx: ctxshort, c: &token.Credentials{User: "pippo", Hashpass: "fsd"}},
want: false,
wantErr: true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, err := token.CheckCredentialsDBCtx(tt.args.ctx, tt.args.c)
if (err != nil) != tt.wantErr {
t.Errorf("CheckCredentialsDBCtx() error = %v, wantErr %v", err, tt.wantErr)
return
}
if got != tt.want {
t.Errorf("CheckCredentialsDBCtx() = %v, want %v", got, tt.want)
}
})
}
}