25 lines
No EOL
559 B
Go
25 lines
No EOL
559 B
Go
package recognize
|
|
|
|
import (
|
|
"testing"
|
|
"io/ioutil"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestGetImageTags(t *testing.T) {
|
|
if imageBuffer, err := ioutil.ReadFile("cat.jpg"); err != nil {
|
|
t.Error(err)
|
|
} else {
|
|
result, err := GetImageTags(string(imageBuffer))
|
|
|
|
assert.NotNil(t, result)
|
|
assert.Nil(t, err)
|
|
assert.IsType(t, []LabelResult{}, result)
|
|
assert.Equal(t, 5, len(result))
|
|
|
|
assert.Equal(t, "tabby", result[0].Label)
|
|
assert.Equal(t, "tiger cat", result[1].Label)
|
|
|
|
assert.Equal(t, float32(0.23251747), result[1].Probability)
|
|
}
|
|
} |