MCPcopy Create free account
hub / github.com/algolia/cli / TestGetComposition

Function TestGetComposition

pkg/cmd/compositions/get/get_test.go:15–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestGetComposition(t *testing.T) {
16 tests := []struct {
17 name string
18 cli string
19 mock string
20 wantOut string
21 }{
22 {
23 name: "composition with injection behavior",
24 cli: "my-comp",
25 mock: `{"objectID":"my-comp","name":"My Comp","behavior":{"injection":{"main":{}}}}`,
26 wantOut: `{"behavior":{"injection":{"main":{}}},"name":"My Comp","objectID":"my-comp"}`,
27 },
28 }
29
30 for _, tt := range tests {
31 t.Run(tt.name, func(t *testing.T) {
32 r := &httpmock.Registry{}
33 r.Register(
34 httpmock.REST("GET", "1/compositions/my-comp"),
35 httpmock.StringResponse(tt.mock),
36 )
37
38 f, out := test.NewFactory(false, r, nil, "")
39 cmd := get.NewGetCmd(f)
40 _, err := test.Execute(cmd, tt.cli, out)
41 require.NoError(t, err)
42
43 assert.JSONEq(t, tt.wantOut, strings.TrimSpace(out.String()))
44 r.Verify(t)
45 })
46 }
47}
48
49func TestGetComposition_MissingArg(t *testing.T) {
50 r := &httpmock.Registry{}

Callers

nothing calls this directly

Calls 9

RegisterMethod · 0.95
VerifyMethod · 0.95
RESTFunction · 0.92
StringResponseFunction · 0.92
NewFactoryFunction · 0.92
NewGetCmdFunction · 0.92
ExecuteFunction · 0.92
RunMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected