|
| 1 | +# Copyright 2026 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +"""Helper functions for compliance tests.""" |
| 15 | + |
| 16 | +import os |
| 17 | + |
| 18 | +SPANNER_EMULATOR_HOST = os.environ.get("SPANNER_EMULATOR_HOST") |
| 19 | + |
| 20 | +PROJECT_ID = "test-project" |
| 21 | +INSTANCE_ID = "test-instance" |
| 22 | +DATABASE_ID = "test-db" |
| 23 | + |
| 24 | +EMULATOR_TEST_CONNECTION_STRING = ( |
| 25 | + f"{SPANNER_EMULATOR_HOST}" |
| 26 | + f"projects/{PROJECT_ID}" |
| 27 | + f"/instances/{INSTANCE_ID}" |
| 28 | + f"/databases/{DATABASE_ID}" |
| 29 | + "?autoConfigEmulator=true" |
| 30 | +) |
| 31 | + |
| 32 | + |
| 33 | +def setup_test_env() -> None: |
| 34 | + print(f"Set SPANNER_EMULATOR_HOST to {os.environ['SPANNER_EMULATOR_HOST']}") |
| 35 | + print(f"Using Connection String: {get_test_connection_string()}") |
| 36 | + |
| 37 | + |
| 38 | +def get_test_connection_string() -> str: |
| 39 | + return EMULATOR_TEST_CONNECTION_STRING |
0 commit comments