Skip to content

Commit

Permalink
tests: fix unit test for image engine
Browse files Browse the repository at this point in the history
  • Loading branch information
aldor007 committed Apr 21, 2019
1 parent 3b8a948 commit fb08736
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions pkg/engine/image_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ func TestImageEngine_Process(t *testing.T) {
image := response.New(200, f)
mortConfig := config.Config{}
mortConfig.Load("testdata/config.yml")
obj, err := object.NewFileObjectFromPath("/local/small/parent.jpg", &mortConfig)
obj, err := object.NewFileObjectFromPath("/local/parent.jpg?width=100&height=70", &mortConfig)

assert.Nil(t, err)
assert.NotNil(t, obj)

obj.Transforms.Resize(100, 70, false)

e := NewImageEngine(image)
res, err := e.Process(obj, []transforms.Transforms{obj.Transforms})

assert.Nil(t, err)
assert.Equal(t, res.StatusCode, 200)
assert.Equal(t, res.Headers.Get("content-type"), "image/jpeg")
assert.Equal(t, res.Headers.Get("etag"), "3ddbe830b458045b041d7653fc42970e")
assert.Equal(t, res.Headers.Get("x-amz-meta-public-width"), "300")
assert.Equal(t, res.Headers.Get("x-amz-meta-public-width"), "100")
assert.Equal(t, res.Headers.Get("x-amz-meta-public-height"), "70")
}
2 changes: 1 addition & 1 deletion pkg/engine/testdata/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ buckets:
local:
transform:
path: "\\/(?P<parent>[a-zA-Z0-9\\.\\/]+)\\-(?P<presetName>[a-z]+)"
kind: "presets"
kind: "presets-query"
parentBucket: "local"
presets:
small:
Expand Down

0 comments on commit fb08736

Please # to comment.