Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
counter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Peter Cheng
counter
Commits
60aa50e4
Commit
60aa50e4
authored
Sep 03, 2019
by
Peter Cheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.追加測試碼
parent
1e4a77d4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
125 additions
and
6 deletions
+125
-6
mail.go
controllers/mail.go
+9
-3
mail_test.go
controllers/mail_test.go
+43
-0
punchclock.go
controllers/punchclock.go
+9
-3
punchclock_test.go
controllers/punchclock_test.go
+64
-0
No files found.
controllers/mail.go
View file @
60aa50e4
...
...
@@ -13,10 +13,16 @@ import (
func
SendMail
(
c
*
gin
.
Context
)
{
params
:=
&
beans
.
SendMail
{}
getParams
(
c
,
params
)
json
,
_
:=
json
.
Marshal
(
params
)
response
:=
doSendMail
(
params
)
c
.
JSON
(
http
.
StatusOK
,
response
)
}
//doSendMail 運行寄信用API
func
doSendMail
(
params
*
beans
.
SendMail
)
*
beans
.
Response
{
jsonStr
,
_
:=
json
.
Marshal
(
params
)
channel
:=
"Mail"
message
:=
"Mail/SendMail</UseService>"
+
string
(
json
)
message
:=
"Mail/SendMail</UseService>"
+
string
(
json
Str
)
postMessage
(
channel
,
message
)
response
:=
&
beans
.
Response
{
Status
:
true
,
Channel
:
channel
,
Message
:
message
}
c
.
JSON
(
http
.
StatusOK
,
response
)
return
response
}
controllers/mail_test.go
0 → 100644
View file @
60aa50e4
package
controllers
import
(
"reflect"
"testing"
"github.com/teed7334-restore/counter/beans"
)
func
Test_doSendMail
(
t
*
testing
.
T
)
{
type
args
struct
{
params
*
beans
.
SendMail
}
tests
:=
[]
struct
{
name
string
args
args
want
*
beans
.
Response
}{
{
name
:
"一般測試"
,
args
:
args
{
params
:
&
beans
.
SendMail
{
To
:
"teed7334@gmail.com"
,
Cc
:
"teed7334@163.com"
,
Subject
:
"這是一封測試信"
,
Content
:
"這是一封測試信<br />這是一封測試信<br />這是一封測試信<br />這是一封測試信<br />這是一封測試信<br />這是一封測試信"
,
},
},
want
:
&
beans
.
Response
{
Status
:
true
,
Channel
:
"Mail"
,
Message
:
"Mail/SendMail</UseService>{
\"
To
\"
:
\"
teed7334@gmail.com
\"
,
\"
Cc
\"
:
\"
teed7334@163.com
\"
,
\"
Subject
\"
:
\"
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\"
,
\"
Content
\"
:
\"
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\\
u003cbr /
\\
u003e
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\\
u003cbr /
\\
u003e
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\\
u003cbr /
\\
u003e
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\\
u003cbr /
\\
u003e
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\\
u003cbr /
\\
u003e
\3
51
\2
00
\2
31
\3
46
\2
30
\2
57
\3
44
\2
70
\2
00
\3
45
\2
60
\2
01
\3
46
\2
70
\2
54
\3
50
\2
51
\2
46
\3
44
\2
77
\2
41
\"
}"
,
},
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
if
got
:=
doSendMail
(
tt
.
args
.
params
);
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"doSendMail() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
controllers/punchclock.go
View file @
60aa50e4
...
...
@@ -13,10 +13,16 @@ import (
func
UploadDailyPunchclockData
(
c
*
gin
.
Context
)
{
params
:=
&
homekeeper
.
DailyPunchclockData
{}
getParams
(
c
,
params
)
json
,
_
:=
json
.
Marshal
(
params
)
message
:=
"PunchClock/UploadDailyPunchclockData</UseService>"
+
string
(
json
)
response
:=
doUploadDailyPunchclockData
(
params
)
c
.
JSON
(
http
.
StatusOK
,
response
)
}
//doUploadDailyPunchclockData 運行將每天員工打卡資料上鏈
func
doUploadDailyPunchclockData
(
params
*
homekeeper
.
DailyPunchclockData
)
*
beans
.
Response
{
jsonStr
,
_
:=
json
.
Marshal
(
params
)
message
:=
"PunchClock/UploadDailyPunchclockData</UseService>"
+
string
(
jsonStr
)
channel
:=
"PunchClock"
postMessage
(
channel
,
message
)
response
:=
&
beans
.
Response
{
Status
:
true
,
Channel
:
channel
,
Message
:
message
}
c
.
JSON
(
http
.
StatusOK
,
response
)
return
response
}
controllers/punchclock_test.go
0 → 100644
View file @
60aa50e4
package
controllers
import
(
"reflect"
"testing"
"github.com/teed7334-restore/counter/beans"
homekeeper
"github.com/teed7334-restore/homekeeper/beans"
)
func
Test_doUploadDailyPunchclockData
(
t
*
testing
.
T
)
{
type
args
struct
{
params
*
homekeeper
.
DailyPunchclockData
}
tests
:=
[]
struct
{
name
string
args
args
want
*
beans
.
Response
}{
{
name
:
"一般測試"
,
args
:
args
{
params
:
&
homekeeper
.
DailyPunchclockData
{
Employee
:
&
homekeeper
.
EmployeeOnChain
{
Identify
:
"00190"
,
FirstName
:
"Peter"
,
LastName
:
"Cheng"
,
},
Punchclock
:
&
homekeeper
.
Punchclock
{
Begin
:
&
homekeeper
.
TimeStruct
{
Year
:
"2019"
,
Month
:
"08"
,
Day
:
"28"
,
Hour
:
"09"
,
Minute
:
"24"
,
Second
:
"00"
,
},
End
:
&
homekeeper
.
TimeStruct
{
Year
:
"2019"
,
Month
:
"08"
,
Day
:
"28"
,
Hour
:
"20"
,
Minute
:
"05"
,
Second
:
"00"
,
},
},
},
},
want
:
&
beans
.
Response
{
Status
:
true
,
Channel
:
"PunchClock"
,
Message
:
"PunchClock/UploadDailyPunchclockData</UseService>{
\"
employee
\"
:{
\"
$class
\"
:
\"\"
,
\"
identify
\"
:
\"
00190
\"
,
\"
firstName
\"
:
\"
Peter
\"
,
\"
lastName
\"
:
\"
Cheng
\"
},
\"
punchclock
\"
:{
\"
begin
\"
:{
\"
year
\"
:
\"
2019
\"
,
\"
month
\"
:
\"
08
\"
,
\"
day
\"
:
\"
28
\"
,
\"
hour
\"
:
\"
09
\"
,
\"
minute
\"
:
\"
24
\"
,
\"
second
\"
:
\"
00
\"
},
\"
end
\"
:{
\"
year
\"
:
\"
2019
\"
,
\"
month
\"
:
\"
08
\"
,
\"
day
\"
:
\"
28
\"
,
\"
hour
\"
:
\"
20
\"
,
\"
minute
\"
:
\"
05
\"
,
\"
second
\"
:
\"
00
\"
}}}"
,
},
},
}
for
_
,
tt
:=
range
tests
{
t
.
Run
(
tt
.
name
,
func
(
t
*
testing
.
T
)
{
got
:=
doUploadDailyPunchclockData
(
tt
.
args
.
params
)
if
!
reflect
.
DeepEqual
(
got
,
tt
.
want
)
{
t
.
Errorf
(
"doUploadDailyPunchclockData() = %v, want %v"
,
got
,
tt
.
want
)
}
})
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment