Skip to content

Commit

Permalink
fix: composition operation has no required fields anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Weibel committed Mar 6, 2018
1 parent 685532c commit a048b22
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 19 deletions.
2 changes: 1 addition & 1 deletion cmd/gen/operations.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ func (o *Operations) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
*o = append(*o, op.(Operation))
if err := json.Unmarshal(v.Options, op); err != nil {
// BUG(mweibel): We continue here when such an error is reached because rokka sometimes (legacy reasons)
// has options on an operation which are not of the correct type. Should we write something to stdout? also not nice though..
continue
}
*o = append(*o, op.(Operation))
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gen/testdata/operations_object.go.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func (o *Operations) UnmarshalJSON(data []byte) error {
if err != nil {
return err
}
*o = append(*o, op.(Operation))
if err := json.Unmarshal(v.Options, op); err != nil {
// BUG(mweibel): We continue here when such an error is reached because rokka sometimes (legacy reasons)
// has options on an operation which are not of the correct type. Should we write something to stdout? also not nice though..
continue
}
*o = append(*o, op.(Operation))
}
return nil
}
Expand Down
17 changes: 2 additions & 15 deletions rokka/operations_objects.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rokka/operations_objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ var operationObjectsTests = []struct {
{"AutorotateOperation with multiple args", AutorotateOperation{Width: IntPtr(10), Height: IntPtr(20), RotationDirection: StrPtr("clockwise")}, true, "autorotate-height-20-rotation_direction-clockwise-width-10"},
{"BlurOperation with missing args", BlurOperation{}, false, "blur"},
{"BlurOperation with valid args", BlurOperation{Sigma: Float64Ptr(1.337)}, true, "blur-sigma-1.337"},
{"CompositionOperation missing args", CompositionOperation{}, false, "composition"},
{"CompositionOperation missing args", CompositionOperation{}, true, "composition"},
{"CompositionOperation with valid args", CompositionOperation{Anchor: StrPtr("top"), Height: IntPtr(10), Width: IntPtr(20), Mode: StrPtr("test")}, true, "composition-anchor-top-height-10-mode-test-width-20"},
{"CropOperation with missing args", CropOperation{}, false, "crop"},
{"CropOperation with valid args", CropOperation{Height: IntPtr(100), Width: IntPtr(200)}, true, "crop-height-100-width-200"},
Expand Down
2 changes: 1 addition & 1 deletion rokka/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestGetURLWithCustomImageHost(t *testing.T) {

func TestGetURLWithInvalidStackOperation(t *testing.T) {
operations := []Operation{
CompositionOperation{},
CropOperation{},
}

c := NewClient(&Config{})
Expand Down

0 comments on commit a048b22

Please sign in to comment.