Verify native workflows and explain identity mismatches
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -167,3 +168,25 @@ func TestConfigurationAggregateDoesNotOmitUnavailableContext(t *testing.T) {
|
||||
t.Fatalf("missing aggregate scope report: %s", out.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigurationInspectionExplainsIdentityMismatches(t *testing.T) {
|
||||
_, campaign, session := writeValidConfigFiles(t, t.TempDir())
|
||||
for _, args := range [][]string{
|
||||
{"config", "show", "--scope", "campaign", "--campaign-file", campaign, "--campaign", "other-campaign"},
|
||||
{"config", "show", "--scope", "session", "--campaign-file", campaign, "--session-file", session, "--session", "other-session"},
|
||||
{"config", "diff", "--scope", "campaign", "--campaign-file", campaign, "--against-campaign-file", campaign, "--against-campaign", "other-campaign"},
|
||||
} {
|
||||
var output, diagnostics bytes.Buffer
|
||||
result := Execute(context.Background(), args, commandkit.Streams{Out: &output, Err: &diagnostics})
|
||||
var identity *config.SessionIdentityError
|
||||
if result.Status == 0 || !errors.As(result.Cause, &identity) {
|
||||
t.Fatalf("%v: identity cause missing: %#v", args, result)
|
||||
}
|
||||
if output.Len() != 0 || !strings.Contains(diagnostics.String(), identity.Field) || !strings.Contains(diagnostics.String(), identity.Expected) || !strings.Contains(diagnostics.String(), identity.Actual) {
|
||||
t.Fatalf("%v: assertion not explained: %s", args, diagnostics.String())
|
||||
}
|
||||
if identity.Field == "campaign_id" && strings.Contains(diagnostics.String(), "session file") {
|
||||
t.Fatalf("campaign assertion mislabeled: %s", diagnostics.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user