-
Notifications
You must be signed in to change notification settings - Fork 0
/
Handlers_test.old
141 lines (105 loc) · 2.8 KB
/
Handlers_test.old
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
package main
import (
"fmt"
"testing"
)
var IDs []string
func TestCreateAccount(t *testing.T) {
redisConnector = NewConnection("localhost:6379", "", 0)
mails := []string{
"test@outlook.com",
"test@gmail.com",
"test@custom.com",
}
tests := []struct {
name string
username string
email []string
}{
{
name: "Test",
username: "FullTest",
email: mails,
},
{name: "Test1", username: "FullTest1", email: mails},
{name: "Test2", username: "FullTest2", email: mails},
{name: "Test3", username: "FullTest3", email: mails},
{name: "Test4", username: "FullTest4", email: mails},
{name: "Test5", username: "FullTest5", email: mails},
{name: "Test6", username: "FullTest6", email: mails},
{name: "Test7", username: "FullTest7", email: mails},
}
IDs = make([]string, 0)
cChannel := make(chan AccountModel)
defer close(cChannel)
//var value AccountModel
for index, val := range tests {
fmt.Println("")
fmt.Printf("Counter %d started", index)
fmt.Println("")
go Create(val.name, val.username, val.email, cChannel)
value := <-cChannel
if value.ID == "ERR_500INTEX" {
panic(value.ID)
}
IDs = append(IDs, value.ID)
fmt.Printf("%s | %s alias %s, XP:%d and Lv:%d, ", value.ID, value.username, value.name, value.XP, value.Level, value.email)
}
}
func TestUpdateMail(t *testing.T) {
redisConnector = NewConnection("localhost:6379", "", 0)
mails := []string{
"test1@outlook.com",
"test5@gmail.com",
"test@custom.com",
}
cChannel := make(chan bool)
defer close(cChannel)
aChannel := make(chan AccountModel)
defer close(aChannel)
for _, val := range IDs[3:5] {
go UpdateEmails(val, mails, cChannel)
go Find(val, aChannel)
acc := <-aChannel
fmt.Printf("%s | Mails updated: %s, new mails", val, <-cChannel, acc.email)
fmt.Println("")
}
}
func TestGetAccount(t *testing.T) {
redisConnector = NewConnection("localhost:6379", "", 0)
cChannel := make(chan AccountModel)
defer close(cChannel)
//var value AccountModel
for index, val := range IDs {
fmt.Println("")
fmt.Printf("Counter %d started", index)
fmt.Println("")
go Find(val, cChannel)
value := <-cChannel
if value.ID == "ERR_500INTEX" {
panic(value.ID)
}
fmt.Printf("%s | %s alias %s, XP:%d and Lv:%d, mails ", value.ID, value.username, value.name, value.XP, value.Level, value.email)
}
}
func TestRemoveAccount(t *testing.T) {
redisConnector = NewConnection("localhost:6379", "", 0)
if len(IDs) > 0 {
cChannel := make(chan bool)
defer close(cChannel)
//var value AccountModel
for index, val := range IDs {
fmt.Println("")
fmt.Printf("Counter %d started %s", index, val)
fmt.Println("")
go Remove(val, cChannel)
if <-cChannel == false {
fmt.Printf("Couldn't not remove value %s", val)
}
}
}
Reset()
CloseConnection(redisConnector)
}
*/