diff --git a/controller/nucleus/initialise_test.go b/controller/nucleus/initialise_test.go index b9cd0f98d0bbb7d3671a1896de275b52b3445c7e..e1ad1a28bf5d0f4ac3f8aeb03580db92ee9e55e7 100644 --- a/controller/nucleus/initialise_test.go +++ b/controller/nucleus/initialise_test.go @@ -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 {