invidious/lib/pg/spec/pq/param_spec.cr
Leon Klingele 40fb17791e
shard: track dependencies
Commit the whole ./lib/ folder which stores the Crystal dependencies.
This has a few benefits:

- Allows to build the project without a connection to the Internet
  to retrieve dependencies.
- Makes the project resistant against dependency re-tags which might
  include malicious code.
2019-08-15 01:51:27 +02:00

24 lines
742 B
Crystal

require "spec"
require "../../src/pq/param"
private def it_encodes_array(value, encoded)
it "encodes #{value.class}" do
PQ::Param.encode_array(value).should eq encoded
end
end
describe PQ::Param do
describe "encoders" do
describe "#encode_array" do
it_encodes_array([] of String, "{}")
it_encodes_array([true, false, true], "{t,f,t}")
it_encodes_array(["t", "f", "t"], %({"t","f","t"}))
it_encodes_array([1, 2, 3], "{1,2,3}")
it_encodes_array([1.2, 3.4, 5.6], "{1.2,3.4,5.6}")
it_encodes_array([%(a), %(\\b~), %(c\\"d), %(\uFF8F)], %({"a","\\\\b~","c\\\\\\"d","\uFF8F"}))
it_encodes_array(["baz, bar"], %({"baz, bar"}))
it_encodes_array(["foo}"], %({"foo}"}))
end
end
end