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,42 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = ["white.go"],
importpath = "go-common/app/interface/main/app-resource/service/white",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//app/interface/main/app-resource/conf: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"],
)
go_test(
name = "go_default_test",
srcs = ["white_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = [
"//app/interface/main/app-resource/conf:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)

View File

@@ -0,0 +1,26 @@
package white
import (
"go-common/app/interface/main/app-resource/conf"
)
// Service white service.
type Service struct {
c *conf.Config
listCache map[string][]string
}
// New new a interest service.
func New(c *conf.Config) (s *Service) {
s = &Service{
c: c,
listCache: c.White.List,
}
return
}
// List white list
func (s *Service) List() (res map[string][]string) {
res = s.listCache
return
}

View File

@@ -0,0 +1,37 @@
package white
import (
"flag"
"path/filepath"
"testing"
"time"
"go-common/app/interface/main/app-resource/conf"
. "github.com/smartystreets/goconvey/convey"
)
var (
s *Service
)
func WithService(f func(s *Service)) func() {
return func() {
f(s)
}
}
func init() {
dir, _ := filepath.Abs("../../cmd/app-resource-test.toml")
flag.Set("conf", dir)
conf.Init()
s = New(conf.Conf)
time.Sleep(time.Second)
}
func TestList(t *testing.T) {
Convey("get List data", t, WithService(func(s *Service) {
res := s.List()
So(res, ShouldNotBeEmpty)
}))
}