Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_test",
"go_library",
)
go_test(
name = "go_default_test",
srcs = ["dao_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/job/main/videoup/conf:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = ["dao.go"],
importpath = "go-common/app/job/main/videoup/dao/monitor",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/job/main/videoup/conf:go_default_library",
"//library/net/http/blademaster:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,37 @@
package monitor
import (
"context"
"net/url"
"go-common/app/job/main/videoup/conf"
xhttp "go-common/library/net/http/blademaster"
)
// Dao is message dao.
type Dao struct {
c *conf.Config
client *xhttp.Client
uri string
}
// New new a message dao.
func New(c *conf.Config) (d *Dao) {
//http://ops-mng.bilibili.co/api/sendsms&message=test&token=
d = &Dao{
c: c,
client: xhttp.NewClient(c.HTTPClient),
uri: c.Host.Monitor + "/api/sendsms",
}
return
}
// Send send message to upper.
func (d *Dao) Send(c context.Context, msg string) (err error) {
params := url.Values{}
params.Set("phone", d.c.Tels)
params.Set("message", msg)
params.Set("token", "f5a658b2-5926-4b71-96c3-7d3777b7d256")
d.client.Get(c, d.uri, "", params, nil)
return
}

View File

@@ -0,0 +1,39 @@
package monitor
import (
"context"
"flag"
"path/filepath"
"testing"
. "github.com/smartystreets/goconvey/convey"
"go-common/app/job/main/videoup/conf"
)
var (
d *Dao
)
func init() {
dir, _ := filepath.Abs("../../cmd/videoup-job-test.toml")
flag.Set("conf", dir)
conf.Init()
d = New(conf.Conf)
}
func WithDao(f func(d *Dao)) func() {
return func() {
f(d)
}
}
func Test_History(t *testing.T) {
var (
c = context.TODO()
err error
)
Convey("History", t, WithDao(func(d *Dao) {
err = d.Send(c, "test-msg")
So(err, ShouldBeNil)
}))
}