Skip to content

Commit

Permalink
Merge pull request #283 from nerdrew/refresh-unittest-protos-from-ups…
Browse files Browse the repository at this point in the history
…tream

consolidate test protos to spec/support/protos
  • Loading branch information
abrandoned committed Feb 1, 2016
2 parents 312f4bd + 39224be commit 9d84055
Show file tree
Hide file tree
Showing 36 changed files with 664 additions and 290 deletions.
2 changes: 1 addition & 1 deletion spec/benchmark/tasks.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'benchmark'
require 'protobuf/socket'
require 'support/all'
require 'support/test/resource_service'
require SUPPORT_PATH.join('resource_service')

case RUBY_ENGINE.to_sym
when :ruby
Expand Down
3 changes: 0 additions & 3 deletions spec/data/data.bin

This file was deleted.

Binary file removed spec/data/types.bin
Binary file not shown.
55 changes: 28 additions & 27 deletions spec/encoding/all_types_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
require 'spec_helper'
require PROTOS_PATH.join('google_unittest.pb')

RSpec.describe ::Protobuf do
it "correctly encodes all types" do
message = GoogleUnittest::TestAllTypes.new(
message = Protobuf_unittest::TestAllTypes.new(
:optional_int32 => 101,
:optional_int64 => 102,
:optional_uint32 => 103,
Expand All @@ -18,16 +19,16 @@
:optional_bool => true,
:optional_string => "115",
:optional_bytes => "116",
:optional_nested_message => GoogleUnittest::TestAllTypes::NestedMessage.new(:bb => 118),
:optional_foreign_message => GoogleUnittest::ForeignMessage.new(:c => 119),
:optional_import_message => GoogleUnittestImport::ImportMessage.new(:d => 120),
:optional_nested_enum => GoogleUnittest::TestAllTypes::NestedEnum::BAZ,
:optional_foreign_enum => GoogleUnittest::ForeignEnum::FOREIGN_BAZ,
:optional_import_enum => GoogleUnittestImport::ImportEnum::IMPORT_BAZ,
:optional_nested_message => Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 118),
:optional_foreign_message => Protobuf_unittest::ForeignMessage.new(:c => 119),
:optional_import_message => Protobuf_unittest_import::ImportMessage.new(:d => 120),
:optional_nested_enum => Protobuf_unittest::TestAllTypes::NestedEnum::BAZ,
:optional_foreign_enum => Protobuf_unittest::ForeignEnum::FOREIGN_BAZ,
:optional_import_enum => Protobuf_unittest_import::ImportEnum::IMPORT_BAZ,
:optional_string_piece => "124",
:optional_cord => "125",
:optional_public_import_message => GoogleUnittestImport::PublicImportMessage.new(:e => 126),
:optional_lazy_message => GoogleUnittest::TestAllTypes::NestedMessage.new(:bb => 127),
:optional_public_import_message => Protobuf_unittest_import::PublicImportMessage.new(:e => 126),
:optional_lazy_message => Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 127),
:repeated_int32 => [201, 301],
:repeated_int64 => [202, 302],
:repeated_uint32 => [203, 303],
Expand All @@ -44,34 +45,34 @@
:repeated_string => ["215", "315"],
:repeated_bytes => ["216", "316"],
:repeated_nested_message => [
::GoogleUnittest::TestAllTypes::NestedMessage.new(:bb => 218),
::GoogleUnittest::TestAllTypes::NestedMessage.new(:bb => 318),
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 218),
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 318),
],
:repeated_foreign_message => [
::GoogleUnittest::ForeignMessage.new(:c => 219),
::GoogleUnittest::ForeignMessage.new(:c => 319),
::Protobuf_unittest::ForeignMessage.new(:c => 219),
::Protobuf_unittest::ForeignMessage.new(:c => 319),
],
:repeated_import_message => [
::GoogleUnittestImport::ImportMessage.new(:d => 220),
::GoogleUnittestImport::ImportMessage.new(:d => 320),
::Protobuf_unittest_import::ImportMessage.new(:d => 220),
::Protobuf_unittest_import::ImportMessage.new(:d => 320),
],
:repeated_nested_enum => [
::GoogleUnittest::TestAllTypes::NestedEnum::BAR,
::GoogleUnittest::TestAllTypes::NestedEnum::BAZ,
::Protobuf_unittest::TestAllTypes::NestedEnum::BAR,
::Protobuf_unittest::TestAllTypes::NestedEnum::BAZ,
],
:repeated_foreign_enum => [
::GoogleUnittest::ForeignEnum::FOREIGN_BAR,
::GoogleUnittest::ForeignEnum::FOREIGN_BAZ,
::Protobuf_unittest::ForeignEnum::FOREIGN_BAR,
::Protobuf_unittest::ForeignEnum::FOREIGN_BAZ,
],
:repeated_import_enum => [
::GoogleUnittestImport::ImportEnum::IMPORT_BAR,
::GoogleUnittestImport::ImportEnum::IMPORT_BAZ,
::Protobuf_unittest_import::ImportEnum::IMPORT_BAR,
::Protobuf_unittest_import::ImportEnum::IMPORT_BAZ,
],
:repeated_string_piece => ["224", "324"],
:repeated_cord => ["225", "325"],
:repeated_lazy_message => [
::GoogleUnittest::TestAllTypes::NestedMessage.new(:bb => 227),
::GoogleUnittest::TestAllTypes::NestedMessage.new(:bb => 327),
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 227),
::Protobuf_unittest::TestAllTypes::NestedMessage.new(:bb => 327),
],
:default_int32 => 401,
:default_int64 => 402,
Expand All @@ -88,14 +89,14 @@
:default_bool => false,
:default_string => "415",
:default_bytes => "416",
:default_nested_enum => ::GoogleUnittest::TestAllTypes::NestedEnum::FOO,
:default_foreign_enum => ::GoogleUnittest::ForeignEnum::FOREIGN_FOO,
:default_import_enum => ::GoogleUnittestImport::ImportEnum::IMPORT_FOO,
:default_nested_enum => ::Protobuf_unittest::TestAllTypes::NestedEnum::FOO,
:default_foreign_enum => ::Protobuf_unittest::ForeignEnum::FOREIGN_FOO,
:default_import_enum => ::Protobuf_unittest_import::ImportEnum::IMPORT_FOO,
:default_string_piece => "424",
:default_cord => "425",
)

