Example #1
0
func createUserToken(u *models.User) {
	u.Token = strconv.Itoa(int(time.Now().Unix()))
	u.ExpiredTime = time.Now()
}
Example #2
0
	. "github.com/onsi/gomega"
	"github.com/triitvn/instagram-go/api/db"
	"github.com/triitvn/instagram-go/api/models"
	"net/url"
	"strconv"
)

var _ = Describe("Photo", func() {
	var (
		u       models.User
		photoId string
	)

	u = models.User{}
	db.Conn.Where(&models.User{}, 1).First(&u)
	u.Token = "123456"
	db.Conn.Save(&u)

	Describe("Get User Photo", func() {
		Context("Success", func() {
			It("User Id must exist", func() {
				response := Request("GET", "/user/1/photos", "")

				Expect(response.Body).Should(ContainSubstring(`https://farm1.staticflickr.com/499/19728341563_3a9d97e5e1_b.jpg`))
			})
		})

		Context("Wrong method", func() {
			It("Must return 404 page", func() {
				response := Request("POST", "/user/1/photos", "")