(t *testing.T)
| 18 | ) |
| 19 | |
| 20 | func TestUnixSocketConnection(t *testing.T) { |
| 21 | // PostgreSQL expects socket files named .s.PGSQL.<port> in the directory |
| 22 | sock := testutil.StartDummyUnixSocket(t, "postgres-socket-test", ".s.PGSQL.5432") |
| 23 | defer sock.Close() |
| 24 | |
| 25 | config := database.Config{ |
| 26 | DbName: "testdb", |
| 27 | User: "testuser", |
| 28 | Password: "testpass", |
| 29 | Socket: sock.Dir, |
| 30 | Port: 5432, |
| 31 | } |
| 32 | |
| 33 | db, err := NewDatabase(config) |
| 34 | if err != nil { |
| 35 | t.Fatalf("NewDatabase failed: %v", err) |
| 36 | } |
| 37 | defer db.Close() |
| 38 | |
| 39 | err = db.DB().Ping() |
| 40 | if err == nil { |
| 41 | t.Fatal("expected connection to fail with protocol error") |
| 42 | } |
| 43 | |
| 44 | // "connection refused" means socket path was not used (fell back to TCP). |
| 45 | // Any other error (e.g., protocol error) indicates the socket was used. |
| 46 | if strings.Contains(err.Error(), "connection refused") { |
| 47 | t.Errorf("expected socket to be used, got: %v", err) |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | // TestExtensionOIDCollisionByInjectedDependency verifies that ExportDDLs correctly |
| 52 | // handles OID collisions between user objects and extension objects. |
nothing calls this directly
no test coverage detected