feat!: migrate simulate requests to resty v3 and add instance options
This commit is contained in:
+40
-11
@@ -1,19 +1,21 @@
|
||||
package test
|
||||
|
||||
import (
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"git.nite07.com/nite/go-flaresolverr"
|
||||
)
|
||||
|
||||
func TestGetV1(t *testing.T) {
|
||||
f, err := flaresolverr.GetInstance("http://10.10.10.1:8191", "", "socks5://10.10.10.1:7900")
|
||||
f, err := flaresolverr.GetInstance(
|
||||
"http://10.10.10.1:8191",
|
||||
flaresolverr.WithProxy("socks5://10.10.10.1:7900"),
|
||||
)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
resp, err := f.GetV1("https://x1337x.cc/", nil)
|
||||
resp, err := f.GetV1("https://steamrip.com/games-list-page/", nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
@@ -22,19 +24,46 @@ func TestGetV1(t *testing.T) {
|
||||
t.Error("status code != 200", resp.Solution.Status)
|
||||
return
|
||||
}
|
||||
resp2, err := f.SimulateGet("https://x1337x.cc/user/FitGirl/", resp.Solution.UserAgent, resp.Solution.Cookies)
|
||||
resp2, err := f.SimulateGet("https://steamrip.com/games-list-page/", resp.Solution.UserAgent, resp.Solution.Cookies)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if resp2.StatusCode != 200 {
|
||||
t.Error("status code != 200", resp2.StatusCode)
|
||||
return
|
||||
}
|
||||
body, err := io.ReadAll(resp2.Body)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
if resp2.StatusCode() != 200 {
|
||||
t.Error("status code != 200", resp2.StatusCode())
|
||||
return
|
||||
}
|
||||
body := resp2.Bytes()
|
||||
t.Log(string(body))
|
||||
}
|
||||
|
||||
func TestGetV1_2(t *testing.T) {
|
||||
f, err := flaresolverr.GetInstance(
|
||||
"http://10.10.10.1:8191",
|
||||
flaresolverr.WithProxy("socks5://10.10.10.1:7900"),
|
||||
)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
resp, err := f.GetV1("https://1337x.to", nil)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if resp.Solution.Status != 200 {
|
||||
t.Error("status code != 200", resp.Solution.Status)
|
||||
return
|
||||
}
|
||||
resp2, err := f.SimulateGet("https://1337x.to/user/FitGirl/", resp.Solution.UserAgent, resp.Solution.Cookies)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if resp2.StatusCode() != 200 {
|
||||
t.Error("status code != 200", resp2.StatusCode())
|
||||
return
|
||||
}
|
||||
body := resp2.Bytes()
|
||||
t.Log(string(body))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user