feat: persist and dispatch client command input
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package windows
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestEnvironmentOverlayIsCaseInsensitiveAndDeterministic_HP_WINENV_01(t *testing.T) {
|
||||
t.Parallel()
|
||||
base := map[string]string{"Path": `C:\Windows`, "TEMP": `C:\Temp`, "=C:": `C:\Windows`}
|
||||
overrides := map[string]string{"PATH": `C:\Pinned`, "Name": "rvbox"}
|
||||
entries, err := MergeEnvironment(base, overrides)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(entries) != 4 || entries[0].Folded != "=C:" || entries[1].Folded != "NAME" || entries[2].Folded != "PATH" || entries[2].Value != `C:\Pinned` {
|
||||
t.Fatalf("merged entries = %#v", entries)
|
||||
}
|
||||
block, err := BuildEnvironmentBlock(base, overrides)
|
||||
if err != nil || len(block) == 0 || block[len(block)-1] != 0 || block[len(block)-2] != 0 {
|
||||
t.Fatalf("environment block = len=%d err=%v", len(block), err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestEnvironmentOverlayRejectsMalformedAndDuplicateBase_BH_WINENV_01(t *testing.T) {
|
||||
t.Parallel()
|
||||
if _, err := MergeEnvironment(map[string]string{"Path": "one", "PATH": "two"}, nil); !errors.Is(err, ErrDuplicateEnvironmentKey) {
|
||||
t.Fatalf("duplicate base error = %v", err)
|
||||
}
|
||||
if _, err := MergeEnvironment(nil, map[string]string{"BAD=KEY": "value"}); !errors.Is(err, ErrInvalidEnvironmentKey) {
|
||||
t.Fatalf("invalid override key error = %v", err)
|
||||
}
|
||||
if _, err := MergeEnvironment(nil, map[string]string{"NUL": "bad\x00value"}); !errors.Is(err, ErrInvalidEnvironmentValue) {
|
||||
t.Fatalf("invalid override value error = %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user