Skip to content

Commit

Permalink
chore: mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jahzielv committed Sep 24, 2024
1 parent 6dcf5cd commit 470ddbb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
7 changes: 1 addition & 6 deletions server/fleet/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -316,10 +314,7 @@ type MDMAppleProfilePayload struct {
// DidNotInstallOnHost indicates whether this profile was not installed on the host (and
// therefore is not, as far as Fleet knows, currently on the host).
func (p *MDMAppleProfilePayload) DidNotInstallOnHost() bool {
if p.Status == nil && p.OperationType == MDMOperationTypeRemove {
slog.With("filename", "server/fleet/apple_mdm.go", "func", func() string { counter, _, _, _ := runtime.Caller(1); return runtime.FuncForPC(counter).Name() }()).Info("JVE_LOG: profile had null status and was remove ", "name", p.ProfileName)
}
return p.Status != nil && (*p.Status == MDMDeliveryFailed || *p.Status == MDMDeliveryPending) && p.OperationType == MDMOperationTypeInstall || p.Status == nil && p.OperationType == MDMOperationTypeRemove
return p.Status != nil && (*p.Status == MDMDeliveryFailed || *p.Status == MDMDeliveryPending) && p.OperationType == MDMOperationTypeInstall
}

func (p MDMAppleProfilePayload) Equal(other MDMAppleProfilePayload) bool {
Expand Down
24 changes: 24 additions & 0 deletions server/mock/datastore_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,10 @@ type DeleteHostDEPAssignmentsFunc func(ctx context.Context, serials []string) er

type UpdateHostDEPAssignProfileResponsesFunc func(ctx context.Context, resp *godep.ProfileResponse) error

type GetHostMDMAppleProfileByUUIDFunc func(ctx context.Context, uuid string) (*fleet.HostMDMAppleProfile, error)

type DeleteHostMDMAppleProfileByUUIDFunc func(ctx context.Context, uuid string) error

type ScreenDEPAssignProfileSerialsForCooldownFunc func(ctx context.Context, serials []string) (skipSerialsByOrgName map[string][]string, serialsByOrgName map[string][]string, err error)

type GetDEPAssignProfileExpiredCooldownsFunc func(ctx context.Context) (map[uint][]string, error)
Expand Down Expand Up @@ -2336,6 +2340,12 @@ type DataStore struct {
UpdateHostDEPAssignProfileResponsesFunc UpdateHostDEPAssignProfileResponsesFunc
UpdateHostDEPAssignProfileResponsesFuncInvoked bool

GetHostMDMAppleProfileByUUIDFunc GetHostMDMAppleProfileByUUIDFunc
GetHostMDMAppleProfileByUUIDFuncInvoked bool

DeleteHostMDMAppleProfileByUUIDFunc DeleteHostMDMAppleProfileByUUIDFunc
DeleteHostMDMAppleProfileByUUIDFuncInvoked bool

ScreenDEPAssignProfileSerialsForCooldownFunc ScreenDEPAssignProfileSerialsForCooldownFunc
ScreenDEPAssignProfileSerialsForCooldownFuncInvoked bool

Expand Down Expand Up @@ -5604,6 +5614,20 @@ func (s *DataStore) UpdateHostDEPAssignProfileResponses(ctx context.Context, res
return s.UpdateHostDEPAssignProfileResponsesFunc(ctx, resp)
}

func (s *DataStore) GetHostMDMAppleProfileByUUID(ctx context.Context, uuid string) (*fleet.HostMDMAppleProfile, error) {
s.mu.Lock()
s.GetHostMDMAppleProfileByUUIDFuncInvoked = true
s.mu.Unlock()
return s.GetHostMDMAppleProfileByUUIDFunc(ctx, uuid)
}

func (s *DataStore) DeleteHostMDMAppleProfileByUUID(ctx context.Context, uuid string) error {
s.mu.Lock()
s.DeleteHostMDMAppleProfileByUUIDFuncInvoked = true
s.mu.Unlock()
return s.DeleteHostMDMAppleProfileByUUIDFunc(ctx, uuid)
}

func (s *DataStore) ScreenDEPAssignProfileSerialsForCooldown(ctx context.Context, serials []string) (skipSerialsByOrgName map[string][]string, serialsByOrgName map[string][]string, err error) {
s.mu.Lock()
s.ScreenDEPAssignProfileSerialsForCooldownFuncInvoked = true
Expand Down

0 comments on commit 470ddbb

Please sign in to comment.