Skip to content

Commit

Permalink
Add e2E tests for new options.
Browse files Browse the repository at this point in the history
Addresses #8.
  • Loading branch information
thesamet committed Jan 18, 2015
1 parent d31ada9 commit 5837498
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions e2e/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ PB.protobufSettings

PB.scalapbVersion in PB.protobufConfig := com.trueaccord.scalapb.Version.scalapbVersion

PB.includePaths in PB.protobufConfig ++= Seq(file("../vendor"), file("../protobuf"))

PB.javaConversions in PB.protobufConfig := true

libraryDependencies ++= Seq(
Expand Down
23 changes: 23 additions & 0 deletions e2e/src/main/protobuf/flat.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.trueaccord.proto.e2e;

import "scalapb.proto";

import "one_of.proto"; // testing an import of non-flat proto

option (scalapb.options) = {
package_name: "com.trueaccord.pb.flat"
flat_package: true
};

enum Priority {
LOW = 1;
MEDIUM = 2;
HIGH = 3;
}

message FlatTest {
optional int32 b = 1;
optional Priority priority = 2;
optional OneofTest one_of_msg = 3;
}

5 changes: 5 additions & 0 deletions e2e/src/main/protobuf/repeatables.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.trueaccord.proto.e2e;

option java_outer_classname = "Reps";

import "flat.proto";

message RepeatablesTest {
repeated string strings = 1;
repeated int32 ints = 2;
Expand All @@ -11,4 +13,7 @@ message RepeatablesTest {
message Nested {
optional int32 nested_field = 1;
}

// testing inclusion of a proto compiled with flat_package=true.
optional FlatTest flat_test = 5;
}
13 changes: 13 additions & 0 deletions e2e/src/test/scala/FlatPackageSpec.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import com.trueaccord.proto.e2e.one_of._
import com.trueaccord.pb.flat.Priority
import com.trueaccord.pb.flat.FlatTest
import org.scalatest._

class FlatPackageSpec extends FlatSpec with MustMatchers {

"FlatTest" should "serialize and parse" in {
val ft = FlatTest(b=Some(4), priority=Some(Priority.MEDIUM),
oneOfMsg=Some(OneofTest(a=Some(4))))
FlatTest.parseFrom(ft.toByteArray) must be(ft)
}
}

0 comments on commit 5837498

Please sign in to comment.