Skip to content

Commit

Permalink
Rename jsonpb to temporalproto
Browse files Browse the repository at this point in the history
This package will eventually contain all our extensions to google's v2
proto package, including:

- Enum casing translation
- Shorthand JSON support
  • Loading branch information
tdeebswihart committed Oct 10, 2023
1 parent 17191bd commit 16ae34d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion jsonpb/decode.go → temporalproto/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package jsonpb
package temporalproto

import (
"encoding/json"
Expand Down
14 changes: 7 additions & 7 deletions jsonpb/decode_test.go → temporalproto/decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package jsonpb_test
package temporalproto_test

import (
"bytes"
Expand All @@ -32,7 +32,7 @@ import (

enums "go.temporal.io/api/enums/v1"
historypb "go.temporal.io/api/history/v1"
"go.temporal.io/api/jsonpb"
"go.temporal.io/api/temporalproto"
)

var oldEnums = `
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestUnmarshal(t *testing.T) {
t.Parallel()
require := require.New(t)
var hist historypb.History
require.NoError(jsonpb.Unmarshal([]byte(newEnums), &hist))
require.NoError(temporalproto.Unmarshal([]byte(newEnums), &hist))
require.Len(hist.Events, 1)

ev := hist.Events[0]
Expand All @@ -134,8 +134,8 @@ func TestUnmarshal_Compatible(t *testing.T) {
t.Parallel()
// Ensure both new and old enums deserialize the same way
var oldHist, newHist historypb.History
require.NoError(t, jsonpb.Unmarshal([]byte(newEnums), &oldHist))
require.NoError(t, jsonpb.Unmarshal([]byte(newEnums), &newHist))
require.NoError(t, temporalproto.Unmarshal([]byte(newEnums), &oldHist))
require.NoError(t, temporalproto.Unmarshal([]byte(newEnums), &newHist))
if !proto.Equal(&oldHist, &newHist) {
t.Errorf("LoadFromJSON() mismatch between old and new enum formats\n%v\n%v", &oldHist, &newHist)
}
Expand All @@ -146,7 +146,7 @@ func TestUnmarshal_NestedType(t *testing.T) {

require := require.New(t)
var newHist historypb.History
require.NoError(jsonpb.Unmarshal([]byte(newNestedFailure), &newHist))
require.NoError(temporalproto.Unmarshal([]byte(newNestedFailure), &newHist))
require.Len(newHist.Events, 1)

wfFail := newHist.Events[0].GetWorkflowExecutionFailedEventAttributes()
Expand All @@ -163,7 +163,7 @@ func TestDecode(t *testing.T) {
input := fmt.Sprintf("%s%s", newEnums, oldEnums)
var hist historypb.History
rdr := bytes.NewReader([]byte(input))
dec := jsonpb.NewDecoder(rdr)
dec := temporalproto.NewDecoder(rdr)
require.NoError(dec.Decode(&hist))
require.Len(hist.Events, 1)

Expand Down

0 comments on commit 16ae34d

Please sign in to comment.