Skip to content

Commit

Permalink
Add docs and failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tonimelisma committed Jan 6, 2021
1 parent feb2425 commit f471817
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vips/color.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Color struct {
R, G, B uint8
}

// Color represents an RGBA
// ColorRGBA represents an RGB with alpha channel (A)
type ColorRGBA struct {
R, G, B, A uint8
}
Expand Down
26 changes: 26 additions & 0 deletions vips/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"runtime"
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -686,6 +687,31 @@ func TestXYZ(t *testing.T) {
require.NoError(t, err)
}

func TestDeprecatedExportParams(t *testing.T) {
Startup(nil)

defaultExportParams := NewDefaultExportParams()
assert.Equal(t, ImageTypeUnknown, defaultExportParams.Format)

pngExportParams := NewPngExportParams()
assert.Equal(t, 6, pngExportParams.Compression)
}

func TestNewImageFromReaderFail(t *testing.T) {
r := strings.NewReader("")
buf, err := NewImageFromReader(r)

assert.Nil(t, buf)
assert.Error(t, err)
}

func TestNewImageFromFileFail(t *testing.T) {
buf, err := NewImageFromFile("/tmp/nonexistent-fasljdfalkjfadlafjladsfkjadfsljafdslk")

assert.Nil(t, buf)
assert.Error(t, err)
}

// TODO unit tests to cover:
// NewImageFromReader failing test
// NewImageFromFile failing test
Expand Down

0 comments on commit f471817

Please sign in to comment.