chore: establish local platform baseline
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package deviceauth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"data-terminal-cloud/internal/database"
|
||||
)
|
||||
|
||||
func TestRepositoryFindsRegisteredDeviceWithoutCredentialMaterial(t *testing.T) {
|
||||
databaseURL := os.Getenv("TEST_DATABASE_URL")
|
||||
if databaseURL == "" {
|
||||
t.Skip("TEST_DATABASE_URL is not set")
|
||||
}
|
||||
ctx := context.Background()
|
||||
pool, err := database.Open(ctx, databaseURL, "device-auth-integration-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer pool.Close()
|
||||
repository := NewRepository(pool)
|
||||
identity, err := repository.FindByPublicID(ctx, "10000000-0000-0000-0000-000000000511")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if identity.Status != "registered" || identity.TenantID != "10000000-0000-0000-0000-000000000001" || identity.CredentialRef == "" {
|
||||
t.Fatalf("identity = %#v", identity)
|
||||
}
|
||||
if _, err := repository.FindByPublicID(ctx, "30000000-0000-0000-0000-000000000511"); !errors.Is(err, ErrDeviceNotFound) {
|
||||
t.Fatalf("missing device error = %v", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user