Initial call and unit test

This commit is contained in:
Voronsky
2024-06-07 00:01:56 -04:00
parent c7062bdcc7
commit 427e3d2f8d
2 changed files with 115 additions and 0 deletions

25
pterogo_test.go Normal file
View File

@@ -0,0 +1,25 @@
package pterogo
import (
"log"
"log/slog"
"os"
"testing"
"github.com/joho/godotenv"
)
func TestListServers(t *testing.T) {
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
//s, err := listServers()
err := godotenv.Load()
if err != nil {
log.Fatalf(`No env file found`)
}
bearer_auth_token := os.Getenv("PTERO_API_KEY")
s, err := listServers(bearer_auth_token)
if err != nil {
log.Fatalf(`ListServers() = %q, %v, want nil, error`, s, err)
}
logger.Info("Servers queried", "Servers", s)
}