package copydesk import "testing" func TestCopyFileScopeRejectsExtraFiles(t *testing.T) { before := map[string][]byte{"app.go": []byte(`var title="Old words"`), "app_test.go": []byte(`want:="Old words"; check(ok)`)} after := map[string][]byte{"app.go": []byte(`var title="New words"`), "app_test.go": []byte(`want:="New words"; check(ok)`)} ex := []Literal{{Key: "title", Path: "app.go", Start: 11, End: 20, Text: "Old words"}} r := Review{Version: 1, Strings: []Wording{{Key: "title", Text: "New words", Action: "accept"}}} if err := ValidateFiles(before, after, ex, r, []string{}, true); err != nil { t.Fatal(err) } after["app_test.go"] = []byte(`want:="New words"; check(true)`) if ValidateFiles(before, after, ex, r, nil, true) == nil { t.Fatal("test logic edit accepted") } after["app_test.go"] = before["app_test.go"] after["evil.go"] = []byte("bad") if ValidateFiles(before, after, ex, r, nil, true) == nil { t.Fatal("new file accepted") } }