@@ -405,6 +405,27 @@ func testAPIRepoMigrateConflict(t *testing.T, u *url.URL) {
405
405
})
406
406
}
407
407
408
+ // mirror-sync must fail with "400 (Bad Request)" when an attempt is made to
409
+ // sync a non-mirror repository.
410
+ func TestAPIMirrorSyncNonMirrorRepo (t * testing.T ) {
411
+ defer prepareTestEnv (t )()
412
+
413
+ session := loginUser (t , "user2" )
414
+ token := getTokenForLoggedInUser (t , session )
415
+
416
+ var repo api.Repository
417
+ req := NewRequest (t , "GET" , "/api/v1/repos/user2/repo1" )
418
+ resp := MakeRequest (t , req , http .StatusOK )
419
+ DecodeJSON (t , resp , & repo )
420
+ assert .EqualValues (t , false , repo .Mirror )
421
+
422
+ req = NewRequestf (t , "POST" , "/api/v1/repos/user2/repo1/mirror-sync?token=%s" , token )
423
+ resp = session .MakeRequest (t , req , http .StatusBadRequest )
424
+ errRespJSON := map [string ]string {}
425
+ DecodeJSON (t , resp , & errRespJSON )
426
+ assert .Equal (t , "Repository is not a mirror" , errRespJSON ["message" ])
427
+ }
428
+
408
429
func TestAPIOrgRepoCreate (t * testing.T ) {
409
430
testCases := []struct {
410
431
ctxUserID int64
0 commit comments