Files
spoolweight/spooldb/client_test.go
T

41 lines
1014 B
Go
Raw Normal View History

package spooldb
import (
"context"
"os"
"testing"
"time"
)
// TestSpoolLocation is a live integration test against 3dfilamentprofiles.com.
// It is skipped unless SPOOLDB_USER and SPOOLDB_PASS are set. The spool to look
// up defaults to the sample spool but can be overridden with SPOOL_ID.
func TestSpoolLocation(t *testing.T) {
email, pass := os.Getenv("SPOOLDB_USER"), os.Getenv("SPOOLDB_PASS")
if email == "" || pass == "" {
t.Skip("set SPOOLDB_USER and SPOOLDB_PASS to run the live integration test")
}
spoolID := os.Getenv("SPOOL_ID")
if spoolID == "" {
spoolID = "fU9zkaRWB"
}
c, err := New()
if err != nil {
t.Fatalf("new client: %v", err)
}
defer c.Close()
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancel()
if err := c.Login(ctx, email, pass); err != nil {
t.Fatalf("login: %v", err)
}
loc, err := c.SpoolLocation(ctx, spoolID)
if err != nil {
t.Fatalf("spool location: %v", err)
}
t.Logf("spool %s location: %q", spoolID, loc)
}