mirror of
https://github.com/fleetdm/fleet
synced 2026-05-06 06:48:54 +00:00
#20929 Moving Go integration tests to integration test job, which runs tests that start with `TestIntegrations` Test changes only. No product changes
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
package macoffice
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/fleetdm/fleet/v4/pkg/nettest"
|
|
"github.com/fleetdm/fleet/v4/server/vulnerabilities/io"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestIntegrationsSync(t *testing.T) {
|
|
nettest.Run(t)
|
|
|
|
vulnPath := t.TempDir()
|
|
ctx := context.Background()
|
|
|
|
err := SyncFromGithub(ctx, vulnPath)
|
|
require.NoError(t, err)
|
|
|
|
entries, err := os.ReadDir(vulnPath)
|
|
var filesInVulnPath []string
|
|
for _, e := range entries {
|
|
filesInVulnPath = append(filesInVulnPath, e.Name())
|
|
}
|
|
|
|
require.NoError(t, err)
|
|
|
|
// Checking for the presence of the file for today or yesterday
|
|
// in case the NVD repo is having delays publishing the data
|
|
todayFilename := io.MacOfficeRelNotesFileName(time.Now())
|
|
yesterdayFilename := io.MacOfficeRelNotesFileName(time.Now().AddDate(0, 0, -1))
|
|
|
|
require.Condition(t, func() bool {
|
|
return contains(filesInVulnPath, todayFilename) || contains(filesInVulnPath, yesterdayFilename)
|
|
}, "Expected to find %s or %s in %s", todayFilename, yesterdayFilename, vulnPath)
|
|
}
|
|
|
|
func contains(slice []string, str string) bool {
|
|
for _, v := range slice {
|
|
if v == str {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|