package commandkit import ( "errors" "testing" ) func TestOutcomeConstructors(t *testing.T) { cause := errors.New("operation failed") tests := []struct { name string got Outcome kind OutcomeKind status int domain string wantCause error }{ {name: "success", got: Success(), kind: OutcomeSuccess, status: 0}, {name: "usage", got: Usage(cause), kind: OutcomeUsage, status: 2, wantCause: cause}, {name: "failure", got: Failure(cause), kind: OutcomeOperational, status: 1, wantCause: cause}, {name: "domain", got: Domain("record", 7, cause), kind: OutcomeDomain, status: 7, domain: "record", wantCause: cause}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { if test.got.Kind != test.kind { t.Fatalf("Kind = %q, want %q", test.got.Kind, test.kind) } if test.got.Status != test.status { t.Fatalf("Status = %d, want %d", test.got.Status, test.status) } if test.got.Cause != test.wantCause { t.Fatalf("Cause = %v, want original cause %v", test.got.Cause, test.wantCause) } if test.got.Domain != test.domain { t.Fatalf("Domain = %q, want %q", test.got.Domain, test.domain) } }) } }