go.undefinedlabs.com/scopeagent@v0.4.2/instrumentation/testing/config/testing.go (about)

     1  package config
     2  
     3  import (
     4  	"fmt"
     5  	"go.undefinedlabs.com/scopeagent/instrumentation"
     6  	"sync"
     7  )
     8  
     9  var (
    10  	testsToSkip map[string]struct{}
    11  
    12  	m sync.Mutex
    13  )
    14  
    15  // Gets the map of cached tests
    16  func GetCachedTestsMap() map[string]struct{} {
    17  	m.Lock()
    18  	defer m.Unlock()
    19  
    20  	if testsToSkip != nil {
    21  		return testsToSkip
    22  	}
    23  
    24  	config := instrumentation.GetRemoteConfiguration()
    25  	testsToSkip = map[string]struct{}{}
    26  	if config != nil {
    27  		if iCached, ok := config["cached"]; ok {
    28  			cachedTests := iCached.([]interface{})
    29  			for _, item := range cachedTests {
    30  				testItem := item.(map[string]interface{})
    31  				testFqn := fmt.Sprintf("%v.%v", testItem["test_suite"], testItem["test_name"])
    32  				testsToSkip[testFqn] = struct{}{}
    33  			}
    34  		}
    35  	}
    36  	return testsToSkip
    37  }