mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #33756 # Checklist for submitter If some of the following don't apply, delete the relevant line. - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] Added/updated automated tests - [ ] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [x] QA'd all new/changed functionality manually
78 lines
2 KiB
Go
78 lines
2 KiB
Go
// Automatically generated by mockimpl. DO NOT EDIT!
|
|
|
|
package mock
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/fleetdm/fleet/v4/server/fleet"
|
|
)
|
|
|
|
var _ fleet.SoftwareInstallerStore = (*SoftwareInstallerStore)(nil)
|
|
|
|
type GetFunc func(ctx context.Context, installerID string) (io.ReadCloser, int64, error)
|
|
|
|
type PutFunc func(ctx context.Context, installerID string, content io.ReadSeeker) error
|
|
|
|
type ExistsFunc func(ctx context.Context, installerID string) (bool, error)
|
|
|
|
type CleanupFunc func(ctx context.Context, usedInstallerIDs []string, removeCreatedBefore time.Time) (int, error)
|
|
|
|
type SignFunc func(ctx context.Context, fileID string, expiresIn time.Duration) (string, error)
|
|
|
|
type SoftwareInstallerStore struct {
|
|
GetFunc GetFunc
|
|
GetFuncInvoked bool
|
|
|
|
PutFunc PutFunc
|
|
PutFuncInvoked bool
|
|
|
|
ExistsFunc ExistsFunc
|
|
ExistsFuncInvoked bool
|
|
|
|
CleanupFunc CleanupFunc
|
|
CleanupFuncInvoked bool
|
|
|
|
SignFunc SignFunc
|
|
SignFuncInvoked bool
|
|
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func (s *SoftwareInstallerStore) Get(ctx context.Context, installerID string) (io.ReadCloser, int64, error) {
|
|
s.mu.Lock()
|
|
s.GetFuncInvoked = true
|
|
s.mu.Unlock()
|
|
return s.GetFunc(ctx, installerID)
|
|
}
|
|
|
|
func (s *SoftwareInstallerStore) Put(ctx context.Context, installerID string, content io.ReadSeeker) error {
|
|
s.mu.Lock()
|
|
s.PutFuncInvoked = true
|
|
s.mu.Unlock()
|
|
return s.PutFunc(ctx, installerID, content)
|
|
}
|
|
|
|
func (s *SoftwareInstallerStore) Exists(ctx context.Context, installerID string) (bool, error) {
|
|
s.mu.Lock()
|
|
s.ExistsFuncInvoked = true
|
|
s.mu.Unlock()
|
|
return s.ExistsFunc(ctx, installerID)
|
|
}
|
|
|
|
func (s *SoftwareInstallerStore) Cleanup(ctx context.Context, usedInstallerIDs []string, removeCreatedBefore time.Time) (int, error) {
|
|
s.mu.Lock()
|
|
s.CleanupFuncInvoked = true
|
|
s.mu.Unlock()
|
|
return s.CleanupFunc(ctx, usedInstallerIDs, removeCreatedBefore)
|
|
}
|
|
|
|
func (s *SoftwareInstallerStore) Sign(ctx context.Context, fileID string, expiresIn time.Duration) (string, error) {
|
|
s.mu.Lock()
|
|
s.SignFuncInvoked = true
|
|
s.mu.Unlock()
|
|
return s.SignFunc(ctx, fileID, expiresIn)
|
|
}
|