Skip to content

Commit 8fdb09e

Browse files
committed
2way 필수 파라미터 체크 로직 네이밍 변경 (#2)
- checkTwoWaykeyword -> isEmptyTwoWayKeyword - checkTwoWayInfo -> hasTwoWayInfo
1 parent 9c8836c commit 8fdb09e

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

easycodefgo.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (self *Codef) RequestProduct(
4949
}
5050

5151
// 추가인증 키워드 체크
52-
if !checkTwoWayKeyword(param) {
52+
if !isEmptyTwoWayKeyword(param) {
5353
res := newResponseByMessage(messageInvalid2WayKeyword)
5454
return res.WriteValueAsString(), nil
5555
}
@@ -83,7 +83,7 @@ func (self *Codef) RequestCertification(
8383
}
8484

8585
// 추가인증 파라미터 필수 입력 체크
86-
if !checkTwoWayInfo(param) {
86+
if !hasTwoWayInfo(param) {
8787
res := newResponseByMessage(messageInvalid2WayInfo)
8888
return res.WriteValueAsString(), nil
8989
}
@@ -225,8 +225,8 @@ func (self *Codef) getReqInfoByServiceType(serviceType ServiceType) *requestInfo
225225
}
226226
}
227227

228-
// 2Way 키워드 존재 여부 확인
229-
func checkTwoWayKeyword(param map[string]interface{}) bool {
228+
// 2Way 키워드가 없는지 확인
229+
func isEmptyTwoWayKeyword(param map[string]interface{}) bool {
230230
if _, ok := param["is2Way"]; ok {
231231
return false
232232
}
@@ -236,8 +236,8 @@ func checkTwoWayKeyword(param map[string]interface{}) bool {
236236
return true
237237
}
238238

239-
// 2way 상품 요청 시 필수 데이터 체크
240-
func checkTwoWayInfo(param map[string]interface{}) bool {
239+
// 2way 상품 요청 시 필수 데이터 존재하는지 확인
240+
func hasTwoWayInfo(param map[string]interface{}) bool {
241241
is2Way, ok := param["is2Way"]
242242
if !ok || reflect.TypeOf(is2Way).Kind() != reflect.Bool || !is2Way.(bool) {
243243
return false

easycodefgo_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@ func TestGetClientSecret(t *testing.T) {
4343
ast.Equal(key, codef.clientSecret)
4444
}
4545

46-
// 2Way 키워드 존재 여부 확인
47-
func TestCheckTwoWayKeyword(t *testing.T) {
46+
// 2Way 키워드 존재 여부 확인 테스트
47+
func TestIsEmptyTwoWayKeyword(t *testing.T) {
4848
ast := assert.New(t)
4949

5050
m := map[string]interface{}{
5151
"is2Way": true,
5252
"twoWayInfo": "info",
5353
}
54-
b := checkTwoWayKeyword(m)
54+
b := isEmptyTwoWayKeyword(m)
5555
ast.False(b)
5656

5757
delete(m, "is2Way")
58-
b = checkTwoWayKeyword(m)
58+
b = isEmptyTwoWayKeyword(m)
5959
ast.False(b)
6060

6161
delete(m, "twoWayInfo")
62-
b = checkTwoWayKeyword(m)
62+
b = isEmptyTwoWayKeyword(m)
6363
ast.True(b)
6464
}
6565

@@ -135,8 +135,8 @@ func TestGetReqInfoByServiceType(t *testing.T) {
135135
ast.Equal(codef.clientSecret, reqInfo.clientSecret)
136136
}
137137

138-
// checkTwoWayInfo 테스트
139-
func TestCheckTwoWayInfo(t *testing.T) {
138+
// hasTwoWayInfo 테스트
139+
func TestHasTwoWayInfo(t *testing.T) {
140140
ast := assert.New(t)
141141

142142
twoWayInfo := map[string]interface{}{
@@ -151,27 +151,27 @@ func TestCheckTwoWayInfo(t *testing.T) {
151151
}
152152

153153
// bool 타입이 아닐때
154-
ok := checkTwoWayInfo(param)
154+
ok := hasTwoWayInfo(param)
155155
ast.False(ok)
156156

157157
// is2Way가 false일 때
158158
param["is2Way"] = false
159-
ok = checkTwoWayInfo(param)
159+
ok = hasTwoWayInfo(param)
160160
ast.False(ok)
161161

162162
// 정상 작동
163163
param["is2Way"] = true
164-
ok = checkTwoWayInfo(param)
164+
ok = hasTwoWayInfo(param)
165165
ast.True(ok)
166166

167167
// twoWayInfo가 맵으로 캐스팅 되지 않을 때
168168
param["twoWayInfo"] = "string"
169-
ok = checkTwoWayInfo(param)
169+
ok = hasTwoWayInfo(param)
170170
ast.False(ok)
171171

172172
// twoWayInfo가 nil일 때
173173
param["twoWayInfo"] = nil
174-
ok = checkTwoWayInfo(param)
174+
ok = hasTwoWayInfo(param)
175175
ast.False(ok)
176176
}
177177

0 commit comments

Comments
 (0)