script_test.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package service
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "go-common/app/admin/ep/melloi/model"
  6. )
  7. var (
  8. script = model.Script{
  9. ID: 1,
  10. Type: 1,
  11. TestName: "testName",
  12. ThreadsSum: 10,
  13. LoadTime: 10,
  14. ReadyTime: 100,
  15. ProcType: "https",
  16. URL: "live.bilibili.com/as/xxx",
  17. Domain: "live.bilibili.com",
  18. Port: "80",
  19. Path: "/x/v2/search?actionKey=appkey&appkey=27eb53fc9058f8c3&build=6790&device=phone&duration=0&from_source=app_search&highlight=1&keyword=${test}&access_key=${access_key}",
  20. Method: "Get",
  21. UpdateBy: "hujianping",
  22. JmeterLog: "/data/jmeter-log/test/ep/melloi/",
  23. ResJtl: "/data/jmeter-log/test/ep/melloi/",
  24. }
  25. fileWrite = false
  26. )
  27. func Test_Script(t *testing.T) {
  28. Convey("add script", t, func() {
  29. _, _, err := s.AddScript(&script, fileWrite)
  30. So(err, ShouldBeNil)
  31. })
  32. Convey("query script", t, func() {
  33. _, err := s.QueryScripts(&script, 1, 1)
  34. So(err, ShouldBeNil)
  35. })
  36. Convey("count query script", t, func() {
  37. cs := s.CountQueryScripts(&script)
  38. So(cs, ShouldNotBeNil)
  39. })
  40. Convey("delete script", t, func() {
  41. err := s.DelScript(script.ID)
  42. So(err, ShouldBeNil)
  43. })
  44. Convey("update script", t, func() {
  45. _, err := s.UpdateScript(&script)
  46. So(err, ShouldBeNil)
  47. })
  48. Convey("add jmeter sample", t, func() {
  49. _, err := s.AddJmeterSample(&script)
  50. So(err, ShouldBeNil)
  51. })
  52. }