Skip to content
Snippets Groups Projects
Commit 59e00686 authored by Malte Bauch's avatar Malte Bauch
Browse files

Linter pleasing

parent f54028e1
No related branches found
No related tags found
1 merge request!401Change the current gosdn plugin implementation from Go's internal plugin system to hashicorp's go-plugins
Pipeline #135497 failed
......@@ -2,11 +2,9 @@ package nucleus
import (
"context"
"io/fs"
"os"
"path/filepath"
"testing"
"time"
eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement"
......@@ -188,7 +186,6 @@ func newPnd() (*pndImplementation, error) {
err := pluginService.Add(mockPlugin)
if err != nil {
return nil, err
}
deviceService := NewNetworkElementService(
deviceStore,
......@@ -208,42 +205,42 @@ func newPnd() (*pndImplementation, error) {
// removeTestGoStructs removes the plugins created during running the test in the current directory based on their name consisting of a uuid
// and the time since they`ve been created.
func removeTestGoStructs() {
currentDirectory := "./"
// pattern to match plugin uuid used as dir name
pattern := "*-*-*-*-*"
// max time passed since creation in seconds
var seconds int64 = 10
// get all available files
dirs, err := os.ReadDir(currentDirectory)
if err != nil {
log.Info(err)
}
for _, dir := range dirs {
if !dir.IsDir() {
continue
} else if found, _ := filepath.Match(pattern, dir.Name()); found && isDirYoungerThanSeconds(dir.Name(), seconds) {
log.Infof("removing: %v", dir.Name())
err = os.RemoveAll(dir.Name())
if err != nil {
log.Info(err)
}
}
}
}
//func removeTestGoStructs() {
// currentDirectory := "./"
// // pattern to match plugin uuid used as dir name
// pattern := "*-*-*-*-*"
// // max time passed since creation in seconds
// var seconds int64 = 10
//
// // get all available files
// dirs, err := os.ReadDir(currentDirectory)
// if err != nil {
// log.Info(err)
// }
//
// for _, dir := range dirs {
// if !dir.IsDir() {
// continue
// } else if found, _ := filepath.Match(pattern, dir.Name()); found && isDirYoungerThanSeconds(dir.Name(), seconds) {
// log.Infof("removing: %v", dir.Name())
// err = os.RemoveAll(dir.Name())
// if err != nil {
// log.Info(err)
// }
// }
// }
//}
// isDirYoungerThanSeconds returns true if the provided dir is younger than the given amount in seconds
// and therefore was created as part of the test suite.
func isDirYoungerThanSeconds(dirName string, seconds int64) bool {
fileInfo, err := os.Stat(dirName)
if err != nil {
log.Info(err)
}
return fs.FileInfo.ModTime(fileInfo).Unix() > (time.Now().Unix() - seconds)
}
//func isDirYoungerThanSeconds(dirName string, seconds int64) bool {
// fileInfo, err := os.Stat(dirName)
// if err != nil {
// log.Info(err)
// }
//
// return fs.FileInfo.ModTime(fileInfo).Unix() > (time.Now().Unix() - seconds)
//}
func ensureStoreFileForTestsIsRemoved(storeName string) {
if err := store.EnsureFilesystemStorePathExists(storeName); err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment