1// +build go1.3,!plan9,!solaris
11func (vt *ValidatorTest) UpdateEmailFile(t *testing.T, emails []string) {
13 vt.auth_email_file, err = os.OpenFile(
14 vt.auth_email_file.Name(), os.O_WRONLY|os.O_CREATE, 0600)
16 t.Fatal("failed to re-open temp file for updates")
18 vt.WriteEmails(t, emails)
21func (vt *ValidatorTest) UpdateEmailFileViaRenameAndReplace(
22 t *testing.T, emails []string) {
23 orig_file := vt.auth_email_file
25 vt.auth_email_file, err = ioutil.TempFile("", "test_auth_emails_")
27 t.Fatal("failed to create temp file for rename and replace: " +
30 vt.WriteEmails(t, emails)
32 moved_name := orig_file.Name() + "-moved"
33 err = os.Rename(orig_file.Name(), moved_name)
34 err = os.Rename(vt.auth_email_file.Name(), orig_file.Name())
36 t.Fatal("failed to rename and replace temp file: " +
39 vt.auth_email_file = orig_file
43func TestValidatorOverwriteEmailListDirectly(t *testing.T) {
44 vt := NewValidatorTest(t)
47 vt.WriteEmails(t, []string{
51 domains := []string(nil)
52 updated := make(chan bool)
53 validator := vt.NewValidator(domains, updated)
55 if !validator("xyzzy@example.com") {
56 t.Error("first email in list should validate")
58 if !validator("plugh@example.com") {
59 t.Error("second email in list should validate")
61 if validator("xyzzy.plugh@example.com") {
62 t.Error("email not in list that matches no domains " +
63 "should not validate")
66 vt.UpdateEmailFile(t, []string{
67 "xyzzy.plugh@example.com",
72 if validator("xyzzy@example.com") {
73 t.Error("email removed from list should not validate")
75 if !validator("plugh@example.com") {
76 t.Error("email retained in list should validate")
78 if !validator("xyzzy.plugh@example.com") {
79 t.Error("email added to list should validate")
83func TestValidatorOverwriteEmailListViaRenameAndReplace(t *testing.T) {
84 vt := NewValidatorTest(t)
87 vt.WriteEmails(t, []string{"xyzzy@example.com"})
88 domains := []string(nil)
89 updated := make(chan bool)
90 validator := vt.NewValidator(domains, updated)
92 if !validator("xyzzy@example.com") {
93 t.Error("email in list should validate")
96 vt.UpdateEmailFileViaRenameAndReplace(t, []string{"plugh@example.com"})
99 if validator("xyzzy@example.com") {
100 t.Error("email removed from list should not validate")
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list