update: improve coverage
This commit is contained in:
parent
dde42d81d9
commit
b779448fcd
|
@ -1,6 +1,6 @@
|
|||
> Package captcha provides a simple API for captcha generation
|
||||
|
||||
<div align="center">
|
||||
<div>
|
||||
|
||||
[![GoDoc](https://godoc.org/github.com/steambap/captcha?status.svg)](https://godoc.org/github.com/steambap/captcha)
|
||||
[![Build Status](https://travis-ci.org/steambap/captcha.svg)](https://travis-ci.org/steambap/captcha)
|
||||
|
|
|
@ -2,10 +2,12 @@ package captcha
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"image/color"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNewCaptcha(t *testing.T) {
|
||||
New(36, 12)
|
||||
data, err := New(150, 50)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
@ -13,3 +15,24 @@ func TestNewCaptcha(t *testing.T) {
|
|||
buf := new(bytes.Buffer)
|
||||
data.WriteTo(buf)
|
||||
}
|
||||
|
||||
func TestNewCaptchaOptions(t *testing.T) {
|
||||
New(100, 34, func(options *Options) {
|
||||
options.BackgroundColor = color.Opaque
|
||||
options.CharPreset = "1234567890"
|
||||
options.CurveNumber = 0
|
||||
options.TextLength = 6
|
||||
})
|
||||
}
|
||||
|
||||
func TestCovNilFontError(t *testing.T) {
|
||||
temp := ttfFont
|
||||
ttfFont = nil
|
||||
|
||||
_, err := New(150, 50)
|
||||
if err == nil {
|
||||
t.Fatal("Expect to get nil font error")
|
||||
}
|
||||
|
||||
ttfFont = temp
|
||||
}
|
||||
|
|
Reference in New Issue