mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
refactor(cve): improve CVE test time by mocking trivy (#1184)
- refactor(cve): remove the global of type cveinfo.CveInfo from the extensions package Replace it with an attribute on controller level - refactor(controller): extract initialization logic from controller.Run() - test(cve): mock cve scanner in cli tests Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
This commit is contained in:
@@ -126,14 +126,18 @@ func TestNewExporter(t *testing.T) {
|
||||
|
||||
dir := t.TempDir()
|
||||
serverController.Config.Storage.RootDirectory = dir
|
||||
go func(c *zotapi.Controller) {
|
||||
go func(ctrl *zotapi.Controller) {
|
||||
if err := ctrl.Init(context.Background()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// this blocks
|
||||
if err := c.Run(context.Background()); !errors.Is(err, http.ErrServerClosed) {
|
||||
if err := ctrl.Run(context.Background()); !errors.Is(err, http.ErrServerClosed) {
|
||||
panic(err)
|
||||
}
|
||||
}(serverController)
|
||||
defer func(c *zotapi.Controller) {
|
||||
_ = c.Server.Shutdown(context.TODO())
|
||||
defer func(ctrl *zotapi.Controller) {
|
||||
_ = ctrl.Server.Shutdown(context.TODO())
|
||||
}(serverController)
|
||||
// wait till ready
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user