package utils import ( "reflect" "testing" ) func TestCompressImage(t *testing.T) { type args struct { filename string } tests := []struct { name string args args wantErr bool }{ { args: args{filename: "../../runtime/tmp/8_24.png"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if err := CompressImage(tt.args.filename, "../../runtime/tmp/compress.png"); err != nil { t.Errorf("CompressImage() error = %v", err) } }) } } func TestCompressJPG(t *testing.T) { type args struct { dst string newDst string } tests := []struct { name string args args wantErr bool }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if err := CompressJPG(tt.args.dst, tt.args.newDst); (err != nil) != tt.wantErr { t.Errorf("CompressJPG() error = %v, wantErr %v", err, tt.wantErr) } }) } } func TestResizeImg(t *testing.T) { type args struct { url string } tests := []struct { name string args args wantNewImgPath string wantErr bool }{ { args: args{url: "https://cdns.fontree.cn/fonchain-main/dev/file/artwork/config/1234.jpg"}, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { gotNewImgPath, err := ResizeImg(tt.args.url) if err != nil { t.Errorf("ResizeImg() error = %v", err) return } t.Logf("gotNewImgPath--%s", gotNewImgPath) }) } } func Test_compressImageResource(t *testing.T) { type args struct { data []byte } tests := []struct { name string args args want []byte }{ // TODO: Add test cases. } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := compressImageResource(tt.args.data); !reflect.DeepEqual(got, tt.want) { t.Errorf("compressImageResource() = %v, want %v", got, tt.want) } }) } }