(t *testing.T)
| 15 | ) |
| 16 | |
| 17 | func TestAppsListCmd(t *testing.T) { |
| 18 | tests := []struct { |
| 19 | name string |
| 20 | assertOutput func(t testing.TB, out string) |
| 21 | args []string |
| 22 | }{ |
| 23 | { |
| 24 | name: "happy path", |
| 25 | assertOutput: func(t testing.TB, out string) { |
| 26 | expectTable(t, out, |
| 27 | []string{"CLIENT ID", "NAME", "TYPE", "RESOURCE SERVER"}, |
| 28 | [][]string{ |
| 29 | {"some-id", "some-name", "Generic", ""}, |
| 30 | }, |
| 31 | ) |
| 32 | }, |
| 33 | }, |
| 34 | { |
| 35 | name: "reveal secrets", |
| 36 | args: []string{"--reveal-secrets"}, |
| 37 | assertOutput: func(t testing.TB, out string) { |
| 38 | expectTable(t, out, |
| 39 | []string{"CLIENT ID", "NAME", "TYPE", "CLIENT SECRET", "RESOURCE SERVER"}, |
| 40 | [][]string{ |
| 41 | {"some-id", "some-name", "Generic", "secret-here", ""}, |
| 42 | }, |
| 43 | ) |
| 44 | }, |
| 45 | }, |
| 46 | } |
| 47 | |
| 48 | for _, test := range tests { |
| 49 | t.Run(test.name, func(t *testing.T) { |
| 50 | // Step 1: Setup our client mock for this test. We only care about |
| 51 | // Clients so no need to bootstrap other bits. |
| 52 | ctrl := gomock.NewController(t) |
| 53 | defer ctrl.Finish() |
| 54 | |
| 55 | clientAPI := mock.NewMockClientAPI(ctrl) |
| 56 | clientAPI.EXPECT(). |
| 57 | List(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()). |
| 58 | Return(&management.ClientList{ |
| 59 | Clients: []*management.Client{ |
| 60 | { |
| 61 | Name: auth0.String("some-name"), |
| 62 | ClientID: auth0.String("some-id"), |
| 63 | Callbacks: &[]string{"http://localhost"}, |
| 64 | ClientSecret: auth0.String("secret-here"), |
| 65 | }, |
| 66 | }, |
| 67 | }, nil) |
| 68 | |
| 69 | stdout := &bytes.Buffer{} |
| 70 | |
| 71 | // Step 2: Setup our cli context. The important bits are |
| 72 | // renderer and api. |
| 73 | cli := &cli{ |
| 74 | renderer: &display.Renderer{ |
nothing calls this directly
no test coverage detected