(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func TestEvaluateAlignment(t *testing.T) { |
| 32 | type tCase struct { |
| 33 | fromDomain string |
| 34 | record *Record |
| 35 | results []authres.Result |
| 36 | |
| 37 | output authres.ResultValue |
| 38 | } |
| 39 | test := func(i int, c tCase) { |
| 40 | out := EvaluateAlignment(c.fromDomain, c.record, c.results) |
| 41 | t.Logf("%d - %+v", i, out) |
| 42 | if out.Authres.Value != c.output { |
| 43 | t.Errorf("%d: Wrong eval result, want '%s', got '%s' (%+v)", i, c.output, out.Authres.Value, out) |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | cases := []tCase{ |
| 48 | { // 0 |
| 49 | fromDomain: "example.org", |
| 50 | record: &Record{}, |
| 51 | |
| 52 | output: authres.ResultNone, |
| 53 | }, |
| 54 | { // 1 |
| 55 | fromDomain: "example.org", |
| 56 | record: &Record{}, |
| 57 | results: []authres.Result{ |
| 58 | &authres.SPFResult{ |
| 59 | Value: authres.ResultFail, |
| 60 | From: "example.org", |
| 61 | Helo: "mx.example.org", |
| 62 | }, |
| 63 | &authres.DKIMResult{ |
| 64 | Value: authres.ResultNone, |
| 65 | Domain: "example.org", |
| 66 | }, |
| 67 | }, |
| 68 | output: authres.ResultFail, |
| 69 | }, |
| 70 | { // 2 |
| 71 | fromDomain: "example.org", |
| 72 | record: &Record{}, |
| 73 | results: []authres.Result{ |
| 74 | &authres.SPFResult{ |
| 75 | Value: authres.ResultPass, |
| 76 | From: "example.org", |
| 77 | Helo: "mx.example.org", |
| 78 | }, |
| 79 | &authres.DKIMResult{ |
| 80 | Value: authres.ResultNone, |
| 81 | Domain: "example.org", |
| 82 | }, |
| 83 | }, |
| 84 | output: authres.ResultPass, |
| 85 | }, |
| 86 | { // 3 |
| 87 | fromDomain: "example.org", |
| 88 | record: &Record{}, |
nothing calls this directly
no test coverage detected