-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers_test.go
More file actions
124 lines (118 loc) · 2.44 KB
/
helpers_test.go
File metadata and controls
124 lines (118 loc) · 2.44 KB
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
package generator_test
import (
"testing"
"github.com/kalbasit/sqlc-multi-db/generator"
)
func TestFixAcronyms(t *testing.T) {
t.Parallel()
tests := []struct {
name string
input string
expected string
}{
{
name: "Simple Id to ID",
input: "userId",
expected: "userID",
},
{
name: "Url to URL",
input: "profileUrl",
expected: "profileURL",
},
{
name: "Api to API",
input: "fetchApiData",
expected: "fetchAPIData",
},
{
name: "Sql to SQL",
input: "execSqlQuery",
expected: "execSQLQuery",
},
{
name: "Json to JSON",
input: "parseJsonBody",
expected: "parseJSONBody",
},
{
name: "Identifier should not be corrupted",
input: "Identifier",
expected: "Identifier",
},
{
name: "Curling should not be corrupted to CURLing",
input: "Curling",
expected: "Curling",
},
{
name: "XmlParser should become XMLParser",
input: "XmlParser",
expected: "XMLParser",
},
{
name: "HtmlDocument should become HTMLDocument",
input: "HtmlDocument",
expected: "HTMLDocument",
},
{
name: "Multiple acronyms in one string",
input: "userId and profileUrl",
expected: "userID and profileURL",
},
{
name: "Id at end of string",
input: "GetUserId",
expected: "GetUserID",
},
{
name: "Already correct ID should stay",
input: "GetUserID",
expected: "GetUserID",
},
{
name: "Already correct URL should stay",
input: "profileURL",
expected: "profileURL",
},
{
name: "Tcp connection",
input: "openTcpConnection",
expected: "openTCPConnection",
},
{
name: "Jwt token",
input: "validateJwtToken",
expected: "validateJWTToken",
},
{
name: "Ec2 instance",
input: "launchEc2Instance",
expected: "launchEC2Instance",
},
{
name: "Json web token Jwt",
input: "parseJsonWebToken",
expected: "parseJSONWebToken",
},
{
name: "Uuid should not change (not in our list)",
input: "userUuid",
expected: "userUuid",
},
{
name: "Empty string",
input: "",
expected: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
result := generator.FixAcronyms([]byte(tt.input))
if string(result) != tt.expected {
t.Errorf("FixAcronyms(%q) = %q, want %q", tt.input, string(result), tt.expected)
}
})
}
}