Skip to content

Commit 7b1b528

Browse files
[triage] Add a test for an invalid product to /api/metadata/triage
1 parent ec513c9 commit 7b1b528

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

api/metadata_handler_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,30 @@ func TestHandleMetadataTriage_InvalidBody(t *testing.T) {
108108
assert.Equal(t, http.StatusBadRequest, w.Code)
109109
}
110110

111+
func TestHandleMetadataTriage_InvalidProduct(t *testing.T) {
112+
mockCtrl := gomock.NewController(t)
113+
defer mockCtrl.Finish()
114+
ctx := sharedtest.NewTestContext()
115+
w := httptest.NewRecorder()
116+
117+
body :=
118+
`{
119+
"/bar/foo.html": [
120+
{
121+
"product":"foobar",
122+
"url":"bugs.bar",
123+
"results":[{"status":6}]
124+
}
125+
]}`
126+
bodyReader := strings.NewReader(body)
127+
req := httptest.NewRequest("PATCH", "https://foo/metadata", bodyReader)
128+
req.Header.Set("Content-Type", "application/json")
129+
130+
handleMetadataTriage(ctx, nil, nil, w, req)
131+
132+
assert.Equal(t, http.StatusBadRequest, w.Code)
133+
}
134+
111135
func TestMetadataHanlder_GET_Success(t *testing.T) {
112136
mockCtrl := gomock.NewController(t)
113137
defer mockCtrl.Finish()

0 commit comments

Comments
 (0)