-
Notifications
You must be signed in to change notification settings - Fork 465
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To ensure that type mapping with the pg gem works as desired.
- Loading branch information
Showing
10 changed files
with
155 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.bundle | ||
vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source "https://rubygems.org" | ||
gem "pg", "~> 1.5.4" | ||
gem "test-unit", "~> 3.6.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
pg (1.5.4) | ||
power_assert (2.0.3) | ||
test-unit (3.6.1) | ||
power_assert | ||
|
||
PLATFORMS | ||
aarch64-linux | ||
arm64-darwin-22 | ||
|
||
DEPENDENCIES | ||
pg (~> 1.5.4) | ||
test-unit (~> 3.6.1) | ||
|
||
BUNDLED WITH | ||
2.4.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
# | ||
# mzcompose — runs Docker Compose with Materialize customizations. | ||
|
||
exec "$(dirname "$0")"/../../../bin/pyactivate -m materialize.cli.mzcompose "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
|
||
from materialize.mzcompose.composition import Composition, Service | ||
from materialize.mzcompose.services.materialized import Materialized | ||
|
||
SERVICES = [ | ||
Materialized(), | ||
Service( | ||
name="ruby", | ||
config={ | ||
"image": "ruby:3.2.2-bookworm", | ||
"volumes": [ | ||
"../../../:/workdir", | ||
], | ||
"environment": [ | ||
"PGHOST=materialized", | ||
], | ||
}, | ||
), | ||
] | ||
|
||
|
||
def workflow_default(c: Composition) -> None: | ||
c.up("materialized") | ||
c.run("ruby", "/workdir/test/lang/ruby/test.sh") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
|
||
require "bundler/setup" | ||
require "pg" | ||
require "test/unit" | ||
|
||
|
||
class MaterializeTest < Test::Unit::TestCase | ||
def connect | ||
PG.connect( | ||
host: ENV["PGHOST"] || "localhost", | ||
port: (ENV["PGPORT"] || 6875).to_i, | ||
dbname: ENV["PGDATABASE"] || "materialize", | ||
user: ENV["PGUSER"] || "materialize", | ||
) | ||
end | ||
|
||
def test_type_map_all_strings | ||
conn = connect | ||
conn.exec("VALUES ('a'::text, 1::integer, '2023-01-01T01:23:45'::timestamp), ('b', NULL, NULL) ORDER BY 1") do |result| | ||
assert_equal(result.collect.to_a, [ | ||
{"column1" => "a", "column2" => "1", "column3" => "2023-01-01 01:23:45"}, | ||
{"column1" => "b", "column2" => nil, "column3" => nil} | ||
]) | ||
end | ||
end | ||
|
||
def test_type_map_basic_type_map | ||
conn = connect | ||
conn.type_map_for_results = PG::BasicTypeMapForResults.new(conn) | ||
conn.exec("VALUES ('a'::text, 1::integer, '2023-01-01T01:23:45'::timestamp), ('b', NULL, NULL) ORDER BY 1") do |result| | ||
assert_equal(result.collect.to_a, [ | ||
{"column1" => "a", "column2" => 1, "column3" => Time.new(2023, 1, 1, 1, 23, 45)}, | ||
{"column1" => "b", "column2" => nil, "column3" => nil} | ||
]) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Copyright Materialize, Inc. and contributors. All rights reserved. | ||
# | ||
# Use of this software is governed by the Business Source License | ||
# included in the LICENSE file at the root of this repository. | ||
# | ||
# As of the Change Date specified in that file, in accordance with | ||
# the Business Source License, use of this software will be governed | ||
# by the Apache License, Version 2.0. | ||
# | ||
# test.sh — run Ruby language tests. | ||
|
||
set -euo pipefail | ||
|
||
cd "$(dirname "$0")/../../.." | ||
|
||
. misc/shlib/shlib.bash | ||
|
||
cd test/lang/ruby | ||
|
||
bundle install | ||
|
||
try ruby test.rb | ||
|
||
try_status_report |