title: Slick 3: How to implement repository pattern with transactions?
body: <p>In my play framework (2.5) app, I need to write unit tests for services.</p>
  
  <p>I need to isolate data access logic to able to test service layer in isolation,
  for this I want to create repository interfaces and MOCK them in my unit tests:</p>
  
  <pre><code>class UserService {
     def signUpNewUser(username: String, memberName: String): Future[Unit] {
        val userId = 1 // Set to 1 for demo
        val user = User(userId, username)
        val member = Member(memberName, userId) 
        // ---- I NEED TO EXECUTE THIS BLOCK WITHIN TRANSACTION ----
        for {
          userResult &lt;- userRepository.save(user)
          memberRepository.save(member)
        } yield ()     
        // ---- END OF TRANSACTION ----
     }
  }
  </code></pre>
  
  <p>In the above example, <code>userRepository.save(User)</code> and <code>memberRepository.save(member)</code> operations should be performed within transaction.</p>
  
  <p>I don't want to use slick directly in my service layer because it will complicate my tests. </p>
  
  <p>Also, I don't want to use embedded database for my unit tests, elsewhere it would be a NOT unit test, I need complete isolation.</p>
  
  <p>I do not want my repository interfaces to be depended on slick at all, but need something like this:</p>
  
  <pre><code>trait UserRepository {
     findById(id: Long): Future[Option[User]]
     save(user: User): Future[Unit] 
  }
  </code></pre>
  
  <p>how can I achieve this with slick?</p>