toorop / go-dkim

DKIM package for golang
MIT License
98 stars 39 forks source link

unit test fails #11

Closed vodolaz095 closed 5 years ago

vodolaz095 commented 6 years ago

go version go1.9.7 linux/amd64

git commit hash - 83672023c79e6b352bf9d4908e6c060c7a24323c

[vodolaz095@tractor go-dkim]$ go test -v
=== RUN   Test_NewSigOptions
--- PASS: Test_NewSigOptions (0.00s)
=== RUN   Test_SignConfig
--- PASS: Test_SignConfig (0.01s)
=== RUN   Test_canonicalize
--- PASS: Test_canonicalize (0.00s)
=== RUN   Test_Sign
--- PASS: Test_Sign (0.01s)
=== RUN   Test_Verify
--- FAIL: Test_Verify (0.47s)
    dkim_test.go:350: 
            Error Trace:    dkim_test.go:350
            Error:          Not equal: 
                            expected: &errors.errorString{s:"body hash did not verify"}
                            actual  : &errors.errorString{s:"no key for verify"}

                            Diff:
                            --- Expected
                            +++ Actual
                            @@ -1,2 +1,2 @@
                            -(*errors.errorString)(body hash did not verify)
                            +(*errors.errorString)(no key for verify)

            Test:           Test_Verify
    dkim_test.go:351: 
            Error Trace:    dkim_test.go:351
            Error:          Not equal: 
                            expected: 6
                            actual  : 2
            Test:           Test_Verify
    dkim_test.go:375: 
            Error Trace:    dkim_test.go:375
            Error:          Received unexpected error:
                            no key for verify
            Test:           Test_Verify
    dkim_test.go:376: 
            Error Trace:    dkim_test.go:376
            Error:          Not equal: 
                            expected: 1
                            actual  : 2
            Test:           Test_Verify
    dkim_test.go:381: 
            Error Trace:    dkim_test.go:381
            Error:          Received unexpected error:
                            no key for verify
            Test:           Test_Verify
    dkim_test.go:382: 
            Error Trace:    dkim_test.go:382
            Error:          Not equal: 
                            expected: 1
                            actual  : 2
            Test:           Test_Verify
FAIL
exit status 1
FAIL    github.com/toorop/go-dkim   0.492s
dcormier commented 5 years ago

Can I just change these tests to pass with the existing code?


Edit: I'm guessing these failures are all because some DNS records changed. With my current PR (#15), I can also make a change to allow for hooking the TXT record lookup function for tests. It would be non-breaking for existing consumers of the package. Then I could return some specific DNS record so the tests are properly exercising the code. If you know what the TXT record should have been that would help, but I can probably figure it out if needed.


Edit 2: You can see what these changes would look like here. With those changes, based on what's already in my existing PR (#15), all tests pass for me locally. I did have to comment out one test case. I left a comment explaining the situation.