mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Add migration that creates the Sonoma+ built-in label
This commit is contained in:
parent
d2fd3694b8
commit
81556aa43a
2 changed files with 19 additions and 10 deletions
|
|
@ -22,7 +22,7 @@ func Up_20240403104633(tx *sql.Tx) error {
|
|||
platform,
|
||||
label_type,
|
||||
label_membership_type
|
||||
) VALUES (?, ?, ?, ?, ?)
|
||||
) VALUES (?, ?, ?, ?, ?, ?)
|
||||
`
|
||||
|
||||
const labelName = "macOS 14+ (Sonoma+)"
|
||||
|
|
|
|||
|
|
@ -1,20 +1,29 @@
|
|||
package tables
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestUp_20240403104633(t *testing.T) {
|
||||
db := applyUpToPrev(t)
|
||||
|
||||
//
|
||||
// Insert data to test the migration
|
||||
//
|
||||
// ...
|
||||
execNoErr(t, db, "INSERT INTO labels (name, query, platform) VALUES (?,?,?)", "NOT macOS 14+ (Sonoma+)", "SELECT 1", "windows")
|
||||
|
||||
// Apply current migration.
|
||||
//
|
||||
// The case where the name already exists could not be tested because
|
||||
// applying the next migration fails drastically when the migration returns
|
||||
// an error (it calls log.Fatal) and the test cannot continue after the
|
||||
// error, but it has been tested manually.
|
||||
applyNext(t, db)
|
||||
|
||||
//
|
||||
// Check data, insert new entries, e.g. to verify migration is safe.
|
||||
//
|
||||
// ...
|
||||
var names []string
|
||||
err := db.Select(&names, `SELECT name FROM labels`)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.GreaterOrEqual(t, len(names), 2)
|
||||
require.Contains(t, names, "macOS 14+ (Sonoma+)")
|
||||
require.Contains(t, names, "NOT macOS 14+ (Sonoma+)")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue