forked from quic-go/quic-go
change tests such that they are covered by coverage reports
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package qerr_test
|
||||
package qerr
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
@@ -7,8 +7,6 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/qerr"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@@ -28,8 +26,8 @@ var _ = Describe("error codes", func() {
|
||||
valString := c.(*ast.ValueSpec).Values[0].(*ast.BasicLit).Value
|
||||
val, err := strconv.Atoi(valString)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(qerr.ErrorCode(val).String()).To(Equal(name))
|
||||
Expect(ErrorCode(val).String()).To(Equal(name))
|
||||
}
|
||||
Expect(qerr.ErrorCode(0).String()).To(Equal("ErrorCode(0)"))
|
||||
Expect(ErrorCode(0).String()).To(Equal("ErrorCode(0)"))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package qerr_test
|
||||
package qerr
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
package qerr_test
|
||||
package qerr
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/lucas-clemente/quic-go/qerr"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
@@ -12,31 +10,31 @@ import (
|
||||
var _ = Describe("Quic error", func() {
|
||||
Context("QuicError", func() {
|
||||
It("has a string representation", func() {
|
||||
err := qerr.Error(qerr.DecryptionFailure, "foobar")
|
||||
err := Error(DecryptionFailure, "foobar")
|
||||
Expect(err.Error()).To(Equal("DecryptionFailure: foobar"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("ErrorCode", func() {
|
||||
It("works as error", func() {
|
||||
var err error = qerr.DecryptionFailure
|
||||
var err error = DecryptionFailure
|
||||
Expect(err).To(MatchError("DecryptionFailure"))
|
||||
})
|
||||
})
|
||||
|
||||
Context("ToQuicError", func() {
|
||||
It("leaves QuicError unchanged", func() {
|
||||
err := qerr.Error(qerr.DecryptionFailure, "foo")
|
||||
Expect(qerr.ToQuicError(err)).To(Equal(err))
|
||||
err := Error(DecryptionFailure, "foo")
|
||||
Expect(ToQuicError(err)).To(Equal(err))
|
||||
})
|
||||
|
||||
It("wraps ErrorCode properly", func() {
|
||||
var err error = qerr.DecryptionFailure
|
||||
Expect(qerr.ToQuicError(err)).To(Equal(qerr.Error(qerr.DecryptionFailure, "")))
|
||||
var err error = DecryptionFailure
|
||||
Expect(ToQuicError(err)).To(Equal(Error(DecryptionFailure, "")))
|
||||
})
|
||||
|
||||
It("changes default errors to InternalError", func() {
|
||||
Expect(qerr.ToQuicError(io.EOF)).To(Equal(qerr.Error(qerr.InternalError, "EOF")))
|
||||
Expect(ToQuicError(io.EOF)).To(Equal(Error(InternalError, "EOF")))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user