MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestNewControllerClient

Function TestNewControllerClient

pkg/controller/client/rpc_test.go:40–61  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38const ErrorServerHost = "http:/%%a.easyfaas.com/just/a/path"
39
40func TestNewControllerClient(t *testing.T) {
41 ds := []struct {
42 host string
43 err error
44 }{
45 {host: ServerHost, err: nil},
46 {host: ErrorServerHost, err: InvaildConfigError{Reason: fmt.Sprintf("invaild host %s", ErrorServerHost)}},
47 }
48 for _, item := range ds {
49 pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)
50 opt := NewControllerClientOptions()
51 opt.AddFlags(pflag.CommandLine)
52 pflag.Set("controller-host", item.host)
53 flag.InitFlags()
54 fmt.Println(opt.Host)
55 _, err := NewControllerClient(opt)
56 t.Logf("err = %+v", err)
57 if item.err != err {
58 t.Errorf("new controller client expect err %+v, but got %+v", item.err, err)
59 }
60 }
61}
62
63func TestInvoke(t *testing.T) {
64 pflag.CommandLine = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)

Callers

nothing calls this directly

Calls 6

AddFlagsMethod · 0.95
InitFlagsFunction · 0.92
NewControllerClientFunction · 0.85
ErrorfMethod · 0.80
SetMethod · 0.65

Tested by

no test coverage detected