github.com/ActiveState/cli@v0.0.0-20240508170324-6801f60cd051/pkg/platform/runtime/artifactcache/testhelper.go (about)

     1  package artifactcache
     2  
     3  import "github.com/go-openapi/strfmt"
     4  
     5  // This file exists solely to export private data from ArtifactCache in order to run integration
     6  // tests in an outside package.
     7  
     8  type testArtifactCache struct {
     9  	cache *ArtifactCache
    10  }
    11  
    12  // NewTestArtifactCache is only meant to be called from tests. Use New() instead.
    13  func NewTestArtifactCache(dir string, maxSize int64) (*testArtifactCache, error) {
    14  	cache, err := newWithDirAndSize(dir, maxSize)
    15  	if err != nil {
    16  		return nil, err
    17  	}
    18  	return &testArtifactCache{cache}, nil
    19  }
    20  
    21  func (ac *testArtifactCache) Dir() string {
    22  	return ac.cache.dir
    23  }
    24  
    25  func (ac *testArtifactCache) InfoJson() string {
    26  	return ac.cache.infoJson
    27  }
    28  
    29  func (ac *testArtifactCache) MaxSize() int64 {
    30  	return ac.cache.maxSize
    31  }
    32  
    33  func (ac *testArtifactCache) CurrentSize() int64 {
    34  	return ac.cache.currentSize
    35  }
    36  
    37  func (ac *testArtifactCache) Artifacts() map[strfmt.UUID]*cachedArtifact {
    38  	return ac.cache.artifacts
    39  }
    40  
    41  func (ac *testArtifactCache) Get(a strfmt.UUID) (string, bool) {
    42  	return ac.cache.Get(a)
    43  }
    44  
    45  func (ac *testArtifactCache) Store(a strfmt.UUID, s string) error {
    46  	return ac.cache.Store(a, s)
    47  }
    48  
    49  func (ac *testArtifactCache) Save() error {
    50  	return ac.cache.Save()
    51  }