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/interface/main/app-view/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/interface/main/app-view/dao/ai",
tags = ["automanaged"],
deps = [
"//app/interface/main/app-view/conf:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//library/net/metadata: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,34 @@
package ai
import (
"context"
"go-common/app/interface/main/app-view/conf"
bm "go-common/library/net/http/blademaster"
"go-common/library/net/metadata"
)
const (
_av2GameURL = "/avid2gameid"
)
type Dao struct {
client *bm.Client
av2GameURL string
}
func New(c *conf.Config) (d *Dao) {
d = &Dao{
client: bm.NewClient(c.HTTPGameAsync),
av2GameURL: c.Host.AI + _av2GameURL,
}
return
}
func (d *Dao) Av2Game(c context.Context) (res map[int64]int64, err error) {
ip := metadata.String(c, metadata.RemoteIP)
if err = d.client.Get(c, d.av2GameURL, ip, nil, &res); err != nil {
return
}
return
}

View File

@@ -0,0 +1,65 @@
package ai
import (
"context"
"flag"
"path/filepath"
"reflect"
"testing"
"go-common/app/interface/main/app-view/conf"
. "github.com/smartystreets/goconvey/convey"
)
var (
d *Dao
)
func init() {
dir, _ := filepath.Abs("../../cmd/app-view-test.toml")
flag.Set("conf", dir)
conf.Init()
d = New(conf.Conf)
}
func TestNew(t *testing.T) {
type args struct {
c *conf.Config
}
tests := []struct {
name string
args args
wantD *Dao
}{
// TODO: Add test cases.
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if gotD := New(tt.args.c); !reflect.DeepEqual(gotD, tt.wantD) {
t.Errorf("New() = %v, want %v", gotD, tt.wantD)
}
})
}
}
func TestDao_Av2Game(t *testing.T) {
type args struct {
c context.Context
}
tests := []struct {
name string
args args
wantRes map[int64]int64
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
Convey(tt.name, t, func() {
gotRes, err := d.Av2Game(tt.args.c)
So(err, ShouldEqual, tt.wantErr)
So(gotRes, ShouldResemble, tt.wantRes)
})
}
}