Skip to content

Commit

Permalink
Fix go tests
Browse files Browse the repository at this point in the history
Expected output needed to be updated for the
int 64 as strings vs int 32 as numbers change.

Wrappers was expected for the well known types
but it is one of the ignored files. Referencing
Empty as well means we have one ignored and one
non-ignored file.

Wrapped each dir in t.Run so they will each run
even if one fails.
  • Loading branch information
davcamer committed Aug 12, 2018
1 parent 5a1f746 commit 8c189ac
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 285 deletions.
27 changes: 15 additions & 12 deletions protoc-gen-elm/go_tests/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -21,21 +22,23 @@ func TestDiff(t *testing.T) {
continue
}

dir := filepath.Join(td, fi.Name())
actualOutputDir := filepath.Join(dir, "actual_output")
t.Run(fmt.Sprintf("generating in directory %s", fi.Name()), func (t *testing.T) {
dir := filepath.Join(td, fi.Name())
actualOutputDir := filepath.Join(dir, "actual_output")

err := os.RemoveAll(actualOutputDir)
if err != nil {
t.Fatal(err)
}
err := os.RemoveAll(actualOutputDir)
if err != nil {
t.Fatal(err)
}

err = os.MkdirAll(actualOutputDir, 0777)
if err != nil {
t.Fatal(err)
}
err = os.MkdirAll(actualOutputDir, 0777)
if err != nil {
t.Fatal(err)
}

runProto(t, dir)
runDiff(t, dir)
runProto(t, dir)
runDiff(t, dir)
})
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ firstOneofDecoder : JD.Decoder FirstOneof
firstOneofDecoder =
JD.lazy <| \_ -> JD.oneOf
[ JD.map StringField (JD.field "stringField" JD.string)
, JD.map IntField (JD.field "intField" JD.int)
, JD.map IntField (JD.field "intField" intDecoder)
, JD.succeed FirstOneofUnspecified
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type alias SubMessage =
subMessageDecoder : JD.Decoder SubMessage
subMessageDecoder =
JD.lazy <| \_ -> decode SubMessage
|> required "int32Field" JD.int 0
|> required "int32Field" intDecoder 0


subMessageEncoder : SubMessage -> JE.Value
Expand Down Expand Up @@ -117,21 +117,21 @@ fooDecoder =
JD.lazy <| \_ -> decode Foo
|> required "doubleField" JD.float 0.0
|> required "floatField" JD.float 0.0
|> required "int32Field" JD.int 0
|> required "int64Field" JD.int 0
|> required "uint32Field" JD.int 0
|> required "uint64Field" JD.int 0
|> required "sint32Field" JD.int 0
|> required "sint64Field" JD.int 0
|> required "fixed32Field" JD.int 0
|> required "fixed64Field" JD.int 0
|> required "sfixed32Field" JD.int 0
|> required "sfixed64Field" JD.int 0
|> required "int32Field" intDecoder 0
|> required "int64Field" intDecoder 0
|> required "uint32Field" intDecoder 0
|> required "uint64Field" intDecoder 0
|> required "sint32Field" intDecoder 0
|> required "sint64Field" intDecoder 0
|> required "fixed32Field" intDecoder 0
|> required "fixed64Field" intDecoder 0
|> required "sfixed32Field" intDecoder 0
|> required "sfixed64Field" intDecoder 0
|> required "boolField" JD.bool False
|> required "stringField" JD.string ""
|> required "enumField" enumDecoder enumDefault
|> optional "subMessage" subMessageDecoder
|> repeated "repeatedInt64Field" JD.int
|> repeated "repeatedInt64Field" intDecoder
|> repeated "repeatedEnumField" enumDecoder
|> optional "nestedMessageField" foo_NestedMessageDecoder
|> required "nestedEnumField" foo_NestedEnumDecoder foo_NestedEnumDefault
Expand Down Expand Up @@ -161,20 +161,20 @@ fooEncoder v =
[ (requiredFieldEncoder "doubleField" JE.float 0.0 v.doubleField)
, (requiredFieldEncoder "floatField" JE.float 0.0 v.floatField)
, (requiredFieldEncoder "int32Field" JE.int 0 v.int32Field)
, (requiredFieldEncoder "int64Field" JE.int 0 v.int64Field)
, (requiredFieldEncoder "int64Field" numericStringEncoder 0 v.int64Field)
, (requiredFieldEncoder "uint32Field" JE.int 0 v.uint32Field)
, (requiredFieldEncoder "uint64Field" JE.int 0 v.uint64Field)
, (requiredFieldEncoder "uint64Field" numericStringEncoder 0 v.uint64Field)
, (requiredFieldEncoder "sint32Field" JE.int 0 v.sint32Field)
, (requiredFieldEncoder "sint64Field" JE.int 0 v.sint64Field)
, (requiredFieldEncoder "sint64Field" numericStringEncoder 0 v.sint64Field)
, (requiredFieldEncoder "fixed32Field" JE.int 0 v.fixed32Field)
, (requiredFieldEncoder "fixed64Field" JE.int 0 v.fixed64Field)
, (requiredFieldEncoder "fixed64Field" numericStringEncoder 0 v.fixed64Field)
, (requiredFieldEncoder "sfixed32Field" JE.int 0 v.sfixed32Field)
, (requiredFieldEncoder "sfixed64Field" JE.int 0 v.sfixed64Field)
, (requiredFieldEncoder "sfixed64Field" numericStringEncoder 0 v.sfixed64Field)
, (requiredFieldEncoder "boolField" JE.bool False v.boolField)
, (requiredFieldEncoder "stringField" JE.string "" v.stringField)
, (requiredFieldEncoder "enumField" enumEncoder enumDefault v.enumField)
, (optionalEncoder "subMessage" subMessageEncoder v.subMessage)
, (repeatedFieldEncoder "repeatedInt64Field" JE.int v.repeatedInt64Field)
, (repeatedFieldEncoder "repeatedInt64Field" numericStringEncoder v.repeatedInt64Field)
, (repeatedFieldEncoder "repeatedEnumField" enumEncoder v.repeatedEnumField)
, (optionalEncoder "nestedMessageField" foo_NestedMessageEncoder v.nestedMessageField)
, (requiredFieldEncoder "nestedEnumField" foo_NestedEnumEncoder foo_NestedEnumDefault v.nestedEnumField)
Expand All @@ -201,7 +201,7 @@ type alias Foo_NestedMessage =
foo_NestedMessageDecoder : JD.Decoder Foo_NestedMessage
foo_NestedMessageDecoder =
JD.lazy <| \_ -> decode Foo_NestedMessage
|> required "int32Field" JD.int 0
|> required "int32Field" intDecoder 0


foo_NestedMessageEncoder : Foo_NestedMessage -> JE.Value
Expand All @@ -219,7 +219,7 @@ type alias Foo_NestedMessage_NestedNestedMessage =
foo_NestedMessage_NestedNestedMessageDecoder : JD.Decoder Foo_NestedMessage_NestedNestedMessage
foo_NestedMessage_NestedNestedMessageDecoder =
JD.lazy <| \_ -> decode Foo_NestedMessage_NestedNestedMessage
|> required "int32Field" JD.int 0
|> required "int32Field" intDecoder 0


foo_NestedMessage_NestedNestedMessageEncoder : Foo_NestedMessage_NestedNestedMessage -> JE.Value
Expand Down Expand Up @@ -254,16 +254,16 @@ fooRepeatedDecoder =
JD.lazy <| \_ -> decode FooRepeated
|> repeated "doubleField" JD.float
|> repeated "floatField" JD.float
|> repeated "int32Field" JD.int
|> repeated "int64Field" JD.int
|> repeated "uint32Field" JD.int
|> repeated "uint64Field" JD.int
|> repeated "sint32Field" JD.int
|> repeated "sint64Field" JD.int
|> repeated "fixed32Field" JD.int
|> repeated "fixed64Field" JD.int
|> repeated "sfixed32Field" JD.int
|> repeated "sfixed64Field" JD.int
|> repeated "int32Field" intDecoder
|> repeated "int64Field" intDecoder
|> repeated "uint32Field" intDecoder
|> repeated "uint64Field" intDecoder
|> repeated "sint32Field" intDecoder
|> repeated "sint64Field" intDecoder
|> repeated "fixed32Field" intDecoder
|> repeated "fixed64Field" intDecoder
|> repeated "sfixed32Field" intDecoder
|> repeated "sfixed64Field" intDecoder
|> repeated "boolField" JD.bool
|> repeated "stringField" JD.string
|> repeated "enumField" enumDecoder
Expand All @@ -276,15 +276,15 @@ fooRepeatedEncoder v =
[ (repeatedFieldEncoder "doubleField" JE.float v.doubleField)
, (repeatedFieldEncoder "floatField" JE.float v.floatField)
, (repeatedFieldEncoder "int32Field" JE.int v.int32Field)
, (repeatedFieldEncoder "int64Field" JE.int v.int64Field)
, (repeatedFieldEncoder "int64Field" numericStringEncoder v.int64Field)
, (repeatedFieldEncoder "uint32Field" JE.int v.uint32Field)
, (repeatedFieldEncoder "uint64Field" JE.int v.uint64Field)
, (repeatedFieldEncoder "uint64Field" numericStringEncoder v.uint64Field)
, (repeatedFieldEncoder "sint32Field" JE.int v.sint32Field)
, (repeatedFieldEncoder "sint64Field" JE.int v.sint64Field)
, (repeatedFieldEncoder "sint64Field" numericStringEncoder v.sint64Field)
, (repeatedFieldEncoder "fixed32Field" JE.int v.fixed32Field)
, (repeatedFieldEncoder "fixed64Field" JE.int v.fixed64Field)
, (repeatedFieldEncoder "fixed64Field" numericStringEncoder v.fixed64Field)
, (repeatedFieldEncoder "sfixed32Field" JE.int v.sfixed32Field)
, (repeatedFieldEncoder "sfixed64Field" JE.int v.sfixed64Field)
, (repeatedFieldEncoder "sfixed64Field" numericStringEncoder v.sfixed64Field)
, (repeatedFieldEncoder "boolField" JE.bool v.boolField)
, (repeatedFieldEncoder "stringField" JE.string v.stringField)
, (repeatedFieldEncoder "enumField" enumEncoder v.enumField)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module Google.Protobuf.Empty exposing (..)

-- DO NOT EDIT
-- AUTOGENERATED BY THE ELM PROTOCOL BUFFER COMPILER
-- https://github.com/tiziano88/elm-protobuf
-- source file: google/protobuf/empty.proto

import Protobuf exposing (..)

import Json.Decode as JD
import Json.Encode as JE


type alias Empty =
{
}


emptyDecoder : JD.Decoder Empty
emptyDecoder =
JD.lazy <| \_ -> decode Empty


emptyEncoder : Empty -> JE.Value
emptyEncoder v =
JE.object <| List.filterMap identity <|
[
]
Loading

0 comments on commit 8c189ac

Please sign in to comment.