|
|
|
|
@@ -118,7 +118,7 @@ func TestSubprocessRunnerMapsCacheControlsToArguments(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestSubprocessRunnerMapsConfigProfileToArgumentPair(t *testing.T) {
|
|
|
|
|
func TestSubprocessRunnerMapsConfigOverlayToArgumentPair(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
|
|
|
|
name string
|
|
|
|
|
supplied bool
|
|
|
|
|
@@ -133,7 +133,7 @@ func TestSubprocessRunnerMapsConfigProfileToArgumentPair(t *testing.T) {
|
|
|
|
|
t.Run(test.name, func(t *testing.T) {
|
|
|
|
|
req := validRunRequest(t)
|
|
|
|
|
if test.supplied {
|
|
|
|
|
req.ConfigProfile = &test.value
|
|
|
|
|
req.ConfigOverlay = &test.value
|
|
|
|
|
}
|
|
|
|
|
var captured sharedsubprocess.RunRequest
|
|
|
|
|
runner := &SubprocessRunner{run: func(_ context.Context, processReq sharedsubprocess.RunRequest) (sharedsubprocess.RunResult, error) {
|
|
|
|
|
@@ -147,19 +147,19 @@ func TestSubprocessRunnerMapsConfigProfileToArgumentPair(t *testing.T) {
|
|
|
|
|
}
|
|
|
|
|
flagIndex := -1
|
|
|
|
|
for index, arg := range captured.Args {
|
|
|
|
|
if arg == "--config-profile" {
|
|
|
|
|
if arg == "--config-overlay" {
|
|
|
|
|
flagIndex = index
|
|
|
|
|
break
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if !test.supplied {
|
|
|
|
|
if flagIndex >= 0 {
|
|
|
|
|
t.Fatalf("subprocess args unexpectedly contain config profile: %#v", captured.Args)
|
|
|
|
|
t.Fatalf("subprocess args unexpectedly contain config overlay: %#v", captured.Args)
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if flagIndex < 0 || flagIndex+2 >= len(captured.Args) || captured.Args[flagIndex+1] != test.value || captured.Args[flagIndex+2] != "--json" {
|
|
|
|
|
t.Fatalf("config profile argument boundary = %#v, want flag, exact value, then --json", captured.Args)
|
|
|
|
|
t.Fatalf("config overlay argument boundary = %#v, want flag, exact value, then --json", captured.Args)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
@@ -455,7 +455,7 @@ func TestSubprocessRunnerReturnsProcessFailuresWithoutParsingStdout(t *testing.T
|
|
|
|
|
req := validRunRequest(t)
|
|
|
|
|
if test.name == "nonzero" {
|
|
|
|
|
profile := "missing-profile"
|
|
|
|
|
req.ConfigProfile = &profile
|
|
|
|
|
req.ConfigOverlay = &profile
|
|
|
|
|
}
|
|
|
|
|
req.Binary = writeShellScript(t, "#!/bin/sh\n"+test.scriptBody)
|
|
|
|
|
req.Timeout = test.timeout
|
|
|
|
|
@@ -754,7 +754,7 @@ func TestLoadDiagnosticSummariesValidateBoundsAndTolerateUnknownFields(t *testin
|
|
|
|
|
|
|
|
|
|
func TestFakeRunnerCapturesRequestsAndHonorsContextAndError(t *testing.T) {
|
|
|
|
|
profile := "testing"
|
|
|
|
|
req := RunRequest{PipelineID: "pipeline", ConfigProfile: &profile, References: []ReferenceBinding{{Selector: "party", Path: "/references/party.json"}}}
|
|
|
|
|
req := RunRequest{PipelineID: "pipeline", ConfigOverlay: &profile, References: []ReferenceBinding{{Selector: "party", Path: "/references/party.json"}}}
|
|
|
|
|
want := RunResult{BundleRoot: "/bundle"}
|
|
|
|
|
fake := &FakeRunner{Result: want}
|
|
|
|
|
got, err := fake.Run(context.Background(), req)
|
|
|
|
|
@@ -766,8 +766,8 @@ func TestFakeRunnerCapturesRequestsAndHonorsContextAndError(t *testing.T) {
|
|
|
|
|
t.Fatalf("fake retained aliased request references: %#v", fake.Requests[0].References)
|
|
|
|
|
}
|
|
|
|
|
profile = "changed"
|
|
|
|
|
if *fake.Requests[0].ConfigProfile != "testing" {
|
|
|
|
|
t.Fatalf("fake retained aliased config profile: %q", *fake.Requests[0].ConfigProfile)
|
|
|
|
|
if *fake.Requests[0].ConfigOverlay != "testing" {
|
|
|
|
|
t.Fatalf("fake retained aliased config overlay: %q", *fake.Requests[0].ConfigOverlay)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wantErr := errors.New("configured failure")
|
|
|
|
|
|