diff --git a/api/apiproxy/lib_test.go b/api/apiproxy/lib_test.go new file mode 100644 index 0000000..9c46f99 --- /dev/null +++ b/api/apiproxy/lib_test.go @@ -0,0 +1,22 @@ +package apiproxy + +import ( + "log" + "os" + "testing" +) + +func TestCli_Do(t *testing.T) { + os.Setenv("REPLAY_APIKEY", "DONTBOTHER") + os.Setenv("REPLAY_ADDR", "https://localhost:8443") + c := NewCli() + + res, err := c.Do(&APIProxyRequest{ + Method: "GET", + Url: "https://www.slashdot.org", + }) + if err != nil { + t.Fatal(err.Error()) + } + log.Printf("%#v", res) +} diff --git a/api/chrome/cli.go b/api/chrome/cli.go index b557026..a20aa03 100644 --- a/api/chrome/cli.go +++ b/api/chrome/cli.go @@ -41,14 +41,12 @@ func (c *Cli) Eval(id string, s string) (map[string]interface{}, error) { json.Unmarshal(bs, &ret) return ret, err } - func (c *Cli) Wait(id string, s string, to int) (string, error) { ret := "" bs, err := c.HttpCli().RawPost(fmt.Sprintf("/ipc/chrome/wait/%s?to=%d", id, to), []byte(s)) json.Unmarshal(bs, &ret) return ret, err } - func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, error) { ret := "" in := map[string]interface{}{ diff --git a/api/dataapi/lib.go b/api/dataapi/lib.go index bb1e1ba..c91e1e7 100644 --- a/api/dataapi/lib.go +++ b/api/dataapi/lib.go @@ -1,6 +1,7 @@ package dataapi import ( + "go.digitalcircle.com.br/open/replaycli-go/api/replay" "strconv" "time" @@ -63,6 +64,8 @@ func LCR_Create() { } func RegistrarExec(table string, check bool) { + rp := replay.NewCli() + rp.ConfigGet("API_KEY") //Para robôs, age como contador e registra cada repetição no mês c := NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") var registros int diff --git a/api/dataapi/lib_test.go b/api/dataapi/lib_test.go index 7893da8..d3ed1bc 100644 --- a/api/dataapi/lib_test.go +++ b/api/dataapi/lib_test.go @@ -2,6 +2,7 @@ package dataapi_test import ( "log" + "os" "strconv" "testing" "time" @@ -10,7 +11,8 @@ import ( ) func TestAPIRetrieve(t *testing.T) { - c := dataapi.NewCli("RnJpIDA1IE5vdiAyMDIxIDExOjE1OjIyIEFNIFVUQwo") + apikey := os.Getenv("DATAAPI_APIKEY") + c := dataapi.NewCli(apikey) res, err := c.Do(&dataapi.DataAPIRequest{ Col: "teste3", Op: dataapi.RETRIEVE, diff --git a/api/excel/cli.go b/api/excel/cli.go index 5e77793..8d18791 100644 --- a/api/excel/cli.go +++ b/api/excel/cli.go @@ -43,7 +43,6 @@ func (c *Cli) Write(fname string, sheet string, cell string, val string, celtype err := c.HttpCli().JsonPost("/ipc/excel/write", req, &res) return err } - func (c *Cli) New(fname string, sheet string) (string, error) { req := &Req{ File: fname,