[WIP] Fix unit tests
This commit is contained in:
@@ -27,7 +27,7 @@ type testInstance struct {
|
||||
geoip *geoip.GeoIP
|
||||
}
|
||||
|
||||
func (stub *testInstance) Updates() *updates.Updates {
|
||||
func (stub *testInstance) IntelUpdates() *updates.Updates {
|
||||
return stub.updates
|
||||
}
|
||||
|
||||
@@ -61,6 +61,16 @@ func runTest(m *testing.M) error {
|
||||
}
|
||||
defer func() { _ = os.RemoveAll(ds) }()
|
||||
|
||||
installDir, err := os.MkdirTemp("", "endpoints_installdir")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create tmp install dir: %w", err)
|
||||
}
|
||||
defer func() { _ = os.RemoveAll(installDir) }()
|
||||
err = updates.GenerateMockFolder(installDir, "Test Intel", "1.0.0")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to generate mock installation: %w", err)
|
||||
}
|
||||
|
||||
stub := &testInstance{}
|
||||
stub.db, err = dbmodule.New(stub)
|
||||
if err != nil {
|
||||
@@ -74,7 +84,10 @@ func runTest(m *testing.M) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create api: %w", err)
|
||||
}
|
||||
stub.updates, err = updates.New(stub)
|
||||
stub.updates, err = updates.New(stub, "Test Intel", updates.UpdateIndex{
|
||||
Directory: installDir,
|
||||
IndexFile: "index.json",
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create updates: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user