MCPcopy
hub / github.com/larksuite/cli / TestRegisterService

Function TestRegisterService

cmd/service/service_test.go:55–91  ·  view source on GitHub ↗

── registerService ──

(t *testing.T)

Source from the content-addressed store, hash-verified

53// ── registerService ──
54
55func TestRegisterService(t *testing.T) {
56 parent := &cobra.Command{Use: "root"}
57 f := &cmdutil.Factory{}
58 base := meta.ServiceFromMap(map[string]interface{}{
59 "name": "base",
60 "description": "Base API",
61 "servicePath": "/open-apis/base/v3",
62 "resources": map[string]interface{}{
63 "tables": map[string]interface{}{
64 "methods": map[string]interface{}{
65 "list": map[string]interface{}{
66 "description": "List tables",
67 "httpMethod": "GET",
68 },
69 },
70 },
71 },
72 })
73
74 registerService(parent, base, f)
75
76 // service command exists
77 svc, _, err := parent.Find([]string{"base"})
78 if err != nil || svc.Name() != "base" {
79 t.Fatalf("expected 'base' command, got err=%v", err)
80 }
81 // resource sub-command
82 res, _, err := parent.Find([]string{"base", "tables"})
83 if err != nil || res.Name() != "tables" {
84 t.Fatalf("expected 'tables' command, got err=%v", err)
85 }
86 // method sub-command
87 meth, _, err := parent.Find([]string{"base", "tables", "list"})
88 if err != nil || meth.Name() != "list" {
89 t.Fatalf("expected 'list' command, got err=%v", err)
90 }
91}
92
93func TestRegisterService_MergesExistingCommand(t *testing.T) {
94 parent := &cobra.Command{Use: "root"}

Callers

nothing calls this directly

Calls 3

ServiceFromMapFunction · 0.92
registerServiceFunction · 0.85
NameMethod · 0.65

Tested by

no test coverage detected