mirror of
https://github.com/TecharoHQ/anubis.git
synced 2026-04-11 19:18:46 +00:00
chore: expose thoth in lib
Imports a patch previously exclusive to Botstopper. Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
36
lib/thoth/thoth_test.go
Normal file
36
lib/thoth/thoth_test.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package thoth_test
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/TecharoHQ/anubis/lib/thoth"
|
||||
"github.com/TecharoHQ/anubis/lib/thoth/thothmock"
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
func loadSecrets(t testing.TB) *thoth.Client {
|
||||
t.Helper()
|
||||
|
||||
if err := godotenv.Load(); err != nil {
|
||||
t.Log("using mock thoth")
|
||||
result := &thoth.Client{}
|
||||
result.WithIPToASNService(thothmock.MockIpToASNService())
|
||||
return result
|
||||
}
|
||||
|
||||
cli, err := thoth.New(t.Context(), os.Getenv("THOTH_URL"), os.Getenv("THOTH_API_KEY"), false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
return cli
|
||||
}
|
||||
|
||||
func TestNew(t *testing.T) {
|
||||
cli := loadSecrets(t)
|
||||
|
||||
if err := cli.Close(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user