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

Function TestReadMobileBundleID

internal/cli/quickstart_detect_test.go:2589–2654  ·  view source on GitHub ↗

-- readMobileBundleID --.

(t *testing.T)

Source from the content-addressed store, hash-verified

2587// -- readMobileBundleID --.
2588
2589func TestReadMobileBundleID(t *testing.T) {
2590 t.Run("reads applicationId from android/app/build.gradle (double quotes)", func(t *testing.T) {
2591 dir := t.TempDir()
2592 require.NoError(t, os.MkdirAll(filepath.Join(dir, "android", "app"), 0755))
2593 writeTestFile(t, dir, filepath.Join("android", "app", "build.gradle"),
2594 `android {
2595 defaultConfig {
2596 applicationId "com.example.myapp"
2597 minSdkVersion 21
2598 }
2599}`)
2600 assert.Equal(t, "com.example.myapp", readMobileBundleID(dir))
2601 })
2602
2603 t.Run("reads applicationId with single quotes (Groovy DSL style)", func(t *testing.T) {
2604 dir := t.TempDir()
2605 require.NoError(t, os.MkdirAll(filepath.Join(dir, "android", "app"), 0755))
2606 writeTestFile(t, dir, filepath.Join("android", "app", "build.gradle"),
2607 `android {
2608 defaultConfig {
2609 applicationId 'com.example.singlequote'
2610 minSdkVersion 21
2611 }
2612}`)
2613 assert.Equal(t, "com.example.singlequote", readMobileBundleID(dir))
2614 })
2615
2616 t.Run("falls back to project.pbxproj for iOS-only project", func(t *testing.T) {
2617 dir := t.TempDir()
2618 require.NoError(t, os.MkdirAll(filepath.Join(dir, "ios", "Runner.xcodeproj"), 0755))
2619 writeTestFile(t, dir, filepath.Join("ios", "Runner.xcodeproj", "project.pbxproj"),
2620 `PRODUCT_BUNDLE_IDENTIFIER = com.example.iosonly;`)
2621 assert.Equal(t, "com.example.iosonly", readMobileBundleID(dir))
2622 })
2623
2624 t.Run("falls back to Info.plist when project.pbxproj absent", func(t *testing.T) {
2625 dir := t.TempDir()
2626 require.NoError(t, os.MkdirAll(filepath.Join(dir, "ios", "Runner"), 0755))
2627 writeTestFile(t, dir, filepath.Join("ios", "Runner", "Info.plist"),
2628 `<key>CFBundleIdentifier</key><string>com.example.infoplist</string>`)
2629 assert.Equal(t, "com.example.infoplist", readMobileBundleID(dir))
2630 })
2631
2632 t.Run("Info.plist with Xcode variable reference returns empty (falls through)", func(t *testing.T) {
2633 dir := t.TempDir()
2634 require.NoError(t, os.MkdirAll(filepath.Join(dir, "ios", "Runner"), 0755))
2635 writeTestFile(t, dir, filepath.Join("ios", "Runner", "Info.plist"),
2636 `<key>CFBundleIdentifier</key><string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>`)
2637 assert.Empty(t, readMobileBundleID(dir))
2638 })
2639
2640 t.Run("no build.gradle and no iOS files returns empty", func(t *testing.T) {
2641 assert.Empty(t, readMobileBundleID(t.TempDir()))
2642 })
2643
2644 t.Run("build.gradle without applicationId falls back to iOS", func(t *testing.T) {
2645 dir := t.TempDir()
2646 require.NoError(t, os.MkdirAll(filepath.Join(dir, "android", "app"), 0755))

Callers

nothing calls this directly

Calls 2

writeTestFileFunction · 0.85
readMobileBundleIDFunction · 0.85

Tested by

no test coverage detected