Permalink
Browse files

Merge pull request #184 from qbox/b_dev_fuzhu_fixreturnnull

return null while not exist
  • Loading branch information...
2 parents 243a83e + e82f42a commit aa7fc3917f826ba8a9362ee51a5c0787d8e0ad03 @carter2000 carter2000 committed Nov 8, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 io/src/qbox.us/up/imageinfo_test.go
@@ -14,14 +14,24 @@ type testCase struct {
var cases = []testCase{
{
- `{"foo": "bar", "w": $(imageInfo.width), "h": $(imageInfo.height), "exif": $(exif.ColorSpace)}`,
+ `{"size": $(fsize), "tag": $(etag), "w": $(imageInfo.width), "h": $(imageInfo.height), "exif": $(exif.ColorSpace)}`,
"application/json",
- `{"foo": "bar", "w": 852, "h": 1136, "exif": {"val":"sRGB","type":3}}`,
+ `{"size": 0, "tag": "test", "w": 852, "h": 1136, "exif": {"val":"sRGB","type":3}}`,
},
{
- `foo=bar&w=$(imageInfo.width)&h=$(imageInfo.height)&cs=$(exif.ColorSpace.val)`,
+ `size=$(fsize)&tag=$(etag)&w=$(imageInfo.width)&h=$(imageInfo.height)&cs=$(exif.ColorSpace.val)`,
"application/x-www-form-urlencoded",
- `foo=bar&w=852&h=1136&cs=sRGB`,
+ `size=0&tag=test&w=852&h=1136&cs=sRGB`,
+ },
+ {
+ `{"n": $(unknown), "w": $(imageInfo.width), "h": $(imageInfo.height), "exif": $(exif.ColorSpace)}`,
+ "application/json",
+ `{"n": null, "w": 852, "h": 1136, "exif": {"val":"sRGB","type":3}}`,
+ },
+ {
+ `n=$(unknown)&w=$(imageInfo.width)&h=$(imageInfo.height)&cs=$(exif.ColorSpace.val)`,
+ "application/x-www-form-urlencoded",
+ `n=&w=852&h=1136&cs=sRGB`,
},
}
@@ -35,7 +45,7 @@ func TestImageInfo(t *testing.T) {
defer f.Close()
for _, c := range cases {
- customData, err := escapeCustomData(f, c.customData, c.callbackBodyType)
+ customData, err := escapeCustomData(f, 0, "test", c.customData, c.callbackBodyType)
if err != nil || customData != c.result {
ts.Fatal(t, "escapeCustomData failed:", c.result, err, customData)
}

0 comments on commit aa7fc39

Please sign in to comment.