This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from lyft/jsonpb-unmarshaler-options
This resolves an issue we were seeing where backwards compatibility of new versions of protobuf messages with new fields were failing.
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package utils | ||
|
||
import ( | ||
structpb "github.com/golang/protobuf/ptypes/struct" | ||
"github.com/lyft/flyteidl/gen/pb-go/flyteidl/plugins" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestBackwardsCompatibility(t *testing.T) { | ||
sidecarProtoMessage := plugins.SidecarJob{ | ||
PrimaryContainerName: "primary", | ||
} | ||
|
||
sidecarStruct, err := MarshalObjToStruct(sidecarProtoMessage) | ||
assert.NoError(t, err) | ||
|
||
// Set a new field in the struct to mimic what happens when we add new fields to protobuf messages | ||
sidecarStruct.Fields["hello"] = &structpb.Value{ | ||
Kind: &structpb.Value_StringValue{ | ||
StringValue: "world", | ||
}, | ||
} | ||
|
||
newSidecarJob := plugins.SidecarJob{} | ||
err = UnmarshalStruct(sidecarStruct, &newSidecarJob) | ||
assert.NoError(t, err) | ||
} |