prepared new version to 0.11.0 with async tc client support

This commit is contained in:
Jan Halfar 2018-06-12 14:27:42 +02:00
parent 53c62c5a68
commit a528dd802b
5 changed files with 45 additions and 6 deletions

View File

@ -21,5 +21,6 @@ goreleaser:
glide:
@go get github.com/Masterminds/glide && glide install
test: demo
go test $(glide nv)
test:
go test -v ./...

View File

@ -4,6 +4,7 @@ import (
"fmt"
"io/ioutil"
"net/http"
"os/exec"
"strings"
"github.com/foomo/gotsrpc/demo"
@ -41,6 +42,13 @@ func main() {
d := &Demo{
proxy: demo.NewDefaultDemoGoTSRPCProxy(&demo.Demo{}, []string{}),
}
fmt.Println("staring a demo on http://127.0.0.1:8080 - open it and take a look at the console")
fmt.Println("starting a demo server on http://127.0.0.1:8080 - open it and take a look at the console")
cmd := exec.Command("open", "http://127.0.0.1:8080")
go func() {
err := cmd.Run()
if err != nil {
fmt.Println("tried to open things with you default browser - did fail", err)
}
}()
fmt.Println(http.ListenAndServe(":8080", d))
}

View File

@ -10,7 +10,7 @@ import (
"github.com/foomo/gotsrpc/config"
)
const Version = "0.10.0"
const Version = "0.11.0"
func jsonDump(v interface{}) {
jsonBytes, err := json.MarshalIndent(v, "", " ")

View File

@ -89,6 +89,8 @@ func LoadConfigFile(file string) (conf *Config, err error) {
return loadConfig(yamlBytes)
}
var ErrInvalidTSClientFlavor = errors.New(fmt.Sprintln("unknown ts client flavor: must be empty or ", TSClientFlavorAsync))
func loadConfig(yamlBytes []byte) (conf *Config, err error) {
conf = &Config{}
yamlErr := yaml.Unmarshal(yamlBytes, conf)
@ -99,13 +101,13 @@ func loadConfig(yamlBytes []byte) (conf *Config, err error) {
switch conf.TSClientFlavor {
case "", TSClientFlavorAsync:
default:
err = errors.New("unknown ts client flavor: " + conf.TSClientFlavor + " must be empty or " + TSClientFlavorAsync)
err = ErrInvalidTSClientFlavor
return
}
switch conf.ModuleKind {
case ModuleKindCommonJS, ModuleKindDefault:
case "":
conf.ModuleKind = ModuleKindDefault
default:
err = errors.New(fmt.Sprintln("illegal module kind:", conf.ModuleKind, "must be in", ModuleKindDefault, ModuleKindCommonJS))
return

View File

@ -60,4 +60,32 @@ func TestLoadConfig(t *testing.T) {
if demoTarget.Services["/service/demo"] != "Service" {
t.Fatal("first service is wrong")
}
}
const sampleConfInvalidClientFlavor = `---
tsclientflavor: asynci
targets:
demo:
services:
/service/demo: Service
package: github.com/foomo/gotsrpc/demo
module: My.Service
modulekind: commonjs
out: /tmp/my-service.ts
mappings:
foo/bar:
module: Sample.Module
out: path/to/ts
github.com/foomo/gotsrpc:
module: Sample.Module.RPC
out: path/to/other/folder
`
func TestLoadConfigInvalidClientFlavor(t *testing.T) {
_, err := loadConfig([]byte(sampleConfInvalidClientFlavor))
if err == nil {
t.Fatal("that config must be invalid")
}
}