mirror of
https://gitlab.52pay.top/go/easygoadmin.git
synced 2025-09-26 22:47:58 +08:00
65 lines
1.2 KiB
Go
65 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"gitlab.52pay.top/go/easygoadmin/app/model"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestUserImage_Insert(t *testing.T) {
|
|
image := &model.UserImage{
|
|
Image: []byte("test image"),
|
|
Created: time.Now(),
|
|
}
|
|
_, err := image.Insert()
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.Fail()
|
|
}
|
|
t.Log("insert ok, id is", image.Id())
|
|
}
|
|
|
|
func TestUserImage_Get(t *testing.T) {
|
|
image := &model.UserImage{
|
|
Image: []byte("test image"),
|
|
Model: "test",
|
|
MId: "123",
|
|
Created: time.Now(),
|
|
}
|
|
_, err := image.Insert()
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.Fail()
|
|
}
|
|
image2 := new(model.UserImage)
|
|
err = image2.Get(image.Id())
|
|
if err != nil {
|
|
t.Error(err)
|
|
t.Fail()
|
|
}
|
|
fmt.Println(image2.Model)
|
|
}
|
|
|
|
func TestExportUserImage(t *testing.T) {
|
|
img := model.ExportUserImage("http://127.0.0.1:9011/img/avatar/6367d24adff5ddb91b5e07f9.png")
|
|
if img == nil {
|
|
t.Error("查询失败")
|
|
return
|
|
}
|
|
if img.Image != nil {
|
|
t.Error("查询错误")
|
|
return
|
|
}
|
|
fmt.Println(img.FileType)
|
|
}
|
|
|
|
func TestExportUserImageId(t *testing.T) {
|
|
imgUrl := "http://127.0.0.1:9011/img/avatar/6367d24adff5ddb91b5e07f9.png"
|
|
id := model.ExportUserImageId(imgUrl)
|
|
if id == "" {
|
|
t.Error("查询失败")
|
|
return
|
|
}
|
|
}
|