-
Notifications
You must be signed in to change notification settings - Fork 25
/
tests.go
780 lines (677 loc) · 19.5 KB
/
tests.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
package main
import (
"errors"
"fmt"
"log"
"os"
"path/filepath"
"regexp"
"strconv"
"strings"
"github.com/gyuho/goraph"
"github.com/rainforestapp/rainforest-cli/rainforest"
"github.com/satori/go.uuid"
"github.com/urfave/cli"
)
// parseError is a custom error implementing error interface for reporting RFML parsing errors.
type fileParseError struct {
filePath string
parseError error
}
func (e fileParseError) Error() string {
return fmt.Sprintf("%v: %v", e.filePath, e.parseError.Error())
}
// validateRFML is a wrapper around two other validation functions
// first one for the single file and the other for whole directory
func validateRFML(c cliContext, api rfAPI) error {
if path := c.Args().First(); path != "" {
err := validateSingleRFMLFile(path)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
tests, err := readRFMLFiles([]string{c.String("test-folder")})
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = validateRFMLFiles(tests, false, api)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
// readRFMLFiles takes in a list of files and/or directories and
// returns a list of the parsed tests, or an error if it is encountered.
func readRFMLFiles(files []string) ([]*rainforest.RFTest, error) {
fileList := []string{}
for _, file := range files {
stat, err := os.Stat(file)
if err != nil {
return nil, err
}
if !stat.IsDir() {
if strings.HasSuffix(file, ".rfml") {
fileList = append(fileList, file)
continue
} else {
log.Printf("%s is not a valid RFML file", file)
continue
}
}
// We have a directory, walk through and find RFML files
err = filepath.WalkDir(file, func(path string, d os.DirEntry, err error) error {
if strings.HasSuffix(path, ".rfml") {
fileList = append(fileList, path)
}
return nil
})
if err != nil {
return nil, err
}
}
tests := []*rainforest.RFTest{}
seenPaths := map[string]bool{}
for _, filePath := range fileList {
// No dups!
if seenPaths[filePath] {
continue
}
seenPaths[filePath] = true
test, err := readRFMLFile(filePath)
if err != nil {
return nil, err
}
tests = append(tests, test)
}
return tests, nil
}
// anyMember is one of those things that would probably be in the stdlib if
// there were generics. I hate golang sometimes. In any case, it returns true if
// any of needles are in haystack. It's O(n*m), so only put small stuff in
// there!
func anyMember(haystack []string, needles []string) bool {
for _, n := range needles {
for _, h := range haystack {
if h == n {
return true
}
}
}
return false
}
func readRFMLFile(filePath string) (*rainforest.RFTest, error) {
f, err := os.Open(filePath)
if err != nil {
return nil, err
}
defer f.Close()
rfmlReader := rainforest.NewRFMLReader(f)
var pTest *rainforest.RFTest
pTest, err = rfmlReader.ReadAll()
if err != nil {
return nil, fileParseError{filePath, err}
}
pTest.RFMLPath = filePath
return pTest, err
}
// validateSingleRFMLFile validates RFML file syntax by
// trying to parse the file and sending any parse errors to the caller
func validateSingleRFMLFile(filePath string) error {
if !strings.Contains(filePath, ".rfml") {
return errors.New("RFML files should have .rfml extension")
}
f, err := os.Open(filePath)
if err != nil {
return err
}
defer f.Close()
rfmlReader := rainforest.NewRFMLReader(f)
_, err = rfmlReader.ReadAll()
if err != nil {
return fileParseError{filePath, err}
}
log.Printf("%v's syntax is valid", filePath)
return nil
}
var errValidation = errors.New("Validation failed")
// validateRFMLFiles validates RFML file syntax, embedded rfml ids, checks for
// circular dependiences and all other cool things in the specified directory
func validateRFMLFiles(parsedTests []*rainforest.RFTest, localOnly bool, api rfAPI) error {
// parse all of them files
var validationErrors []error
var err error
dependencyGraph := goraph.NewGraph()
// check for rfml_id uniqueness
rfmlIDToTest := make(map[string]*rainforest.RFTest)
for _, pTest := range parsedTests {
if conflictingTest, ok := rfmlIDToTest[pTest.RFMLID]; ok {
err = fmt.Errorf(" duplicate RFML id %v, also found in: %v", pTest.RFMLID, conflictingTest.RFMLPath)
validationErrors = append(validationErrors, fileParseError{pTest.RFMLPath, err})
} else {
rfmlIDToTest[pTest.RFMLID] = pTest
dependencyGraph.AddNode(goraph.NewNode(pTest.RFMLID))
}
}
// check for embedded tests id validity
// start with pulling the external test ids to validate against them as well
if !localOnly && api.ClientToken() != "" {
externalTests, err := api.GetTestIDs()
if err != nil {
return err
}
for _, externalTest := range externalTests {
if _, ok := rfmlIDToTest[externalTest.RFMLID]; !ok {
rfmlIDToTest[externalTest.RFMLID] = &rainforest.RFTest{}
dependencyGraph.AddNode(goraph.NewNode(externalTest.RFMLID))
}
}
}
// go through all the tests
for _, pTest := range parsedTests {
// and steps...
for stepNum, step := range pTest.Steps {
// then check if it's embeddedTest
if embeddedTest, ok := step.(rainforest.RFEmbeddedTest); ok {
// if so, check if its rfml id exists
if _, ok := rfmlIDToTest[embeddedTest.RFMLID]; !ok {
if localOnly || api.ClientToken() != "" {
err = fmt.Errorf("step %v - embeddedTest RFML id %v not found", stepNum+1, embeddedTest.RFMLID)
} else {
err = fmt.Errorf("step %v - embeddedTest RFML id %v not found. Specify token_id to check against external tests", stepNum+1, embeddedTest.RFMLID)
}
validationErrors = append(validationErrors, fileParseError{pTest.RFMLPath, err})
} else {
pNode := dependencyGraph.GetNode(goraph.StringID(pTest.RFMLID))
eNode := dependencyGraph.GetNode(goraph.StringID(embeddedTest.RFMLID))
dependencyGraph.AddEdge(pNode.ID(), eNode.ID(), 1)
}
}
}
}
// validate circular dependiences probably using Tarjan's strongly connected components
stronglyConnected := goraph.Tarjan(dependencyGraph)
for _, circularTests := range stronglyConnected {
if len(circularTests) > 1 {
err = fmt.Errorf("Found circular dependiences between: %v", circularTests)
validationErrors = append(validationErrors, err)
}
}
if len(validationErrors) > 0 {
for _, err := range validationErrors {
log.Print(err.Error())
}
return errValidation
}
log.Print("All files are valid!")
return nil
}
func newRFMLTest(c cliContext) error {
testDirectory := c.String("test-folder")
absTestDirectory, err := prepareTestDirectory(testDirectory)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
fileName := c.Args().First()
title := fileName
if fileName == "" {
fileName = "Unnamed Test.rfml"
title = "Unnamed Test"
} else if strings.HasSuffix(fileName, ".rfml") {
title = strings.TrimSuffix(title, ".rfml")
} else {
fileName = fileName + ".rfml"
}
filePath := filepath.Join(absTestDirectory, fileName)
// Make sure that the file is unique
basePath := strings.TrimSuffix(filePath, ".rfml")
fileIdentifier := 0
var identStr string
for {
if fileIdentifier == 0 {
identStr = ""
} else {
identStr = fmt.Sprintf(" (%v)", strconv.Itoa(fileIdentifier))
}
testPath := basePath + identStr + ".rfml"
_, err = os.Stat(testPath)
if !os.IsNotExist(err) {
fileIdentifier = fileIdentifier + 1
} else {
filePath = testPath
break
}
}
test := rainforest.RFTest{
RFMLID: uuid.NewV4().String(),
Title: title,
StartURI: "/",
Type: "test",
Execute: true,
Steps: []interface{}{
rainforest.RFTestStep{
Action: "This is a step action.",
Response: "This is a step question?",
Redirect: true,
},
rainforest.RFTestStep{
Action: "This is another step action.",
Response: "This is another step question?",
Redirect: true,
},
},
}
f, err := os.Create(filePath)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
writer := rainforest.NewRFMLWriter(f)
err = writer.WriteRFMLTest(&test)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
func deleteRFML(c cliContext) error {
filePath := c.Args().First()
if !strings.Contains(filePath, ".rfml") {
return cli.NewExitError("RFML files should have .rfml extension", 1)
}
f, err := os.Open(filePath)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
rfmlReader := rainforest.NewRFMLReader(f)
parsedRFML, err := rfmlReader.ReadAll()
if err != nil {
errMsg := fmt.Sprintf("Error removing test at '%v': %v", filePath, err.Error())
return cli.NewExitError(errMsg, 1)
}
if parsedRFML.RFMLID == "" {
return cli.NewExitError("RFML file doesn't have RFML ID", 1)
}
// Close the file now so we can delete it
f.Close()
// Delete remote first
err = api.DeleteTestByRFMLID(parsedRFML.RFMLID)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
// Then delete local file
err = os.Remove(filePath)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
// uploadTests is a wrapper around test creating/updating functions
func uploadTests(c cliContext, api rfAPI) error {
if c.Bool("synchronous-upload") {
rfmlUploadConcurrency = 1
}
var err error
var branchID int
branchName := c.String("branch")
branchName = strings.TrimSpace(branchName)
if branchName != "" {
branchID, err = getBranchID(branchName, api)
} else {
branchID = 0
err = nil
}
if err != nil {
return err
}
if path := c.Args().First(); path != "" {
err := uploadSingleRFMLFile(path, branchID, api)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
tests, err := readRFMLFiles([]string{c.String("test-folder")})
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
err = uploadRFMLFiles(tests, branchID, false, api)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
return nil
}
// uploadSingleRFMLFile uploads RFML file syntax by
// trying to parse the file and sending any parse errors to the caller
func uploadSingleRFMLFile(filePath string, branchID int, api rfAPI) error {
// Validate first before uploading
err := validateSingleRFMLFile(filePath)
if err != nil {
return err
}
f, err := os.Open(filePath)
if err != nil {
return err
}
defer f.Close()
rfmlReader := rainforest.NewRFMLReader(f)
parsedTest, err := rfmlReader.ReadAll()
if err != nil {
return fileParseError{filePath, err}
}
parsedTest.RFMLPath = filePath
// Check if the test already exists in RF so we can decide between updating and creating new one
testIDPairs, err := api.GetTestIDs()
if err != nil {
return err
}
testIDCollection := rainforest.NewTestIDCollection(testIDPairs)
testID, err := testIDCollection.GetTestID(parsedTest.RFMLID)
if err != nil {
// Create an empty test
log.Printf("Creating new test: %v", parsedTest.RFMLID)
emptyTest := rainforest.RFTest{
RFMLID: parsedTest.RFMLID,
Title: parsedTest.Title,
Type: parsedTest.Type,
}
err = emptyTest.PrepareToUploadFromRFML(*testIDCollection)
if err != nil {
return err
}
err = api.CreateTest(&emptyTest)
if err != nil {
return err
}
log.Printf("Created new test: %v", parsedTest.RFMLID)
// Refresh collection with new test IDs
testIDPairs, err = api.GetTestIDs()
if err != nil {
return err
}
testIDCollection = rainforest.NewTestIDCollection(testIDPairs)
// Assign test ID
testID, err = testIDCollection.GetTestID(parsedTest.RFMLID)
if err != nil {
panic(fmt.Sprintf("Unable to map RFML ID to a primary ID: %v", parsedTest.RFMLID))
} else {
parsedTest.TestID = testID
}
} else {
parsedTest.TestID = testID
}
if parsedTest.HasUploadableFiles() {
err = api.ParseEmbeddedFiles(parsedTest)
if err != nil {
return err
}
}
err = parsedTest.PrepareToUploadFromRFML(*testIDCollection)
if err != nil {
return err
}
// Update the steps
log.Printf("Updating steps for test: %v", parsedTest.RFMLID)
err = api.UpdateTest(parsedTest, branchID)
if err != nil {
return err
}
return nil
}
func uploadRFMLFiles(tests []*rainforest.RFTest, branchID int, localOnly bool, api rfAPI) error {
err := validateRFMLFiles(tests, localOnly, api)
if err != nil {
return err
}
// walk through the specifed directory (also subdirs) and pick the .rfml files
// This will be used over and over again
testIDs, err := api.GetTestIDs()
if err != nil {
return err
}
testIDCollection := rainforest.NewTestIDCollection(testIDs)
var newTests []*rainforest.RFTest
var parsedTests []*rainforest.RFTest
for _, pTest := range tests {
parsedTests = append(parsedTests, pTest)
// Check if it's a new test or an existing one, because they need different treatment
// to ensure we first add new ones and have IDs for potential embedds
_, err = testIDCollection.GetTestID(pTest.RFMLID)
if err != nil {
newTests = append(newTests, pTest)
}
}
// chan to gather errors from workers
errorsChan := make(chan error)
// prepare empty tests to upload, we will fill the steps later on in case there are some
// dependencies between them, we want all of the IDs in place
testsToCreate := make(chan *rainforest.RFTest, len(newTests))
for _, newTest := range newTests {
emptyTest := rainforest.RFTest{
RFMLID: newTest.RFMLID,
Description: newTest.Description,
Title: newTest.Title,
Type: newTest.Type,
}
err = emptyTest.PrepareToUploadFromRFML(*testIDCollection)
if err != nil {
return err
}
testsToCreate <- &emptyTest
}
close(testsToCreate)
// spawn workers to create the tests
for i := 0; i < rfmlUploadConcurrency; i++ {
go testCreationWorker(api, testsToCreate, errorsChan)
}
// Read out the workers results
for i := 0; i < len(newTests); i++ {
if err := <-errorsChan; err != nil {
return err
}
}
// Refresh the collection with new test IDs so we have all of the new tests
testIDs, err = api.GetTestIDs()
if err != nil {
return err
}
testIDCollection = rainforest.NewTestIDCollection(testIDs)
// And here we update all of the tests
testsToUpdate := make(chan *rainforest.RFTest, len(parsedTests))
for _, testToUpdate := range parsedTests {
testID, err := testIDCollection.GetTestID(testToUpdate.RFMLID)
if err != nil {
panic(fmt.Sprintf("Unable to map RFML ID to primary ID: %v", testToUpdate.RFMLID))
} else {
testToUpdate.TestID = testID
}
if testToUpdate.HasUploadableFiles() {
err = api.ParseEmbeddedFiles(testToUpdate)
if err != nil {
return err
}
}
err = testToUpdate.PrepareToUploadFromRFML(*testIDCollection)
if err != nil {
return err
}
testsToUpdate <- testToUpdate
}
close(testsToUpdate)
// spawn workers to create the tests
for i := 0; i < rfmlUploadConcurrency; i++ {
go testUpdateWorker(api, testsToUpdate, branchID, errorsChan)
}
// Read out the workers results
for i := 0; i < len(parsedTests); i++ {
if err := <-errorsChan; err != nil {
return err
}
}
return nil
}
type RFTestInfo struct {
ID int
HasWisp bool
}
type rfAPI interface {
GetTestIDs() ([]rainforest.TestIDPair, error)
GetTests(*rainforest.RFTestFilters) ([]rainforest.RFTest, error)
GetTest(int) (*rainforest.RFTest, error)
CreateTest(*rainforest.RFTest) error
UpdateTest(*rainforest.RFTest, int) error
ParseEmbeddedFiles(*rainforest.RFTest) error
ClientToken() string
branchAPI
}
func downloadTests(c cliContext, client rfAPI) error {
testDirectory := c.String("test-folder")
absTestDirectory, err := prepareTestDirectory(testDirectory)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
var testInfos []RFTestInfo
var tests []rainforest.RFTest
var filters rainforest.RFTestFilters
if len(c.Args()) > 0 {
var argIDs []string
for _, arg := range c.Args() {
_, err = strconv.Atoi(arg)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
argIDs = append(argIDs, arg)
}
filters = rainforest.RFTestFilters{
Tests: argIDs,
}
} else {
filters = rainforest.RFTestFilters{
Tags: c.StringSlice("tag"),
}
if c.Int("site-id") > 0 {
filters.SiteID = c.Int("site-id")
}
if c.Int("folder-id") > 0 {
filters.SmartFolderID = c.Int("folder-id")
}
if c.Int("feature-id") > 0 {
filters.FeatureID = c.Int("feature-id")
}
if c.Int("run-group-id") > 0 {
filters.RunGroupID = c.Int("run-group-id")
}
}
tests, err = client.GetTests(&filters)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
for _, t := range tests {
if t.HasWisp {
err := fmt.Errorf("Cannot download requested tests. Test %v isn't supported.", t.TestID)
return cli.NewExitError(err.Error(), 1)
}
testInfo := RFTestInfo{
ID: t.TestID,
HasWisp: t.HasWisp,
}
testInfos = append(testInfos, testInfo)
}
errorsChan := make(chan error)
testInfoChan := make(chan RFTestInfo, len(testInfos))
testChan := make(chan *rainforest.RFTest, len(testInfos))
for _, testInfo := range testInfos {
testInfoChan <- testInfo
}
close(testInfoChan)
for i := 0; i < rfmlDownloadConcurrency; i++ {
go downloadRFTestWorker(testInfoChan, errorsChan, testChan, client)
}
testIDPairs, err := client.GetTestIDs()
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
testIDCollection := rainforest.NewTestIDCollection(testIDPairs)
for i := 0; i < len(testInfos); i++ {
select {
case err = <-errorsChan:
return cli.NewExitError(err.Error(), 1)
case test := <-testChan:
err = test.PrepareToWriteAsRFML(*testIDCollection, c.Bool("flatten-steps"))
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
paddedTestID := fmt.Sprintf("%010d", test.TestID)
sanitizedTitle := sanitizeTestTitle(test.Title)
fileName := fmt.Sprintf("%v_%v.rfml", paddedTestID, sanitizedTitle)
filePath := filepath.Join(absTestDirectory, fileName)
var file *os.File
file, err = os.Create(filePath)
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
writer := rainforest.NewRFMLWriter(file)
err = writer.WriteRFMLTest(test)
file.Close()
if err != nil {
return cli.NewExitError(err.Error(), 1)
}
log.Printf("Downloaded test to %v", filePath)
}
}
return nil
}
func downloadRFTestWorker(testInfoChan chan RFTestInfo, errorsChan chan error, testChan chan *rainforest.RFTest, client rfAPI) {
for testInfo := range testInfoChan {
test, err := client.GetTest(testInfo.ID)
if err != nil {
errorsChan <- err
return
}
testChan <- test
}
}
/*
Helper Functions
*/
func prepareTestDirectory(testDir string) (string, error) {
absTestDirectory, err := filepath.Abs(testDir)
if err != nil {
return "", err
}
dirStat, err := os.Stat(absTestDirectory)
if os.IsNotExist(err) {
log.Printf("Creating test directory: %v", absTestDirectory)
os.MkdirAll(absTestDirectory, os.ModePerm)
} else if err != nil {
return "", err
} else {
if !dirStat.IsDir() {
return "", fmt.Errorf("%v should be a directory", absTestDirectory)
}
}
return absTestDirectory, nil
}
func sanitizeTestTitle(title string) string {
title = strings.TrimSpace(title)
title = strings.ToLower(title)
// replace all non-alphanumeric character sequences with an underscore
rep := regexp.MustCompile(`[^[[:alnum:]]+`)
title = rep.ReplaceAllLiteralString(title, "_")
if len(title) > 30 {
return title[:30]
}
return title
}
func testCreationWorker(api rfAPI, testsToCreate <-chan *rainforest.RFTest, errorsChan chan<- error) {
for test := range testsToCreate {
log.Printf("Creating new test: %v", test.RFMLID)
err := api.CreateTest(test)
errorsChan <- err
}
}
func testUpdateWorker(api rfAPI, testsToUpdate <-chan *rainforest.RFTest, branchID int, errorsChan chan<- error) {
for test := range testsToUpdate {
log.Printf("Updating existing test: %v", test.RFMLID)
err := api.UpdateTest(test, branchID)
errorsChan <- err
}
}