1.设计API
2.编写cmd_test.go
3.辅助完成功能测试和mock测试
4.编写README.md
https://retokani.docs.apiary.io/#
与组长对应书写的agenda功能如下图:
模块测试代码如下:
测试UserRegister:
func TestRegister(t *testing.T) {
fmt.Println("=====> In TEST of UserRegister")
UserRegisterCmd.Flags().Set("username", "Alice")
UserRegisterCmd.Flags().Set("password", "123")
UserRegisterCmd.Flags().Set("email", "[email protected]")
UserRegisterCmd.Flags().Set("phone", "123")
UserRegisterCmd.Run(UserRegisterCmd, nil)
}
测试UserLogin:
func TestLogin(t *testing.T) {
fmt.Println("=====> In TEST of UserLogin")
UserLoginCmd.Run(UserLoginCmd, nil)
UserLoginCmd.Flags().Set("username", "Alice")
UserLoginCmd.Flags().Set("password", "123")
UserLoginCmd.Run(UserLoginCmd, nil)
}
测试users(列出所有的用户):
func TestShowAllUsers(t *testing.T) {
fmt.Println("=====> In TEST of ListAllUser")
usersCmd.Run(usersCmd, nil)
}
测试MeetingCreate:
func TestCreateNewMeeting(t *testing.T) {
fmt.Println("=====> In TEST of MeetingCreate")
MeetingCreateCmd.Flags().Set("title", "testMeeting")
MeetingCreateCmd.Flags().Set("members", "testUser0,testUser1")
MeetingCreateCmd.Flags().Set("starttime", "2000/01/01/00:00")
MeetingCreateCmd.Flags().Set("endtime", "2001/01/01/00:00")
MeetingCreateCmd.Run(MeetingCreateCmd, nil)
}
测试meetings:(列出所有会议)
func TestShowAllMeetings(t *testing.T) {
fmt.Println("=====> In TEST of ListAllMeeting")
meetingsCmd.Run(meetingsCmd, nil)
}
测试UserDelete:
func TestUserDelete(t *testing.T) {
fmt.Println("=====> In TEST of UserDelete")
UserDeleteCmd.Run(UserDeleteCmd, nil)
UserDeleteCmd.Run(usersCmd, nil)
}
测试方法:
1.修改host为:http://localhost:8080完成本地测试。
2.修改host为:https://private-c9f16-retokani.apiary-mock.com
完成travis测试
测试方法:
1.修改host为:http://localhost:8080完成本地测试:
$ go test
=====> In TEST of UserRegister
Register successfully.The account detail is :
{
"Name": "Alice",
"Password": "123",
"Email": "[email protected]",
"Phone": "123"
}
=====> In TEST of UserLogin
Using UserName and PassWord to login Agenda:
attention:If the PassWord is right,you can login Agenda and use it
If forget the PassWord,you must register another one User
Usage:
agenda login -u [UserName] -p [PassWord] [flags]
Flags:
-p, --password string new user's password
-u, --username string new user's username
Global Flags:
--config string config file (default is $HOME/.cli.yaml)
Login successfully!
username:Alice
=====> In TEST of ListAllUser
[
{
"Name": "Alice",
"Password": "123",
"Email": "[email protected]",
"Phone": "123"
}
]
=====> In TEST of MeetingCreate
To create a new meeting with:
[Title] the Title of the meeting
[Participator] the Participator of the meeting,the Participator can only attend one meeting during one meeting time
[StartTime] the StartTime of the meeting
[EndTime] the EndTime of the meeting
Usage:
agenda create -t [Title] -p [Participator] -s [StartTime] -e [EndTime] [flags]
Flags:
-e, --EndTime string meeting's endTime
-p, --Participator strings meeting's participator
-s, --StartTime string meeting's startTime
-t, --Title string meeting title
Global Flags:
--config string config file (default is $HOME/.cli.yaml)
=====> In TEST of ListAllMeeting
[]
=====> In TEST of UserDelete
Delete successfully.Delete user failed.
PASS
ok Agenda-Service/cli/cmd 0.138s
2.修改host为:https://private-c9f16-retokani.apiary-mock.com
完成travis测试:(测试细节在组长的测试网站)