4
Wat (www.destroyallsoftware.com)
[-] lena@gregtech.eu 4 points 1 hour ago

Just a heads up, you linked to the same article twice

[-] lena@gregtech.eu 14 points 2 days ago

You Germans have a word for everything

[-] lena@gregtech.eu 4 points 2 days ago

the most foul, cruel, and bad-tempered rodent you ever set eyes on.

[-] lena@gregtech.eu 19 points 4 days ago

GIVE ME THE LINK

[-] lena@gregtech.eu 45 points 5 days ago

I bit the onion when I saw this headline, really sounds like something he'd say

[-] lena@gregtech.eu 46 points 5 days ago

As much as I dislike JavaScript, it isn't responsible for this. The person (or AI) and their stupidity is.

1
Furries are cool (gregtech.eu)
11

cross-posted from: https://gregtech.eu/post/16416819

Hi, what's the best way for testing a gin route?

I currently have one function where the routes are defined. Here it is:

package router

import (
	"github.com/gin-gonic/gin"
	"github.com/gragorther/epigo/handlers"
	"github.com/gragorther/epigo/middlewares"
)

func Setup(userUserStore handlers.UserUserStore, groupGroupStore handlers.GroupGroupStore, groupAuthStore handlers.GroupAuthStore, messageAuthStore handlers.MessageAuthStore, messageMessageStore handlers.MessageMessageStore, middlewareUserStore middlewares.UserStore) *gin.Engine {
	r := gin.Default()
	r.Use(middlewares.ErrorHandler())

	userHandler := handlers.NewUserHandler(userUserStore)
	authHandler := middlewares.NewAuthMiddleware(middlewareUserStore)
	groupHandler := handlers.NewGroupHandler(groupGroupStore, groupAuthStore)
	messageHandler := handlers.NewMessageHandler(messageMessageStore, messageAuthStore)

	// user stuff
	r.POST("/user/register", userHandler.RegisterUser)
	r.POST("/user/login", userHandler.LoginUser)
	r.GET("/user/profile", authHandler.CheckAuth, userHandler.GetUserProfile)
	r.PUT("/user/setEmailInterval", authHandler.CheckAuth, userHandler.SetEmailInterval)

	// groups
	r.DELETE("/user/groups/delete/:id", authHandler.CheckAuth, groupHandler.DeleteGroup)
	r.POST("/user/groups/add", authHandler.CheckAuth, groupHandler.AddGroup)
	r.GET("/user/groups", authHandler.CheckAuth, groupHandler.ListGroups) // list groups
	r.PATCH("/user/groups/edit/:id", authHandler.CheckAuth, groupHandler.EditGroup)

	// lastMessages
	r.POST("/user/lastMessages/add", authHandler.CheckAuth, messageHandler.AddLastMessage)
	r.GET("/user/lastMessages", authHandler.CheckAuth, messageHandler.ListLastMessages)
	r.PATCH("/user/lastMessages/edit/:id", authHandler.CheckAuth, messageHandler.EditLastMessage)
	r.DELETE("/user/lastMessages/delete/:id", authHandler.CheckAuth, messageHandler.DeleteLastMessage)
	return r
}

so, my question is, how can I test just one route? should I run this function in every test and send a request to a route with httptest? Or should I set up my handlers like it's described at https://gin-gonic.com/en/docs/testing/

(like this)

func postUser(router *gin.Engine) *gin.Engine {
  router.POST("/user/add", func(c *gin.Context) {
    var user User
    c.BindJSON(&user)
    c.JSON(200, user)
  })
  return router
}

let me know if you have any other questions about my code.

It's available on github: https://github.com/gragorther/epigo

[-] lena@gregtech.eu 73 points 6 days ago

It's a public firebase bucket

882
577
5
submitted 1 week ago by lena@gregtech.eu to c/privacy@lemmy.world
64
Gary (gregtech.eu)
submitted 1 week ago by lena@gregtech.eu to c/cat@lemmy.world
79
submitted 1 week ago by lena@gregtech.eu to c/pics@lemmy.world
29
A lot of birds [OC] (gregtech.eu)
submitted 1 week ago by lena@gregtech.eu to c/pics@lemmy.world
54
submitted 1 week ago by lena@gregtech.eu to c/pics@lemmy.world

Here are some more pics of these two birds:

233

(Shamelessly stolen from reddit)

17
Flowery [OC] (gregtech.eu)
submitted 2 weeks ago by lena@gregtech.eu to c/pics@lemmy.world
[-] lena@gregtech.eu 114 points 2 months ago
[-] lena@gregtech.eu 65 points 4 months ago

My grandpa transitioned, she's now my grandma

[-] lena@gregtech.eu 176 points 6 months ago

They're not trying to be nice, they are being nice about it >:3

view more: next ›

lena

joined 6 months ago