mirror of
https://gitgud.io/yats/libkiwi.git
synced 2026-05-02 10:42:04 -04:00
Update firebird version
Ditch kiwijar
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
package libkiwi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/y-a-t-s/kiwijar"
|
||||
)
|
||||
|
||||
const TEST_HOST = "kiwifarms.net"
|
||||
@@ -19,13 +16,11 @@ func TestGetPage(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
log.Println("Getting homepage")
|
||||
resp, err := kf.GetPage(ctx, kf.domain)
|
||||
resp, err := kf.GetPage(t.Context(), kf.domain)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
@@ -36,7 +31,7 @@ func TestGetPage(t *testing.T) {
|
||||
}
|
||||
}
|
||||
log.Printf("Response host: %s\n\n", kf.domain)
|
||||
log.Printf("Cookies: %s\n", kf.Client.Jar.(*kiwijar.KiwiJar).CookieString(kf.domain))
|
||||
log.Printf("Cookies: %+v\n", resp.Cookies())
|
||||
}
|
||||
|
||||
func TestRefreshSession(t *testing.T) {
|
||||
@@ -46,24 +41,12 @@ func TestRefreshSession(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
log.Println("Refreshing xf_session")
|
||||
tk, err := kf.RefreshSession(ctx)
|
||||
tk, err := kf.RefreshSession(t.Context())
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("New xf_session token: " + tk)
|
||||
}
|
||||
|
||||
func TestCookieString(t *testing.T) {
|
||||
cookies := os.Getenv("TEST_COOKIES")
|
||||
kf, err := NewKF(http.Client{}, TEST_HOST, cookies)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
log.Println("Cookies from jar: " + kf.Client.Jar.(*kiwijar.KiwiJar).CookieString(kf.domain))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user