@@ -471,8 +471,14 @@ func UpdateWipSpec(ctx context.Context, urlStr string) func(c convey.C) {
471471 loginAndSwitch (ctx , c , client , "jude login" , userName , false )
472472 createRepo (ctx , c , client , repoName )
473473 createWip (ctx , c , client , "get wip obj test" , userName , repoName , branchName )
474+
475+ //make wip base commit has value
476+ uploadObject (ctx , c , client , "update init object" , userName , repoName , branchName , "a.txt" )
477+ commitWip (ctx , c , client , "commit init object" , userName , repoName , branchName , "test" )
478+
474479 uploadObject (ctx , c , client , "update f1 to test branch" , userName , repoName , branchName , "m.dat" )
475480 uploadObject (ctx , c , client , "update f2 to test branch" , userName , repoName , branchName , "g/m.dat" )
481+
476482 c .Convey ("get wip" , func (c convey.C ) {
477483 resp , err := client .GetWip (ctx , userName , repoName , & api.GetWipParams {
478484 RefName : branchName ,
@@ -535,6 +541,26 @@ func UpdateWipSpec(ctx context.Context, urlStr string) func(c convey.C) {
535541 convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusNotFound )
536542 })
537543
544+ c .Convey ("update wip with fail base commit" , func () {
545+ //delete
546+ resp , err := client .UpdateWip (ctx , userName , repoName , & api.UpdateWipParams {RefName : branchName }, api.UpdateWipJSONRequestBody {
547+ CurrentTree : utils .String (hash .Empty .Hex ()),
548+ BaseCommit : utils .String ("ddd" ),
549+ })
550+ convey .So (err , convey .ShouldBeNil )
551+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusInternalServerError )
552+ })
553+
554+ c .Convey ("update wip with fail tree hash" , func () {
555+ //delete
556+ resp , err := client .UpdateWip (ctx , userName , repoName , & api.UpdateWipParams {RefName : branchName }, api.UpdateWipJSONRequestBody {
557+ CurrentTree : utils .String ("ddd" ),
558+ BaseCommit : utils .String (hash .Empty .Hex ()),
559+ })
560+ convey .So (err , convey .ShouldBeNil )
561+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusInternalServerError )
562+ })
563+
538564 c .Convey ("update wip successful" , func () {
539565 //delete
540566 resp , err := client .UpdateWip (ctx , userName , repoName , & api.UpdateWipParams {RefName : branchName }, api.UpdateWipJSONRequestBody {
@@ -555,6 +581,26 @@ func UpdateWipSpec(ctx context.Context, urlStr string) func(c convey.C) {
555581 convey .So ((* updatedWip .JSON200 ).CurrentTree , convey .ShouldEqual , "" )
556582 })
557583
584+ c .Convey ("fail to update non exit tree hash" , func () {
585+ //delete
586+ resp , err := client .UpdateWip (ctx , userName , repoName , & api.UpdateWipParams {RefName : branchName }, api.UpdateWipJSONRequestBody {
587+ CurrentTree : utils .String ("6161616161" ),
588+ BaseCommit : utils .String (wip .BaseCommit ),
589+ })
590+ convey .So (err , convey .ShouldBeNil )
591+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusNotFound )
592+ })
593+
594+ c .Convey ("fail to update non exit base commit" , func () {
595+ //delete
596+ resp , err := client .UpdateWip (ctx , userName , repoName , & api.UpdateWipParams {RefName : branchName }, api.UpdateWipJSONRequestBody {
597+ CurrentTree : utils .String (wip .CurrentTree ),
598+ BaseCommit : utils .String ("6161616161" ),
599+ })
600+ convey .So (err , convey .ShouldBeNil )
601+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusNotFound )
602+ })
603+
558604 c .Convey ("update wip to non empty successful" , func () {
559605 //delete
560606 resp , err := client .UpdateWip (ctx , userName , repoName , & api.UpdateWipParams {RefName : branchName }, api.UpdateWipJSONRequestBody {
0 commit comments