正在显示
22 个修改的文件
包含
428 行增加
和
17 行删除
| @@ -7,10 +7,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | @@ -7,10 +7,7 @@ aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | ||
| 7 | #阿里云基础配置 | 7 | #阿里云基础配置 |
| 8 | AccessKeyID ="LTAI4FhiZ3UktC6N1u3H5GFC" | 8 | AccessKeyID ="LTAI4FhiZ3UktC6N1u3H5GFC" |
| 9 | AccessKeySecret ="UyspWwdni55CYQ02hUCint4qY2jNYO" | 9 | AccessKeySecret ="UyspWwdni55CYQ02hUCint4qY2jNYO" |
| 10 | -#AccessKeyID ="LTAI4Fz1LUBW2fXp6QWaJHRS" | ||
| 11 | -#AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" | ||
| 12 | -#阿里云->绑定域名 cname = https://media.goexample.live/ | ||
| 13 | -cname ="https://media.fjmaimaimai.com/" | 10 | +cname ="https://media.goexample.live/" |
| 14 | 11 | ||
| 15 | 12 | ||
| 16 | #友盟推送 | 13 | #友盟推送 |
| @@ -7,5 +7,5 @@ AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" | @@ -7,5 +7,5 @@ AccessKeySecret ="aLZXwK8pgrs10Ws03qcN7NsrSXFVsg" | ||
| 7 | log_level = "${LOG_LEVEL||debug}" | 7 | log_level = "${LOG_LEVEL||debug}" |
| 8 | aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" | 8 | aliyun_logs_access ="${aliyun_logs_access||F:/log/app.log}" |
| 9 | 9 | ||
| 10 | -#阿里云 https://media.goexample.live/ | 10 | +#阿里云 |
| 11 | cname ="https://media.fjmaimaimai.com/" | 11 | cname ="https://media.fjmaimaimai.com/" |
| @@ -3,11 +3,25 @@ module openapi | @@ -3,11 +3,25 @@ module openapi | ||
| 3 | go 1.12 | 3 | go 1.12 |
| 4 | 4 | ||
| 5 | require ( | 5 | require ( |
| 6 | + github.com/ajg/form v1.5.1 // indirect | ||
| 6 | github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 | 7 | github.com/aliyun/alibaba-cloud-sdk-go v1.60.348 |
| 7 | github.com/aliyun/aliyun-sts-go-sdk v0.0.0-20171106034748-98d3903a2309 | 8 | github.com/aliyun/aliyun-sts-go-sdk v0.0.0-20171106034748-98d3903a2309 |
| 8 | github.com/astaxie/beego v1.10.0 | 9 | github.com/astaxie/beego v1.10.0 |
| 10 | + github.com/fatih/structs v1.1.0 // indirect | ||
| 11 | + github.com/gavv/httpexpect v2.0.0+incompatible | ||
| 12 | + github.com/google/go-querystring v1.0.0 // indirect | ||
| 13 | + github.com/imkira/go-interpol v1.1.0 // indirect | ||
| 9 | github.com/klauspost/cpuid v1.2.3 // indirect | 14 | github.com/klauspost/cpuid v1.2.3 // indirect |
| 15 | + github.com/moul/http2curl v1.0.0 // indirect | ||
| 16 | + github.com/onsi/ginkgo v1.10.3 | ||
| 17 | + github.com/onsi/gomega v1.7.1 | ||
| 10 | github.com/satori/go.uuid v1.2.0 | 18 | github.com/satori/go.uuid v1.2.0 |
| 19 | + github.com/sergi/go-diff v1.1.0 // indirect | ||
| 20 | + github.com/valyala/fasthttp v1.13.1 // indirect | ||
| 21 | + github.com/xeipuuv/gojsonschema v1.2.0 // indirect | ||
| 22 | + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect | ||
| 23 | + github.com/yudai/gojsondiff v1.0.0 // indirect | ||
| 24 | + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect | ||
| 11 | gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1 | 25 | gitlab.fjmaimaimai.com/mmm-go/gocomm v0.0.1 |
| 12 | ) | 26 | ) |
| 13 | 27 |
| @@ -3,7 +3,9 @@ package main | @@ -3,7 +3,9 @@ package main | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/astaxie/beego" | 4 | "github.com/astaxie/beego" |
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 6 | + "openapi/pkg/constant" | ||
| 6 | 7 | ||
| 8 | + _ "openapi/pkg/log" | ||
| 7 | _ "openapi/pkg/port/beego" | 9 | _ "openapi/pkg/port/beego" |
| 8 | ) | 10 | ) |
| 9 | 11 | ||
| @@ -12,6 +14,6 @@ func main() { | @@ -12,6 +14,6 @@ func main() { | ||
| 12 | log.Info("server on stop!") | 14 | log.Info("server on stop!") |
| 13 | }() | 15 | }() |
| 14 | log.Info("server on start!") | 16 | log.Info("server on start!") |
| 15 | - | 17 | + constant.DebugConfig() |
| 16 | beego.Run() | 18 | beego.Run() |
| 17 | } | 19 | } |
| 1 | package service | 1 | package service |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | - "github.com/astaxie/beego" | ||
| 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 4 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 5 | + "openapi/pkg/constant" | ||
| 6 | protocol "openapi/pkg/domain" | 6 | protocol "openapi/pkg/domain" |
| 7 | "openapi/pkg/infrastructure/aliyun" | 7 | "openapi/pkg/infrastructure/aliyun" |
| 8 | "openapi/pkg/infrastructure/utils" | 8 | "openapi/pkg/infrastructure/utils" |
| @@ -44,7 +44,7 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl | @@ -44,7 +44,7 @@ func CreateUploadVideo(header *protocol.RequestHeader, request *aliyun.CreateUpl | ||
| 44 | return | 44 | return |
| 45 | } | 45 | } |
| 46 | rsp.FileName = fileName | 46 | rsp.FileName = fileName |
| 47 | - rsp.FileURL = up.GetFileUrl(beego.AppConfig.String("cname")) | 47 | + rsp.FileURL = up.GetFileUrl(constant.CName) |
| 48 | return | 48 | return |
| 49 | } | 49 | } |
| 50 | 50 |
| 1 | package constant | 1 | package constant |
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +var ( | ||
| 9 | + LogFilePath string = "F:/log/app.log" | ||
| 10 | + LogLevel string = "error" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func init() { | ||
| 14 | + LogLevel = config.StringDefault("log_level", LogLevel) | ||
| 15 | + LogFilePath = config.StringDefault("aliyun_logs_access", LogFilePath) | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func DebugConfig() { | ||
| 19 | + for i := range config.HistorySort { | ||
| 20 | + k := config.HistorySort[i] | ||
| 21 | + v, ok := config.History[k] | ||
| 22 | + if !ok { | ||
| 23 | + continue | ||
| 24 | + } | ||
| 25 | + log.Debug(fmt.Sprintf("【load config】 %v=%v", k, v)) | ||
| 26 | + } | ||
| 27 | +} |
pkg/constant/loader.go
0 → 100644
| 1 | +package constant | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | +) | ||
| 6 | + | ||
| 7 | +var config = NewConfigLoader() | ||
| 8 | + | ||
| 9 | +type ConfigLoader struct { | ||
| 10 | + History map[string]interface{} | ||
| 11 | + HistorySort []string | ||
| 12 | +} | ||
| 13 | + | ||
| 14 | +func NewConfigLoader() *ConfigLoader { | ||
| 15 | + return &ConfigLoader{ | ||
| 16 | + History: make(map[string]interface{}), | ||
| 17 | + HistorySort: make([]string, 0), | ||
| 18 | + } | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func (c *ConfigLoader) String(key string) (ret string, ok bool) { | ||
| 22 | + if ret = beego.AppConfig.String(key); len(ret) != 0 { | ||
| 23 | + ok = true | ||
| 24 | + c.SetHistory(key, ret) | ||
| 25 | + return | ||
| 26 | + } | ||
| 27 | + return | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (c *ConfigLoader) StringDefault(key string, defaultValue string) string { | ||
| 31 | + if ret, ok := c.String(key); ok { | ||
| 32 | + return ret | ||
| 33 | + } | ||
| 34 | + return defaultValue | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func (c *ConfigLoader) SetHistory(key string, value interface{}) { | ||
| 38 | + if _, ok := c.History[key]; !ok { | ||
| 39 | + c.History[key] = value | ||
| 40 | + c.HistorySort = append(c.HistorySort, key) | ||
| 41 | + } | ||
| 42 | +} |
| 1 | package constant | 1 | package constant |
| 2 | + | ||
| 3 | +var ( | ||
| 4 | + RegionID = "cn-shanghai" | ||
| 5 | + AccessKeyID string = "LTAI4FhiZ3UktC6N1u3H5GFC" | ||
| 6 | + AccessKeySecret string = "UyspWwdni55CYQ02hUCint4qY2jNYO" | ||
| 7 | + CName string = "https://media.goexample.live/" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +func init() { | ||
| 11 | + AccessKeyID = config.StringDefault("AccessKeyID", AccessKeyID) | ||
| 12 | + AccessKeySecret = config.StringDefault("AccessKeySecret", AccessKeySecret) | ||
| 13 | + CName = config.StringDefault("cname", CName) | ||
| 14 | +} |
| 1 | package aliyun | 1 | package aliyun |
| 2 | 2 | ||
| 3 | -import "github.com/astaxie/beego" | ||
| 4 | - | ||
| 5 | var ( | 3 | var ( |
| 6 | - RegionID = "cn-shanghai" | ||
| 7 | - AccessKeyID = beego.AppConfig.String("AccessKeyID") | ||
| 8 | - AccessKeySecret = beego.AppConfig.String("AccessKeySecret") | 4 | +//RegionID = "cn-shanghai" |
| 5 | +//AccessKeyID = beego.AppConfig.String("AccessKeyID") | ||
| 6 | +//AccessKeySecret = beego.AppConfig.String("AccessKeySecret") | ||
| 9 | ) | 7 | ) |
| 10 | 8 | ||
| 11 | const ( | 9 | const ( |
| @@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
| 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" | 9 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/common" |
| 10 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 10 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
| 11 | comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" | 11 | comm_time "gitlab.fjmaimaimai.com/mmm-go/gocomm/time" |
| 12 | + "openapi/pkg/constant" | ||
| 12 | "openapi/pkg/infrastructure/utils" | 13 | "openapi/pkg/infrastructure/utils" |
| 13 | "path" | 14 | "path" |
| 14 | "path/filepath" | 15 | "path/filepath" |
| @@ -17,13 +18,13 @@ import ( | @@ -17,13 +18,13 @@ import ( | ||
| 17 | 18 | ||
| 18 | //客户端 | 19 | //客户端 |
| 19 | func DefaultVodClient() (client *vod.Client, err error) { | 20 | func DefaultVodClient() (client *vod.Client, err error) { |
| 20 | - return InitVodClient(AccessKeyID, AccessKeySecret) | 21 | + return InitVodClient(constant.AccessKeyID, constant.AccessKeySecret) |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | //初始化客户端 | 24 | //初始化客户端 |
| 24 | func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Client, err error) { | 25 | func InitVodClient(accessKeyId string, accessKeySecret string) (client *vod.Client, err error) { |
| 25 | // 点播服务接入区域 | 26 | // 点播服务接入区域 |
| 26 | - regionId := RegionID | 27 | + regionId := constant.RegionID |
| 27 | // 创建授权对象 | 28 | // 创建授权对象 |
| 28 | credential := &credentials.AccessKeyCredential{ | 29 | credential := &credentials.AccessKeyCredential{ |
| 29 | accessKeyId, | 30 | accessKeyId, |
| @@ -73,7 +74,7 @@ func RefreshUploadVideo(client *vod.Client, r *RefreshUploadVideoRequest) (respo | @@ -73,7 +74,7 @@ func RefreshUploadVideo(client *vod.Client, r *RefreshUploadVideoRequest) (respo | ||
| 73 | if up, e := ParseUploadAddress(rsp.UploadAddress); e != nil { | 74 | if up, e := ParseUploadAddress(rsp.UploadAddress); e != nil { |
| 74 | log.Error(e) | 75 | log.Error(e) |
| 75 | } else { | 76 | } else { |
| 76 | - response.FileURL = up.GetFileUrl(beego.AppConfig.String("cname")) | 77 | + response.FileURL = up.GetFileUrl(constant.CName) |
| 77 | } | 78 | } |
| 78 | return | 79 | return |
| 79 | } | 80 | } |
pkg/log/logger.go
0 → 100644
| 1 | +package log | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/config" | ||
| 6 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
| 7 | + "openapi/pkg/constant" | ||
| 8 | + "openapi/pkg/infrastructure/utils" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +func init() { | ||
| 12 | + log.InitLog(config.Logger{ | ||
| 13 | + Filename: constant.LogFilePath, | ||
| 14 | + Level: fmt.Sprintf("%v", utils.ResolveLogLevel(constant.LogLevel)), | ||
| 15 | + }) | ||
| 16 | +} |
| @@ -2,6 +2,7 @@ package routers | @@ -2,6 +2,7 @@ package routers | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "github.com/astaxie/beego" | 4 | "github.com/astaxie/beego" |
| 5 | + "openapi/pkg/constant" | ||
| 5 | "openapi/pkg/port/beego/controllers" | 6 | "openapi/pkg/port/beego/controllers" |
| 6 | "openapi/pkg/port/beego/controllers/v1" | 7 | "openapi/pkg/port/beego/controllers/v1" |
| 7 | ) | 8 | ) |
| @@ -13,6 +14,6 @@ func init() { | @@ -13,6 +14,6 @@ func init() { | ||
| 13 | beego.NSNamespace("vod", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})), | 14 | beego.NSNamespace("vod", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.VodController{})), |
| 14 | beego.NSNamespace("push", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.PushController{})), | 15 | beego.NSNamespace("push", beego.NSBefore(controllers.AllowOption), beego.NSInclude(&v1.PushController{})), |
| 15 | ) | 16 | ) |
| 16 | - beego.SetStaticPath("/log", beego.AppConfig.String("aliyun_logs_access")) | 17 | + beego.SetStaticPath("/log", constant.LogFilePath) |
| 17 | beego.AddNamespace(nsV1) | 18 | beego.AddNamespace(nsV1) |
| 18 | } | 19 | } |
| 1 | +package push | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("消息推送测试", func() { | ||
| 10 | + ginkgo.Describe("消息推送测试", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "mmmType": 1, | ||
| 16 | + "deviceToken": "", | ||
| 17 | + "clientId": "b5fff5f6b0af551da5f381fa47991828", | ||
| 18 | + "appkey": "5AjJeDOSOZ5ojQpXJFjhg9", | ||
| 19 | + "secret": "9VnM8MaA6n84Y5VnOIaSvA", | ||
| 20 | + "appId": "TkpBI4awmg9fBUx3NWKXS6", | ||
| 21 | + "title": " hello", | ||
| 22 | + "content": " hello content", | ||
| 23 | + "ext": map[string]interface{}{"transData": "trans-content"}, | ||
| 24 | + } | ||
| 25 | + httpExpect.POST("/v1/push/pushInfo"). | ||
| 26 | + WithJSON(body). | ||
| 27 | + Expect(). | ||
| 28 | + Status(http.StatusOK). | ||
| 29 | + JSON(). | ||
| 30 | + Object(). | ||
| 31 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 32 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 33 | + }) | ||
| 34 | + }) | ||
| 35 | + }) | ||
| 36 | +}) |
| 1 | +package push | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "github.com/onsi/gomega" | ||
| 7 | + "net/http" | ||
| 8 | + "net/http/httptest" | ||
| 9 | + _ "openapi/pkg/port/beego" | ||
| 10 | + "testing" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func TestPush(t *testing.T) { | ||
| 14 | + gomega.RegisterFailHandler(ginkgo.Fail) | ||
| 15 | + ginkgo.RunSpecs(t, "Beego Port Config Correlations Test Case Suite") | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var handler http.Handler | ||
| 19 | +var server *httptest.Server | ||
| 20 | + | ||
| 21 | +var _ = ginkgo.BeforeSuite(func() { | ||
| 22 | + handler = beego.BeeApp.Handlers | ||
| 23 | + beego.BConfig.CopyRequestBody = true | ||
| 24 | + server = httptest.NewServer(handler) | ||
| 25 | +}) | ||
| 26 | + | ||
| 27 | +var _ = ginkgo.AfterSuite(func() { | ||
| 28 | + server.Close() | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建图片上传凭证(单图片)", func() { | ||
| 10 | + ginkgo.Describe("创建图片上传凭证(单图片)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "fileName": "test.jpg", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/createUploadImage"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建图片上传凭证(多图片)", func() { | ||
| 10 | + ginkgo.Describe("创建图片上传凭证(多图片)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "items": []struct { | ||
| 16 | + FileName string `json:"fileName"` | ||
| 17 | + }{{FileName: "test.jpg"}}, | ||
| 18 | + } | ||
| 19 | + httpExpect.POST("/v1/vod/createUploadImages"). | ||
| 20 | + WithJSON(body). | ||
| 21 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 22 | + Expect(). | ||
| 23 | + Status(http.StatusOK). | ||
| 24 | + JSON(). | ||
| 25 | + Object(). | ||
| 26 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 27 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 28 | + }) | ||
| 29 | + }) | ||
| 30 | + }) | ||
| 31 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建视频上传凭证(单视频)", func() { | ||
| 10 | + ginkgo.Describe("创建视频上传凭证(单视频)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "fileName": "test.mp4", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/createUploadVideos"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("创建视频上传凭证(多视频)", func() { | ||
| 10 | + ginkgo.Describe("创建视频上传凭证(多视频)", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "items": []struct { | ||
| 16 | + FileName string `json:"fileName"` | ||
| 17 | + }{{FileName: "test.mp4"}}, | ||
| 18 | + } | ||
| 19 | + httpExpect.POST("/v1/vod/createUploadVideos"). | ||
| 20 | + WithJSON(body). | ||
| 21 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 22 | + Expect(). | ||
| 23 | + Status(http.StatusOK). | ||
| 24 | + JSON(). | ||
| 25 | + Object(). | ||
| 26 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 27 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 28 | + }) | ||
| 29 | + }) | ||
| 30 | + }) | ||
| 31 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("获取播放信息测试", func() { | ||
| 10 | + ginkgo.Describe("获取播放信息测试", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "videoId": "7be8e50dd65e45d285908bf28c8e94b2", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/getPlayInfo"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("获取播放凭证测试", func() { | ||
| 10 | + ginkgo.Describe("获取播放凭证测试", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "videoId": "7be8e50dd65e45d285908bf28c8e94b2", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/getVideoPlayAuth"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/gavv/httpexpect" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "net/http" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +var _ = ginkgo.Describe("刷新视频上次凭证", func() { | ||
| 10 | + ginkgo.Describe("刷新视频上次凭证", func() { | ||
| 11 | + ginkgo.Context("", func() { | ||
| 12 | + ginkgo.It("", func() { | ||
| 13 | + httpExpect := httpexpect.New(ginkgo.GinkgoT(), server.URL) | ||
| 14 | + body := map[string]interface{}{ | ||
| 15 | + "videoId": "1023bc472c69499dbe332afa785ee610", | ||
| 16 | + } | ||
| 17 | + httpExpect.POST("/v1/vod/refreshUploadVideo"). | ||
| 18 | + WithJSON(body). | ||
| 19 | + WithHeader("x-mmm-appproject", "opportunity"). | ||
| 20 | + Expect(). | ||
| 21 | + Status(http.StatusOK). | ||
| 22 | + JSON(). | ||
| 23 | + Object(). | ||
| 24 | + ContainsKey("code").ValueEqual("code", 0). | ||
| 25 | + ContainsKey("msg").ValueEqual("msg", "成功") | ||
| 26 | + }) | ||
| 27 | + }) | ||
| 28 | + }) | ||
| 29 | +}) |
test/integration/beego/vod/vod_suite_test.go
0 → 100644
| 1 | +package vod | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/astaxie/beego" | ||
| 5 | + "github.com/onsi/ginkgo" | ||
| 6 | + "github.com/onsi/gomega" | ||
| 7 | + "net/http" | ||
| 8 | + "net/http/httptest" | ||
| 9 | + _ "openapi/pkg/port/beego" | ||
| 10 | + "testing" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func TestPush(t *testing.T) { | ||
| 14 | + gomega.RegisterFailHandler(ginkgo.Fail) | ||
| 15 | + ginkgo.RunSpecs(t, "Beego Port Config Correlations Test Case Suite") | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +var handler http.Handler | ||
| 19 | +var server *httptest.Server | ||
| 20 | + | ||
| 21 | +var _ = ginkgo.BeforeSuite(func() { | ||
| 22 | + handler = beego.BeeApp.Handlers | ||
| 23 | + beego.BConfig.CopyRequestBody = true | ||
| 24 | + server = httptest.NewServer(handler) | ||
| 25 | +}) | ||
| 26 | + | ||
| 27 | +var _ = ginkgo.AfterSuite(func() { | ||
| 28 | + server.Close() | ||
| 29 | +}) |
-
请 注册 或 登录 后发表评论