mirror of
https://github.com/rancher/plugins.git
synced 2025-09-08 01:14:36 +00:00
Windows: Updates Windows Vendoring
Updates windows dependent libraries for vendoing.
This commit is contained in:
68
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_test.go
generated
vendored
Normal file
68
vendor/github.com/Microsoft/hcsshim/pkg/go-runhcs/runhcs_test.go
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
package runhcs
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func resetRunhcsPath() {
|
||||
runhcsPath = atomic.Value{}
|
||||
}
|
||||
|
||||
func TestGetCommandPath_NoLookPath(t *testing.T) {
|
||||
resetRunhcsPath()
|
||||
|
||||
path := getCommandPath()
|
||||
if path != "runhcs.exe" {
|
||||
t.Fatalf("expected path 'runhcs.exe' got '%s'", path)
|
||||
}
|
||||
pathi := runhcsPath.Load()
|
||||
if pathi == nil {
|
||||
t.Fatal("cache state should be set after first query")
|
||||
}
|
||||
if path != pathi.(string) {
|
||||
t.Fatalf("expected: '%s' in cache got '%s'", path, pathi.(string))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommandPath_WithLookPath(t *testing.T) {
|
||||
resetRunhcsPath()
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get cwd with err: %v", err)
|
||||
}
|
||||
fakePath := filepath.Join(wd, "runhcs.exe")
|
||||
f, err := os.Create(fakePath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create fake runhcs.exe in path with err: %v", err)
|
||||
}
|
||||
f.Close()
|
||||
defer os.Remove(fakePath)
|
||||
|
||||
path := getCommandPath()
|
||||
if path != fakePath {
|
||||
t.Fatalf("expected fake path '%s' got '%s'", fakePath, path)
|
||||
}
|
||||
pathi := runhcsPath.Load()
|
||||
if pathi == nil {
|
||||
t.Fatal("cache state should be set after first query")
|
||||
}
|
||||
if path != pathi.(string) {
|
||||
t.Fatalf("expected: '%s' in cache got '%s'", fakePath, pathi.(string))
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCommandPath_WithCache(t *testing.T) {
|
||||
resetRunhcsPath()
|
||||
|
||||
value := "this is a test"
|
||||
runhcsPath.Store(value)
|
||||
|
||||
path := getCommandPath()
|
||||
if path != value {
|
||||
t.Fatalf("expected fake cached path: '%s' got '%s'", value, path)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user