package releasekit import "testing" func TestCandidateRequestPreservesSharedFileSelection(t *testing.T) { for _, tt := range []struct { name string input []string wantNil bool wantValues []string }{ {name: "omitted defaults", input: nil, wantNil: true}, {name: "explicit empty", input: []string{}, wantValues: []string{}}, {name: "explicit paths", input: []string{"LICENSE", "docs/shared.md"}, wantValues: []string{"LICENSE", "docs/shared.md"}}, } { t.Run(tt.name, func(t *testing.T) { request := ReleaseRequest{Validation: ValidationSpec{SharedFiles: tt.input}} mapped := candidateRequest(request).Validation.SharedFiles if (mapped == nil) != tt.wantNil { t.Fatalf("mapped shared files nil=%t, want %t", mapped == nil, tt.wantNil) } if len(mapped) != len(tt.wantValues) { t.Fatalf("mapped shared files = %#v, want %#v", mapped, tt.wantValues) } for index, value := range tt.wantValues { if mapped[index] != value { t.Fatalf("mapped shared files = %#v, want %#v", mapped, tt.wantValues) } } if len(tt.input) != 0 { request.Validation.SharedFiles[0] = "changed" if mapped[0] != tt.wantValues[0] { t.Fatal("mapped shared-file selection aliases the caller's slice") } } }) } }