data_file_path = File.expand_path('../../support/test/all_types.data.bin', __FILE__)
data_file_path = PROTOS_PATH.join('all_types.data.bin')
data = File.open(data_file_path, 'rb', &:read)
expect(data).to eq(message.serialize_to_string)
end
Expand Down
Binary file modified spec/encoding/extreme_values_spec.rb
Binary file not shown.
2 changes: 1 addition & 1 deletion spec/functional/class_inheritance_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'
require 'spec/support/test/resource_service'
require SUPPORT_PATH.join('resource_service')

RSpec.describe 'works through class inheritance' do
module Corp
Expand Down
2 changes: 1 addition & 1 deletion spec/functional/socket_server_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'
require 'spec/support/test/resource_service'
require SUPPORT_PATH.join('resource_service')

RSpec.describe 'Functional Socket Client' do
before(:all) do
Expand Down
2 changes: 1 addition & 1 deletion spec/functional/zmq_server_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

require 'spec/support/test/resource_service'
require 'protobuf/rpc/service_directory'
require SUPPORT_PATH.join('resource_service')

RSpec.describe 'Functional ZMQ Client' do
before(:all) do
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/protobuf/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

require 'stringio'
require 'spec_helper'
require PROTOS_PATH.join('resource.pb')
require PROTOS_PATH.join('enum.pb')

RSpec.describe Protobuf::Message do

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/protobuf/rpc/client_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'
require 'spec/support/test/resource_service'
require SUPPORT_PATH.join('resource_service')

RSpec.describe Protobuf::Rpc::Client do
before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/protobuf/rpc/servers/socket_server_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'
require 'spec/support/test/resource_service'
require 'protobuf/rpc/servers/socket_runner'
require 'protobuf/socket'
require SUPPORT_PATH.join('resource_service')

RSpec.describe Protobuf::Rpc::Socket::Server do
before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/protobuf/rpc/service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'spec_helper'
require 'spec/support/test/resource_service'
require SUPPORT_PATH.join('resource_service')

RSpec.describe Protobuf::Rpc::Service do

Expand Down
10 changes: 5 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
require 'bundler'
Bundler.setup :default, :development, :test
require 'pry'
require 'pathname'

$LOAD_PATH << ::File.expand_path('../..', __FILE__)
$LOAD_PATH << ::File.expand_path('../support', __FILE__)
SUPPORT_PATH = Pathname.new(::File.expand_path('../support', __FILE__))
PROTOS_PATH = SUPPORT_PATH.join('protos')
$LOAD_PATH << SUPPORT_PATH

require 'protobuf'
require 'protobuf/rpc/server'
require ::File.expand_path('../support/all', __FILE__)
require SUPPORT_PATH.join('all')

$LOAD_PATH << ::File.expand_path("../../lib/protobuf/descriptors", __FILE__)
require 'google/protobuf/compiler/plugin.pb'
Expand All @@ -25,9 +28,6 @@
# Get rid of the deprecation env var if present (messes with specs).
ENV.delete("PB_IGNORE_DEPRECATIONS")

support_proto_glob = File.expand_path('../support/**/*.pb.rb', __FILE__)
Dir[support_proto_glob].each { |proto_file| require proto_file }

RSpec.configure(&:disable_monkey_patching!)

::Protobuf::Rpc::Client.class_eval do
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
##
# Imports
#
require 'test/resource.pb'
require 'protos/resource.pb'

module Test

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto2";

package test;
import 'test/resource.proto';
import 'protos/resource.proto';

// Test extending another message from an imported file.

Expand Down
File renamed without changes.
Binary file added spec/support/protos/google_unittest.bin
Binary file not shown.
Loading

0 comments on commit 9d84055

Please sign in to comment.