title: Golang strategy for testing repository
body: <p>I have a ClassRepository struct and I would like to test the query ClassesForLastNDays. I am using Gorp to connect to the database, but I cannot work out a nice way of testing my query. Right now it seems that I have to add data to the database, but that is pretty painful as I need to populate unnecessary fields and FKs etc to get my test to work. Perhaps repositories should just not be tested?</p>
  
  <pre><code>package repositories
  
  import (
      "mobifit/app/domain/entities"
  )
  
  type ClassRepository struct {
      *Repository
  }
  
  func (c *ClassRepository) ClassesForLastNDays(days int) []entities.Class {
      classes := make([]entities.Class, 0)
      query := Select("*").
          From("Class").
          Where("VisibleAt &gt; CURRENT_TIMESTAMP() - INTERVAL ? DAY").
          OrderBy("ClassTypeId").
          Sql()
      c.Repository.Select(classes, query, days)
      c.populateClassRelationships(classes)
      return classes
  }
  
  func (c *ClassRepository) populateClassRelationships(classes []entities.Class) {
      for i := range classes {
          class := classes[i]
  
          // ClassType
          c.Repository.GetById(&amp;class.ClassType, class.ClassTypeId)
  
          // Instructor
          c.Repository.GetById(&amp;class.Instructor, class.ClassType.InstructorId)
  
          // Equipment
          query := Select("E.*").
              From("Equipment E").
              Join("ClassEquipment CE on E.Id = CE.EquipmentId").
              Where("CE.ClassId = ?").
              Sql()
          c.Repository.Select(&amp;class.Equipment, query, class.Id)
      }
  }
  </code></pre>