Skip to content

Commit

Permalink
Remove obsolete todo, start test
Browse files Browse the repository at this point in the history
  • Loading branch information
mna committed Dec 16, 2024
1 parent cb63c06 commit adb263c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
30 changes: 14 additions & 16 deletions server/datastore/mysql/software_installers.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,8 +832,6 @@ func (ds *Datastore) CleanupUnusedSoftwareInstallers(ctx context.Context, softwa
}

func (ds *Datastore) BatchSetSoftwareInstallers(ctx context.Context, tmID *uint, installers []*fleet.UploadSoftwareInstallerPayload) error {
// TODO(mna): handle the include/exclude labels...

const upsertSoftwareTitles = `
INSERT INTO software_titles
(name, source, browser)
Expand Down Expand Up @@ -1003,27 +1001,27 @@ ON DUPLICATE KEY UPDATE
`

const loadSoftwareInstallerID = `
SELECT
id
FROM
software_installers
WHERE
SELECT
id
FROM
software_installers
WHERE
global_or_team_id = ? AND
-- this is guaranteed to select a single title_id, due to unique index
title_id IN (SELECT id FROM software_titles WHERE name = ? AND source = ? AND browser = '')
title_id IN (SELECT id FROM software_titles WHERE name = ? AND source = ? AND browser = '')
`

const deleteInstallerLabelsNotInList = `
DELETE
software_installer_labels
software_installer_labels
WHERE
software_installer_id = ? AND
label_id NOT IN (?)
`

const deleteAllInstallerLabels = `
DELETE
software_installer_labels
DELETE
software_installer_labels
WHERE
software_installer_id = ?
`
Expand All @@ -1042,11 +1040,11 @@ ON DUPLICATE KEY UPDATE
`

const loadExistingInstallerLabels = `
SELECT
SELECT
label_id,
exclude
FROM
software_installer_labels
exclude
FROM
software_installer_labels
WHERE
software_installer_id = ?
`
Expand Down Expand Up @@ -1333,7 +1331,7 @@ WHERE
}
}

// perform side effects if this was an update
// perform side effects if this was an update (related to pending (un)install requests)
if len(existing) > 0 {
if err := ds.runInstallerUpdateSideEffectsInTransaction(
ctx,
Expand Down
5 changes: 5 additions & 0 deletions server/datastore/mysql/software_installers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func TestSoftwareInstallers(t *testing.T) {
{"DeleteSoftwareInstallers", testDeleteSoftwareInstallers},
{"GetHostLastInstallData", testGetHostLastInstallData},
{"GetOrGenerateSoftwareInstallerTitleID", testGetOrGenerateSoftwareInstallerTitleID},
{"BatchSetSoftwareInstallersScopedViaLabels", testBatchSetSoftwareInstallersScopedViaLabels},
}

for _, c := range cases {
Expand Down Expand Up @@ -1361,3 +1362,7 @@ func testGetOrGenerateSoftwareInstallerTitleID(t *testing.T, ds *Datastore) {
})
}
}

func testBatchSetSoftwareInstallersScopedViaLabels(t *testing.T, ds *Datastore) {
ctx := context.Background()
}

0 comments on commit adb263c

Please sign in to comment.