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

Function TestCreateQuickstartApp_SPA_React

internal/cli/quickstarts_test.go:750–805  ·  view source on GitHub ↗

-- createQuickstartApp happy-path --.

(t *testing.T)

Source from the content-addressed store, hash-verified

748// -- createQuickstartApp happy-path --.
749
750func TestCreateQuickstartApp_SPA_React(t *testing.T) {
751 ctrl := gomock.NewController(t)
752 defer ctrl.Finish()
753
754 clientAPI := mock.NewMockClientAPI(ctrl)
755 clientAPI.EXPECT().
756 Create(gomock.Any(), gomock.Any()).
757 DoAndReturn(func(_ context.Context, c *management.Client, _ ...management.RequestOption) error {
758 // Simulate the management API assigning a client ID.
759 id := "test-client-id"
760 c.ClientID = &id
761 return nil
762 })
763
764 dir := t.TempDir()
765 tenantDomain := "test.auth0.com"
766 testCLI := &cli{
767 renderer: &display.Renderer{MessageWriter: &bytes.Buffer{}, ResultWriter: &bytes.Buffer{}},
768 api: &auth0.API{Client: clientAPI},
769 Config: config.Config{
770 DefaultTenant: tenantDomain,
771 Tenants: map[string]config.Tenant{
772 tenantDomain: {Domain: tenantDomain},
773 },
774 },
775 tenant: tenantDomain,
776 }
777
778 inputs := SetupInputs{
779 App: true,
780 Name: "My SPA",
781 Type: "spa",
782 Framework: "react",
783 BuildTool: "vite",
784 Port: 5173,
785 }
786
787 // Write a temp env file location.
788 inputs.CallbackURL = ""
789 inputs.LogoutURL = ""
790
791 // Override the working directory so generateAndWriteQuickstartConfig writes to a temp dir.
792 oldWD, err := os.Getwd()
793 require.NoError(t, err)
794 require.NoError(t, os.Chdir(dir))
795 defer func() { _ = os.Chdir(oldWD) }()
796
797 clientID, err := createQuickstartApp(&cobra.Command{}, testCLI, inputs, "spa:react:vite")
798 require.NoError(t, err)
799 assert.Equal(t, "test-client-id", clientID)
800
801 // Config file should have been written.
802 entries, err := os.ReadDir(dir)
803 require.NoError(t, err)
804 assert.NotEmpty(t, entries, "expected env config file to be written")
805}
806
807func TestCreateQuickstartApp_UnsupportedKey(t *testing.T) {

Callers

nothing calls this directly

Calls 4

EXPECTMethod · 0.95
NewMockClientAPIFunction · 0.92
createQuickstartAppFunction · 0.85
CreateMethod · 0.65

Tested by

no test coverage detected