Skip to content

Commit

Permalink
optimize test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbrzzl committed Sep 22, 2024
1 parent 2fc3dfb commit a7f1994
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions database/migration/blueprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,16 @@ func (s *BlueprintTestSuite) TestBuild() {
s.blueprint.Create()
s.blueprint.String("name")

mockQuery.EXPECT().Exec(s.blueprint.ToSql(mockQuery, grammar)[0]).Return(nil, nil).Once()
sqlStatements := s.blueprint.ToSql(mockQuery, grammar)
s.NotEmpty(sqlStatements)

mockQuery.EXPECT().Exec(sqlStatements[0]).Return(nil, nil).Once()
s.Nil(s.blueprint.Build(mockQuery, grammar))

mockQuery.EXPECT().Exec(s.blueprint.ToSql(mockQuery, grammar)[0]).Return(nil, errors.New("error")).Once()
sqlStatements = s.blueprint.ToSql(mockQuery, grammar)
s.NotEmpty(sqlStatements)

mockQuery.EXPECT().Exec(sqlStatements[0]).Return(nil, errors.New("error")).Once()
s.EqualError(s.blueprint.Build(mockQuery, grammar), "error")
}
}
Expand Down

0 comments on commit a7f1994

Please sign in to comment.