(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestActionsDeployCmd(t *testing.T) { |
| 21 | t.Run("it successfully deploys an action", func(t *testing.T) { |
| 22 | actionID := "1221c74c-cfd6-40db-af13-7bc9bb1c38db" |
| 23 | ctrl := gomock.NewController(t) |
| 24 | defer ctrl.Finish() |
| 25 | |
| 26 | actionAPI := mock.NewMockActionAPI(ctrl) |
| 27 | actionAPI.EXPECT(). |
| 28 | Deploy(context.Background(), actionID). |
| 29 | Return(nil, nil) |
| 30 | |
| 31 | actionAPI.EXPECT(). |
| 32 | Read(context.Background(), actionID). |
| 33 | Return(&management.Action{ |
| 34 | ID: auth0.String(actionID), |
| 35 | Name: auth0.String("actions-deploy"), |
| 36 | SupportedTriggers: []management.ActionTrigger{ |
| 37 | { |
| 38 | ID: auth0.String("post-login"), |
| 39 | }, |
| 40 | }, |
| 41 | Code: auth0.String("function () {}"), |
| 42 | DeployedVersion: &management.ActionVersion{ |
| 43 | Deployed: true, |
| 44 | }, |
| 45 | Status: auth0.String("built"), |
| 46 | }, nil) |
| 47 | |
| 48 | stdout := &bytes.Buffer{} |
| 49 | cli := &cli{ |
| 50 | renderer: &display.Renderer{ |
| 51 | MessageWriter: io.Discard, |
| 52 | ResultWriter: stdout, |
| 53 | }, |
| 54 | api: &auth0.API{Action: actionAPI}, |
| 55 | } |
| 56 | |
| 57 | cmd := deployActionCmd(cli) |
| 58 | cmd.SetArgs([]string{actionID}) |
| 59 | err := cmd.Execute() |
| 60 | |
| 61 | assert.NoError(t, err) |
| 62 | expectTable(t, stdout.String(), |
| 63 | []string{}, |
| 64 | [][]string{ |
| 65 | {"ID 1221c74c-cfd6-40db-af13-7bc9bb1c38db"}, |
| 66 | {"NAME actions-deploy"}, |
| 67 | {"TYPE post-login"}, |
| 68 | {"STATUS built"}, |
| 69 | {"DEPLOYED ✓"}, |
| 70 | {"LAST DEPLOYED"}, |
| 71 | {"LAST UPDATED Jan 01 0001"}, |
| 72 | {"CREATED Jan 01 0001"}, |
| 73 | {"CODE function () {}"}, |
| 74 | }, |
| 75 | ) |
| 76 | }) |
| 77 |
nothing calls this directly
no test coverage detected