MCPcopy Create free account
hub / github.com/auth0/auth0-cli / TestTailLogsCommand

Function TestTailLogsCommand

internal/cli/logs_test.go:19–105  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

17)
18
19func TestTailLogsCommand(t *testing.T) {
20 t.Run("it returns an error when it fails to get the logs on the first request", func(t *testing.T) {
21 ctrl := gomock.NewController(t)
22 defer ctrl.Finish()
23
24 logsAPI := mock.NewMockLogAPI(ctrl)
25 logsAPI.EXPECT().
26 List(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
27 Return(nil, fmt.Errorf("generic error"))
28
29 cli := &cli{
30 api: &auth0.API{Log: logsAPI},
31 }
32
33 cmd := tailLogsCmd(cli)
34 cmd.SetArgs([]string{"--number", "90", "--filter", "user_id:123"})
35 err := cmd.Execute()
36
37 assert.EqualError(t, err, "failed to list logs: generic error")
38 })
39
40 t.Run("it returns an error when it fails to get the logs on the 3rd request", func(t *testing.T) {
41 ctrl := gomock.NewController(t)
42 defer ctrl.Finish()
43
44 logsAPI := mock.NewMockLogAPI(ctrl)
45 logsAPI.EXPECT().
46 List(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
47 Return(
48 []*management.Log{
49 {
50 LogID: auth0.String("354234"),
51 Type: auth0.String("sapi"),
52 Description: auth0.String("Update branding settings"),
53 },
54 },
55 nil,
56 )
57
58 logsAPI.EXPECT().
59 List(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).
60 Return(
61 []*management.Log{
62 {
63 LogID: auth0.String("354234"),
64 Type: auth0.String("sapi"),
65 Description: auth0.String("Update branding settings"),
66 },
67 {
68 LogID: auth0.String("354236"),
69 Type: auth0.String("sapi"),
70 Description: auth0.String("Update tenant settings"),
71 },
72 },
73 nil,
74 )
75
76 logsAPI.EXPECT().

Callers

nothing calls this directly

Calls 5

EXPECTMethod · 0.95
NewMockLogAPIFunction · 0.92
tailLogsCmdFunction · 0.85
ErrorfMethod · 0.80
ListMethod · 0.65

Tested by

no test coverage detected