Fix the Download Process tests
This commit is contained in:
parent
18b212985d
commit
00b0649296
3 changed files with 29 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
package dashboard
|
package dashboard
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
|
@ -45,6 +46,8 @@ func TestProcessComponent(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(res)
|
||||||
|
|
||||||
pets, ok := res.([]maps.MapStr)
|
pets, ok := res.([]maps.MapStr)
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
assert.Equal(t, 2, len(pets))
|
assert.Equal(t, 2, len(pets))
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package form
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -152,7 +153,8 @@ func TestProcessDelete(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = process.New("yao.form.find", "pet", 1).Exec()
|
res, err := process.New("yao.form.find", "pet", 1).Exec()
|
||||||
|
fmt.Println("err", res, err)
|
||||||
assert.Contains(t, err.Error(), "ID=1")
|
assert.Contains(t, err.Error(), "ID=1")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -251,8 +253,18 @@ func TestProcessDownload(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
body, ok := res.(map[string]interface{})
|
body, ok := res.(map[string]interface{})
|
||||||
|
reader, ok := body["content"].(io.ReadCloser)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("content not found")
|
||||||
|
}
|
||||||
|
defer reader.Close()
|
||||||
|
content, err := io.ReadAll(reader)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
assert.Equal(t, []byte("Hello"), body["content"])
|
assert.Equal(t, []byte("Hello"), content)
|
||||||
assert.Equal(t, "text/plain; charset=utf-8", body["type"])
|
assert.Equal(t, "text/plain; charset=utf-8", body["type"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package table
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -451,8 +452,18 @@ func TestProcessDownload(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
body, ok := res.(map[string]interface{})
|
body, ok := res.(map[string]interface{})
|
||||||
|
reader, ok := body["content"].(io.ReadCloser)
|
||||||
|
if !ok {
|
||||||
|
t.Fatal("content not found")
|
||||||
|
}
|
||||||
|
defer reader.Close()
|
||||||
|
content, err := io.ReadAll(reader)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
assert.True(t, ok)
|
assert.True(t, ok)
|
||||||
assert.Equal(t, []byte("Hello"), body["content"])
|
assert.Equal(t, []byte("Hello"), content)
|
||||||
assert.Equal(t, "text/plain; charset=utf-8", body["type"])
|
assert.Equal(t, "text/plain; charset=utf-8", body["type"])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue