(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func 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(). |
nothing calls this directly
no test coverage detected