Skip to content

Commit

Permalink
test(spanner): add PG.OID tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hengfengli committed Nov 14, 2023
1 parent a0748fb commit 13e77c5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require "spanner_helper"

describe "Spanner Client", :params, :bool, :spanner do
let(:db) { spanner_pg_client }

it "queries and returns a PG.OID parameter" do
skip if emulator_enabled?
results = db.execute_query "SELECT $1 AS value", params: { p1: 123 }, types: { p1: :PG_OID }

_(results).must_be_kind_of Google::Cloud::Spanner::Results
_(results.fields[:value]).must_equal :INT64
_(results.rows.first[:value]).must_equal 123
end
end
29 changes: 29 additions & 0 deletions google-cloud-spanner/acceptance/spanner/client/types/pgoid_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

require "spanner_helper"

describe "Spanner Client", :types, :oid, :spanner do
let(:db) { spanner_pg_client }
let(:table_name) { "stuffs" }

it "queries pg.oid" do
skip if emulator_enabled?
results = db.execute_sql "select 123::oid as value"

_(results).must_be_kind_of Google::Cloud::Spanner::Results
_(results.fields.to_h).must_equal({ value: :INT64 })
_(results.rows.first.to_h).must_equal({ value: 123 })
end
end

0 comments on commit 13e77c5

Please sign in to comment.