github.com/iter8-tools/iter8@v1.1.2/abn/test_helpers.go (about)

     1  package abn
     2  
     3  import "github.com/iter8-tools/iter8/controllers"
     4  
     5  type testroutemapsByName map[string]*testroutemap
     6  type testroutemaps struct {
     7  	nsRoutemap map[string]testroutemapsByName
     8  }
     9  
    10  func (s *testroutemaps) GetRoutemapFromNamespaceName(namespace string, name string) controllers.RoutemapInterface {
    11  	rmByName, ok := s.nsRoutemap[namespace]
    12  	if ok {
    13  		return rmByName[name]
    14  	}
    15  	return nil
    16  }
    17  
    18  type testversion struct {
    19  	signature *string
    20  }
    21  
    22  func (v *testversion) GetSignature() *string {
    23  	return v.signature
    24  }
    25  
    26  type testroutemap struct {
    27  	name              string
    28  	namespace         string
    29  	versions          []testversion
    30  	normalizedWeights []uint32
    31  }
    32  
    33  func (s *testroutemap) RLock() {}
    34  
    35  func (s *testroutemap) RUnlock() {}
    36  
    37  func (s *testroutemap) GetNamespace() string {
    38  	return s.namespace
    39  }
    40  
    41  func (s *testroutemap) GetName() string {
    42  	return s.name
    43  }
    44  
    45  func (s *testroutemap) Weights() []uint32 {
    46  	return s.normalizedWeights
    47  }
    48  
    49  func (s *testroutemap) GetVersions() []controllers.VersionInterface {
    50  	result := make([]controllers.VersionInterface, len(s.versions))
    51  	for i := range s.versions {
    52  		v := s.versions[i]
    53  		result[i] = controllers.VersionInterface(&v)
    54  	}
    55  	return result
    56  }
    57  
    58  type testRoutemaps struct {
    59  	allroutemaps testroutemaps
    60  }
    61  
    62  func (cm *testRoutemaps) GetAllRoutemaps() controllers.RoutemapsInterface {
    63  	return &cm.allroutemaps
    64  }