unittests: Fixes unit tests for Windows (part 10)

Currently, there are some unit tests that are failing on
Windows due to various reasons:

- Different "File not found" error messages on Windows.
- Files need to be closed on Windows before removing them.
- The default RootHnsEndpointName (root-hnsendpoint-name) flag value is 'cbr0'
- On Windows, Unix Domain sockets are not checked in the same way in golang, which is why
  hostutils_windows.go checks for it differently. GetFileType will return an error in this
  case. We need to check for it, and see if it's actually a Unix Domain Socket.
This commit is contained in:
Claudiu Belu
2024-01-20 00:40:46 +00:00
parent 909faa3a9b
commit b8df7e7684
7 changed files with 22 additions and 8 deletions

View File

@@ -41,6 +41,10 @@ const (
FileTypeUnknown FileType = ""
)
var (
errUnknownFileType = fmt.Errorf("only recognise file, directory, socket, block device and character device")
)
// HostUtils defines the set of methods for interacting with paths on a host.
type HostUtils interface {
// DeviceOpened determines if the device (e.g. /dev/sdc) is in use elsewhere
@@ -108,5 +112,5 @@ func getFileType(pathname string) (FileType, error) {
return FileTypeBlockDev, nil
}
return pathType, fmt.Errorf("only recognise file, directory, socket, block device and character device")
return pathType, errUnknownFileType
}