github.com/saucelabs/saucectl@v0.175.1/internal/saucecloud/espresso_test.go (about) 1 package saucecloud 2 3 import ( 4 "testing" 5 6 "github.com/saucelabs/saucectl/internal/config" 7 "github.com/saucelabs/saucectl/internal/espresso" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestEspressoRunner_CalculateJobCount(t *testing.T) { 12 tests := []struct { 13 name string 14 suites []espresso.Suite 15 wants int 16 }{ 17 { 18 name: "should multiply emulator combinations", 19 suites: []espresso.Suite{ 20 { 21 Name: "valid espresso project", 22 Emulators: []config.Emulator{ 23 { 24 Name: "Android GoogleApi Emulator", 25 PlatformVersions: []string{"11.0", "10.0"}, 26 }, 27 { 28 Name: "Android Emulator", 29 PlatformVersions: []string{"11.0"}, 30 }, 31 }, 32 }, 33 }, 34 wants: 3, 35 }, 36 { 37 name: "should multiply jobs by NumShards if defined", 38 wants: 18, 39 suites: []espresso.Suite{ 40 { 41 Name: "first suite", 42 TestOptions: map[string]interface{}{ 43 "numShards": 3, 44 }, 45 Emulators: []config.Emulator{ 46 { 47 Name: "Android GoogleApi Emulator", 48 PlatformVersions: []string{"11.0", "10.0"}, 49 }, 50 { 51 Name: "Android Emulator", 52 PlatformVersions: []string{"11.0"}, 53 }, 54 }, 55 }, 56 { 57 Name: "second suite", 58 TestOptions: map[string]interface{}{ 59 "numShards": 3, 60 }, 61 Emulators: []config.Emulator{ 62 { 63 Name: "Android GoogleApi Emulator", 64 PlatformVersions: []string{"11.0", "10.0"}, 65 }, 66 { 67 Name: "Android Emulator", 68 PlatformVersions: []string{"11.0"}, 69 }, 70 }, 71 }, 72 }, 73 }, 74 } 75 76 for _, tt := range tests { 77 runner := &EspressoRunner{ 78 Project: espresso.Project{ 79 Espresso: espresso.Espresso{ 80 App: "/path/to/app.apk", 81 TestApp: "/path/to/testApp.apk", 82 }, 83 Suites: tt.suites, 84 }, 85 } 86 87 assert.Equal(t, runner.calculateJobsCount(runner.Project.Suites), tt.wants) 88 } 89 }