greenlight/internal/cli/verify_test.go
ethan zhou 2cac3722ae Address Copilot 3rd pass: finalized-report verdict + input validation
- runner: require the Revyl report to finalize before declaring VERIFIED or
  FAILED. Previously a passing exit code with an unsettled report could yield a
  false VERIFIED; now an undecided report is always "could not determine."
- verify: validate --flows against the known flow ids (a typo failed silently as
  an empty "nothing to verify" run) and validate/normalize --platform to ios or
  android before generating YAML.

Tests added: validateFlows.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-01 20:17:09 -07:00

37 lines
1.1 KiB
Go

package cli
import "testing"
// parseVars must split on the first '=' so credential values containing commas
// or '=' (base64/JWT padding) survive intact — unlike pflag's StringToString.
func TestParseVars(t *testing.T) {
m := parseVars([]string{"email=a,b@acme.com", "password=p@ss==w0rd", "noeq", "=noval"})
if m["email"] != "a,b@acme.com" {
t.Errorf("email = %q, want a,b@acme.com", m["email"])
}
if m["password"] != "p@ss==w0rd" {
t.Errorf("password = %q, want p@ss==w0rd", m["password"])
}
if _, ok := m["noeq"]; ok {
t.Errorf("entry without '=' should be skipped")
}
if len(m) != 2 {
t.Errorf("expected 2 entries, got %d: %v", len(m), m)
}
if parseVars(nil) != nil {
t.Errorf("nil input should return nil map")
}
}
func TestValidateFlows(t *testing.T) {
if err := validateFlows(nil); err != nil {
t.Errorf("nil flows should be valid: %v", err)
}
if err := validateFlows([]string{"account-deletion", "sign-in-apple"}); err != nil {
t.Errorf("known flows should be valid: %v", err)
}
if err := validateFlows([]string{"account-deletion", "nope"}); err == nil {
t.Errorf("unknown flow should error")
}
}