replaycli-go/api/dataapi/lib_test.go

83 lines
1.5 KiB
Go
Raw Permalink Normal View History

2021-11-05 13:11:04 +00:00
package dataapi_test
import (
"go.digitalcircle.com.br/open/replaycli-go/api/dataapi"
"log"
"testing"
)
func TestAPIRetrieve(t *testing.T) {
2021-11-05 13:13:48 +00:00
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
2021-11-05 13:11:04 +00:00
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.RETRIEVE,
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPIRetrieveWQuery(t *testing.T) {
2021-11-05 13:13:48 +00:00
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
2021-11-05 13:11:04 +00:00
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.RETRIEVE,
Q: "@[?ID==`2`]",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPIUpdate(t *testing.T) {
2021-11-05 13:13:48 +00:00
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
2021-11-05 13:11:04 +00:00
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.UPDATE,
Id: "2",
Data: map[string]interface{}{
"F2": "Novo Campo",
},
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPIDelete(t *testing.T) {
2021-11-05 13:13:48 +00:00
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
2021-11-05 13:11:04 +00:00
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.DELETE,
Id: "2",
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}
func TestAPICreate(t *testing.T) {
2021-11-05 13:13:48 +00:00
c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo")
2021-11-05 13:11:04 +00:00
res, err := c.Do(&dataapi.DataAPIRequest{
Col: "C1",
Op: dataapi.CREATE,
Data: map[string]interface{}{
"MSG": "OI LEO",
},
})
if err != nil {
t.Fatal(err.Error())
}
log.Printf("%#v", res)
}