github.com/saucelabs/saucectl@v0.175.1/internal/saucecloud/testcafe_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/testcafe" 8 "github.com/stretchr/testify/assert" 9 ) 10 11 func TestTestcafe_GetSuiteNames(t *testing.T) { 12 runner := &TestcafeRunner{ 13 Project: testcafe.Project{ 14 Suites: []testcafe.Suite{ 15 {Name: "suite1"}, 16 {Name: "suite2"}, 17 {Name: "suite3"}, 18 }, 19 }, 20 } 21 22 assert.Equal(t, []string{"suite1", "suite2", "suite3"}, runner.getSuiteNames()) 23 } 24 25 func Test_calcTestcafeJobsCount(t *testing.T) { 26 testCases := []struct { 27 name string 28 suites []testcafe.Suite 29 expectedJobsCount int 30 }{ 31 { 32 name: "single suite", 33 suites: []testcafe.Suite{ 34 { 35 Name: "single suite", 36 }, 37 }, 38 expectedJobsCount: 1, 39 }, 40 { 41 name: "two suites", 42 suites: []testcafe.Suite{ 43 { 44 Name: "first suite", 45 }, 46 { 47 Name: "second suite", 48 }, 49 }, 50 expectedJobsCount: 2, 51 }, 52 { 53 name: "suites with simulators and platfrom versions", 54 suites: []testcafe.Suite{ 55 { 56 Name: "first suite", 57 }, 58 { 59 Name: "second suite", 60 }, 61 { 62 Name: "suite with one simulator and two platforms", 63 Simulators: []config.Simulator{ 64 {PlatformVersions: []string{"12.0", "14.3"}}, 65 }, 66 }, 67 { 68 Name: "suite with two simulators and two platforms", 69 Simulators: []config.Simulator{ 70 {PlatformVersions: []string{"12.0", "14.3"}}, 71 {PlatformVersions: []string{"12.0", "14.3"}}, 72 }, 73 }, 74 }, 75 expectedJobsCount: 8, 76 }, 77 } 78 79 for _, tc := range testCases { 80 t.Run(tc.name, func(t *testing.T) { 81 tr := TestcafeRunner{} 82 got := tr.calcTestcafeJobsCount(tc.suites) 83 if tc.expectedJobsCount != got { 84 t.Errorf("expected: %d, got: %d", tc.expectedJobsCount, got) 85 } 86 }) 87 } 88 }