Implementing testify as a test suite for the API.
This commit is contained in:
parent
bbfee195a8
commit
d0bebb2210
46 changed files with 2503 additions and 187 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -6,3 +6,6 @@
|
|||
|
||||
# Ignore debug files
|
||||
**/__debug*
|
||||
|
||||
# Ignore logging artifacts
|
||||
*.log
|
|
@ -2,6 +2,7 @@
|
|||
domain = "localhost"
|
||||
port = "31337"
|
||||
https = false
|
||||
listen = "localhost"
|
||||
|
||||
[frontend]
|
||||
domain = "localhost"
|
||||
|
@ -10,5 +11,8 @@ https = false
|
|||
|
||||
[oauth]
|
||||
# You can get all of this from https://discord.com/developers/applications
|
||||
clientid = "[CHANGE ME]"
|
||||
clientsecret = "[CHANGE ME]"
|
||||
client_id = "[CHANGE ME]"
|
||||
client_secret = "[CHANGE ME]"
|
||||
|
||||
[database]
|
||||
path = "../db/main.db"
|
||||
|
|
|
@ -1,40 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
api "example.com/api"
|
||||
authdiscord "example.com/auth/discord"
|
||||
database "example.com/database"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
api.GlobalDatabase = database.InitializeDatabase()
|
||||
api.GlobalConfig.ParseConfig("../config.toml")
|
||||
var defaultConfigPath = "../config.toml"
|
||||
|
||||
func parseArgs() map[string]string {
|
||||
config := flag.String("config", defaultConfigPath, fmt.Sprintf("path to the config file; Default: \"%s\"", defaultConfigPath))
|
||||
flag.Parse()
|
||||
return map[string]string{
|
||||
"config": *config,
|
||||
}
|
||||
}
|
||||
|
||||
func initializeAPIServer(filepath string) {
|
||||
api.GlobalConfig.ParseConfig(filepath)
|
||||
api.GlobalDatabase = database.InitializeDatabase(api.GlobalConfig.Database.Path)
|
||||
api.GlobalOAuth = authdiscord.CreateDiscordOAuthConfig(api.GlobalConfig)
|
||||
api.SetFilteredModels()
|
||||
router := gin.Default()
|
||||
router.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{api.GlobalConfig.GetFrontendRootDomain()},
|
||||
AllowMethods: []string{"PUT", "POST", "DELETE", "GET"},
|
||||
AllowHeaders: []string{"Origin"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
|
||||
// Authentication Workflow
|
||||
router.GET("/auth/callback", api.AuthCallback)
|
||||
router.GET("/auth/login", api.AuthLoginRedirect)
|
||||
router.GET("/auth/logout", api.AuthLogoutRedirect)
|
||||
// User methods
|
||||
router.GET("/user/token/generate", api.CreateAPIToken)
|
||||
router.GET("/user/info", api.GetDiscordUser)
|
||||
router.GET("/user/authorized", api.GetUserLoggedIn)
|
||||
// Object Requests
|
||||
router.POST("/:object", api.ObjectRequest)
|
||||
router.PUT("/:object", api.ObjectRequest)
|
||||
router.GET("/:object", api.ObjectRequest)
|
||||
router.DELETE("/:object", api.ObjectRequest)
|
||||
router.Run(":31337")
|
||||
}
|
||||
|
||||
func main() {
|
||||
args := parseArgs()
|
||||
initializeAPIServer(args["config"])
|
||||
router := api.InitializeRouter()
|
||||
router.Run(api.GlobalConfig.GetAPIListenHost())
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
tier "example.com/database/tier"
|
||||
user "example.com/database/user"
|
||||
|
||||
"github.com/gin-contrib/cors"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"github.com/xyproto/randomstring"
|
||||
|
@ -78,50 +79,49 @@ func createUser(context *gin.Context, discordUser authdiscord.DiscordUser, oauth
|
|||
}
|
||||
}
|
||||
|
||||
func getPublicKey(token *jwt.Token) (any, error) {
|
||||
userId, err := token.Claims.GetIssuer()
|
||||
if err != nil {
|
||||
return []byte(""), nil
|
||||
}
|
||||
apiKeyName, err := token.Claims.GetSubject()
|
||||
if err != nil {
|
||||
return []byte(""), nil
|
||||
}
|
||||
var user user.User
|
||||
user.Get(GlobalDatabase, userId)
|
||||
key := user.GetAPIKeySecret(GlobalDatabase, apiKeyName)
|
||||
keyBlock, _ := pem.Decode([]byte(key))
|
||||
privateKey, _ := x509.ParseECPrivateKey(keyBlock.Bytes)
|
||||
return &privateKey.PublicKey, nil
|
||||
}
|
||||
|
||||
func checkAuthentication(context *gin.Context) *oauth2.Token {
|
||||
oauthTokenJSON, err := context.Cookie("discord-oauthtoken")
|
||||
if err == nil {
|
||||
if err != nil {
|
||||
authHeader := context.Request.Header.Get("Authorization")
|
||||
if authHeader == "" {
|
||||
return nil
|
||||
}
|
||||
signedString := strings.Split(authHeader, " ")[1]
|
||||
token, err := jwt.ParseWithClaims(signedString, &jwt.RegisteredClaims{}, getPublicKey)
|
||||
if err != nil || !token.Valid {
|
||||
log.Println(err)
|
||||
context.AbortWithStatus(http.StatusBadRequest)
|
||||
return nil
|
||||
}
|
||||
var oauthToken *oauth2.Token
|
||||
err := json.Unmarshal([]byte(oauthTokenJSON), &oauthToken)
|
||||
if err == nil {
|
||||
if oauthToken.Valid() {
|
||||
if (*user.Get(GlobalDatabase, []string{oauthTokenJSON}))[0].LoggedIn {
|
||||
return oauthToken
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if authHeader := context.Request.Header.Get("Authorization"); authHeader != "" {
|
||||
signedString := strings.Split(authHeader, " ")[1]
|
||||
token, err := jwt.ParseWithClaims(signedString, &jwt.RegisteredClaims{}, func(token *jwt.Token) (interface{}, error) {
|
||||
userId, err := token.Claims.GetIssuer()
|
||||
if err != nil {
|
||||
return []byte(""), nil
|
||||
}
|
||||
apiKeyName, err := token.Claims.GetSubject()
|
||||
if err != nil {
|
||||
return []byte(""), nil
|
||||
}
|
||||
var user user.User
|
||||
user.Get(GlobalDatabase, userId)
|
||||
key := user.GetAPIKeySecret(GlobalDatabase, apiKeyName)
|
||||
keyBlock, _ := pem.Decode([]byte(key))
|
||||
privateKey, _ := x509.ParseECPrivateKey(keyBlock.Bytes)
|
||||
return &privateKey.PublicKey, nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
context.AbortWithStatus(http.StatusBadRequest)
|
||||
return nil
|
||||
}
|
||||
if token.Valid {
|
||||
var oauthToken *oauth2.Token
|
||||
userId, _ := token.Claims.GetIssuer()
|
||||
json.Unmarshal([]byte((*user.Get(GlobalDatabase, []string{userId}))[0].LoginToken), &oauthToken)
|
||||
return oauthToken
|
||||
}
|
||||
|
||||
userId, _ := token.Claims.GetIssuer()
|
||||
json.Unmarshal([]byte((*user.Get(GlobalDatabase, []string{userId}))[0].LoginToken), &oauthToken)
|
||||
return oauthToken
|
||||
}
|
||||
var oauthToken *oauth2.Token
|
||||
err = json.Unmarshal([]byte(oauthTokenJSON), &oauthToken)
|
||||
if err == nil {
|
||||
if !oauthToken.Valid() || !(*user.Get(GlobalDatabase, []string{oauthTokenJSON}))[0].LoggedIn {
|
||||
return nil
|
||||
}
|
||||
return oauthToken
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -432,7 +432,6 @@ func GetDiscordUser(context *gin.Context) {
|
|||
var discordUser authdiscord.DiscordUser
|
||||
result := discordUser.Get(context, oauthToken, GlobalOAuth)
|
||||
if result != "" {
|
||||
log.Println(result)
|
||||
log.Println("Assuming the Discord OAuth Key has expired.")
|
||||
context.Redirect(http.StatusUnauthorized, GlobalConfig.GetFrontendRootDomain()+"/logout")
|
||||
} else {
|
||||
|
@ -450,3 +449,32 @@ func GetUserLoggedIn(context *gin.Context) {
|
|||
"message": (checkAuthentication(context) != nil),
|
||||
})
|
||||
}
|
||||
|
||||
func InitializeRouter() *gin.Engine {
|
||||
router := gin.Default()
|
||||
router.Use(cors.New(cors.Config{
|
||||
AllowOrigins: []string{GlobalConfig.GetFrontendRootDomain()},
|
||||
AllowMethods: []string{"PUT", "POST", "DELETE", "GET"},
|
||||
AllowHeaders: []string{"Origin"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
}))
|
||||
// Testing
|
||||
router.GET("/ping", func(context *gin.Context) {
|
||||
context.Status(http.StatusOK)
|
||||
})
|
||||
// Authentication Workflow
|
||||
router.GET("/auth/callback", AuthCallback)
|
||||
router.GET("/auth/login", AuthLoginRedirect)
|
||||
router.GET("/auth/logout", AuthLogoutRedirect)
|
||||
// User methods
|
||||
router.GET("/user/token/generate", CreateAPIToken)
|
||||
router.GET("/user/info", GetDiscordUser)
|
||||
router.GET("/user/authorized", GetUserLoggedIn)
|
||||
// Object Requests
|
||||
router.POST("/:object", ObjectRequest)
|
||||
router.PUT("/:object", ObjectRequest)
|
||||
router.GET("/:object", ObjectRequest)
|
||||
router.DELETE("/:object", ObjectRequest)
|
||||
return router
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ require (
|
|||
example.com/database/schematic v0.0.0
|
||||
example.com/database/tier v0.0.0
|
||||
example.com/database/user v0.0.0
|
||||
github.com/gin-contrib/cors v1.7.5
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
github.com/xyproto/randomstring v1.2.0
|
||||
|
@ -61,20 +62,20 @@ require (
|
|||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/kr/text v0.2.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
|
@ -83,11 +84,11 @@ require (
|
|||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
|
@ -21,10 +24,10 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
|||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
|
@ -37,9 +40,13 @@ github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/
|
|||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
|
@ -55,45 +62,47 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
|
|
|
@ -10,19 +10,23 @@ import (
|
|||
|
||||
type AppConfig struct {
|
||||
API struct {
|
||||
Domain string
|
||||
Port string
|
||||
Https bool
|
||||
}
|
||||
Domain string `toml:"domain"`
|
||||
Port string `toml:"port"`
|
||||
Https bool `toml:"https"`
|
||||
Listen string `toml:"listen"`
|
||||
} `toml:"api"`
|
||||
Frontend struct {
|
||||
Domain string
|
||||
Port string
|
||||
Https bool
|
||||
}
|
||||
Domain string `toml:"domain"`
|
||||
Port string `toml:"port"`
|
||||
Https bool `toml:"https"`
|
||||
} `toml:"frontend"`
|
||||
OAuth struct {
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
}
|
||||
ClientID string `toml:"client_id"`
|
||||
ClientSecret string `toml:"client_secret"`
|
||||
} `toml:"oauth"`
|
||||
Database struct {
|
||||
Path string `toml:"path"`
|
||||
} `toml:"database"`
|
||||
}
|
||||
|
||||
func (config AppConfig) GetAPIRootDomain() string {
|
||||
|
@ -41,6 +45,10 @@ func (config AppConfig) GetFrontendRootDomain() string {
|
|||
return protocol + config.Frontend.Domain + ":" + config.Frontend.Port
|
||||
}
|
||||
|
||||
func (config AppConfig) GetAPIListenHost() string {
|
||||
return config.API.Listen + ":" + config.API.Port
|
||||
}
|
||||
|
||||
func (config *AppConfig) ParseConfig(configPath string) {
|
||||
configFile, err := os.Open(configPath)
|
||||
if err != nil {
|
||||
|
|
|
@ -23,7 +23,7 @@ type Character struct {
|
|||
|
||||
type CharacterParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
Owners []uint `json:"owners"`
|
||||
|
|
|
@ -24,7 +24,7 @@ type Customization struct {
|
|||
|
||||
type CustomizationParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
Functions []uint `json:"functions"`
|
||||
|
@ -117,6 +117,7 @@ func (customization Customization) delete(db *gorm.DB) error {
|
|||
}
|
||||
|
||||
func Create(db *gorm.DB, params CustomizationParams) error {
|
||||
var err error
|
||||
var newFunctions []function.Function
|
||||
if len(params.Functions) > 0 {
|
||||
newFunctions = *function.Get(db, params.Functions)
|
||||
|
@ -127,7 +128,10 @@ func Create(db *gorm.DB, params CustomizationParams) error {
|
|||
}
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Customization{
|
||||
Name: params.Name,
|
||||
|
@ -154,6 +158,7 @@ func Get(db *gorm.DB, inputCustomizations []uint) *[]Customization {
|
|||
}
|
||||
|
||||
func Update(db *gorm.DB, params CustomizationParams) error {
|
||||
var err error
|
||||
var newFunctions []function.Function
|
||||
if len(params.Functions) > 0 {
|
||||
newFunctions = *function.Get(db, params.Functions)
|
||||
|
@ -164,7 +169,10 @@ func Update(db *gorm.DB, params CustomizationParams) error {
|
|||
}
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Customization{
|
||||
Name: params.Name,
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
character "example.com/database/character"
|
||||
customization "example.com/database/customization"
|
||||
|
@ -20,10 +23,21 @@ import (
|
|||
|
||||
"gorm.io/driver/sqlite"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
)
|
||||
|
||||
func InitializeDatabase() *gorm.DB {
|
||||
db, err := gorm.Open(sqlite.Open("../db/main.db"), &gorm.Config{})
|
||||
// default: "../db/main.db"
|
||||
func InitializeDatabase(filepath string) *gorm.DB {
|
||||
logfile, err := os.Create(fmt.Sprintf("%s/db.log", path.Dir(filepath)))
|
||||
if err != nil {
|
||||
log.Fatal("Failed to create database logfile.")
|
||||
}
|
||||
logger := logger.New(log.New(logfile, "\r\n", log.LstdFlags),
|
||||
logger.Config{},
|
||||
)
|
||||
db, err := gorm.Open(sqlite.Open(filepath), &gorm.Config{
|
||||
Logger: logger,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal("Failed to connect to database.")
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ type Function struct {
|
|||
|
||||
type FunctionParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
Tags []uint `json:"tags"`
|
||||
|
@ -98,9 +98,13 @@ func (function Function) delete(db *gorm.DB) error {
|
|||
}
|
||||
|
||||
func Create(db *gorm.DB, params FunctionParams) error {
|
||||
var err error
|
||||
var newTags []functiontag.FunctionTag
|
||||
if len(params.Tags) > 0 {
|
||||
newTags = *functiontag.Get(db, params.Tags)
|
||||
newTags, err = functiontag.Get(db, params.Tags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var newRequirements []Function
|
||||
if len(params.Requirements) > 0 {
|
||||
|
@ -127,9 +131,13 @@ func Get(db *gorm.DB, inputFunctions []uint) *[]Function {
|
|||
}
|
||||
|
||||
func Update(db *gorm.DB, params FunctionParams) error {
|
||||
var err error
|
||||
var newTags []functiontag.FunctionTag
|
||||
if len(params.Tags) > 0 {
|
||||
newTags = *functiontag.Get(db, params.Tags)
|
||||
newTags, err = functiontag.Get(db, params.Tags)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
var newRequirements []Function
|
||||
if len(params.Requirements) > 0 {
|
||||
|
|
|
@ -15,7 +15,7 @@ type FunctionSet struct {
|
|||
|
||||
type FunctionSetParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Functions []uint `json:"functions"`
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type FunctionTag struct {
|
|||
|
||||
type FunctionTagParams struct {
|
||||
// ID of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
@ -44,8 +44,12 @@ func (functionTag FunctionTag) create(db *gorm.DB) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (functionTag *FunctionTag) get(db *gorm.DB, inputFunctionTag uint) {
|
||||
db.Model(&FunctionTag{}).Where("ID = ?", inputFunctionTag).Take(&functionTag)
|
||||
func (functionTag *FunctionTag) get(db *gorm.DB, inputFunctionTag uint) error {
|
||||
result := db.Model(&FunctionTag{}).Where("ID = ?", inputFunctionTag).Take(&functionTag)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (functionTag FunctionTag) update(db *gorm.DB) error {
|
||||
|
@ -78,17 +82,20 @@ func Create(db *gorm.DB, params FunctionTagParams) error {
|
|||
}.create(db)
|
||||
}
|
||||
|
||||
func Get(db *gorm.DB, inputFunctionTags []uint) *[]FunctionTag {
|
||||
func Get(db *gorm.DB, inputFunctionTags []uint) ([]FunctionTag, error) {
|
||||
var outputFunctionTags []FunctionTag
|
||||
if len(inputFunctionTags) < 1 {
|
||||
db.Model(&FunctionTag{}).Select("id").Find(&inputFunctionTags)
|
||||
}
|
||||
for _, inputFunctionTag := range inputFunctionTags {
|
||||
var outputFunctionTag FunctionTag
|
||||
outputFunctionTag.get(db, inputFunctionTag)
|
||||
err := outputFunctionTag.get(db, inputFunctionTag)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outputFunctionTags = append(outputFunctionTags, outputFunctionTag)
|
||||
}
|
||||
return &outputFunctionTags
|
||||
return outputFunctionTags, nil
|
||||
}
|
||||
|
||||
func Update(db *gorm.DB, params FunctionTagParams) error {
|
||||
|
@ -120,17 +127,17 @@ func Delete(db *gorm.DB, inputFunctionTags []uint) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func HandleRequest(method string, db *gorm.DB, IDUintArray *[]uint, body *[]byte) (*[]FunctionTag, error) {
|
||||
func HandleRequest(method string, db *gorm.DB, IDUintArray *[]uint, body *[]byte) ([]FunctionTag, error) {
|
||||
var err error
|
||||
var params FunctionTagParams
|
||||
err = params.parse(IDUintArray, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result *[]FunctionTag
|
||||
var result []FunctionTag
|
||||
switch method {
|
||||
case "GET":
|
||||
result = Get(db, params.IDArray)
|
||||
result, err = Get(db, params.IDArray)
|
||||
case "POST":
|
||||
err = Create(db, params)
|
||||
case "PUT":
|
||||
|
|
|
@ -56,5 +56,5 @@ require (
|
|||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
)
|
||||
|
|
|
@ -4,8 +4,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
|||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
|
|
|
@ -16,7 +16,7 @@ type GroupParams struct {
|
|||
// ID(s) of the object being modified
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (params *GroupParams) parse(IDUintArray *[]uint, body *[]byte) error {
|
||||
|
@ -44,8 +44,12 @@ func (group Group) create(db *gorm.DB) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (group *Group) get(db *gorm.DB, inputGroup uint) {
|
||||
db.Model(&Group{}).Where("ID = ?", inputGroup).Take(&group)
|
||||
func (group *Group) get(db *gorm.DB, inputGroup uint) error {
|
||||
result := db.Model(&Group{}).Where("ID = ?", inputGroup).Take(&group)
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (group Group) update(db *gorm.DB) error {
|
||||
|
@ -78,17 +82,20 @@ func Create(db *gorm.DB, params GroupParams) error {
|
|||
}.create(db)
|
||||
}
|
||||
|
||||
func Get(db *gorm.DB, inputGroups []uint) *[]Group {
|
||||
func Get(db *gorm.DB, inputGroups []uint) ([]Group, error) {
|
||||
var outputGroups []Group
|
||||
if len(inputGroups) < 1 {
|
||||
db.Model(&Group{}).Select("id").Find(&inputGroups)
|
||||
}
|
||||
for _, inputGroup := range inputGroups {
|
||||
var outputGroup Group
|
||||
outputGroup.get(db, inputGroup)
|
||||
err := outputGroup.get(db, inputGroup)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
outputGroups = append(outputGroups, outputGroup)
|
||||
}
|
||||
return &outputGroups
|
||||
return outputGroups, nil
|
||||
}
|
||||
|
||||
func Update(db *gorm.DB, params GroupParams) error {
|
||||
|
@ -108,7 +115,10 @@ func Delete(db *gorm.DB, inputGroups []uint) error {
|
|||
// }
|
||||
for _, inputGroup := range inputGroups {
|
||||
var group Group
|
||||
group.get(db, inputGroup)
|
||||
err := group.get(db, inputGroup)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
groups = append(groups, group)
|
||||
}
|
||||
for _, group := range groups {
|
||||
|
@ -120,17 +130,17 @@ func Delete(db *gorm.DB, inputGroups []uint) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func HandleRequest(method string, db *gorm.DB, IDUintArray *[]uint, body *[]byte) (*[]Group, error) {
|
||||
func HandleRequest(method string, db *gorm.DB, IDUintArray *[]uint, body *[]byte) ([]Group, error) {
|
||||
var err error
|
||||
var params GroupParams
|
||||
err = params.parse(IDUintArray, body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var result *[]Group
|
||||
var result []Group
|
||||
switch method {
|
||||
case "GET":
|
||||
result = Get(db, params.IDArray)
|
||||
result, err = Get(db, params.IDArray)
|
||||
case "POST":
|
||||
err = Create(db, params)
|
||||
case "PUT":
|
||||
|
|
|
@ -11,13 +11,13 @@ import (
|
|||
|
||||
type InventorySlot struct {
|
||||
gorm.Model
|
||||
Item item.Item `gorm:"uniqueIndex foreignKey:Name" json:"item"`
|
||||
Item item.Item `gorm:"foreignKey:Name" json:"item"`
|
||||
Quantity int64 `json:"quantity"` // Positive
|
||||
}
|
||||
|
||||
type InventorySlotParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Item uint `json:"item"`
|
||||
Quantity int64 `json:"quantity"`
|
||||
|
@ -88,8 +88,7 @@ func (inventorySlot InventorySlot) delete(db *gorm.DB) error {
|
|||
}
|
||||
|
||||
func Create(db *gorm.DB, params InventorySlotParams) error {
|
||||
var newItem item.Item
|
||||
newItem = (*item.Get(db, []uint{params.Item}))[0]
|
||||
newItem := (*item.Get(db, []uint{params.Item}))[0]
|
||||
return InventorySlot{
|
||||
Item: newItem,
|
||||
Quantity: params.Quantity,
|
||||
|
@ -110,8 +109,7 @@ func Get(db *gorm.DB, inputInventorySlots []uint) *[]InventorySlot {
|
|||
}
|
||||
|
||||
func Update(db *gorm.DB, params InventorySlotParams) error {
|
||||
var newItem item.Item
|
||||
newItem = (*item.Get(db, []uint{params.Item}))[0]
|
||||
newItem := (*item.Get(db, []uint{params.Item}))[0]
|
||||
return InventorySlot{
|
||||
Item: newItem,
|
||||
Quantity: params.Quantity,
|
||||
|
|
|
@ -26,7 +26,7 @@ type Item struct {
|
|||
|
||||
type ItemParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
Functions []uint `json:"functions"`
|
||||
|
@ -129,6 +129,7 @@ func (item Item) delete(db *gorm.DB) error {
|
|||
}
|
||||
|
||||
func Create(db *gorm.DB, params ItemParams) error {
|
||||
var err error
|
||||
var newFunctions []function.Function
|
||||
if len(params.Functions) > 0 {
|
||||
newFunctions = *function.Get(db, params.Functions)
|
||||
|
@ -143,7 +144,10 @@ func Create(db *gorm.DB, params ItemParams) error {
|
|||
}
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Item{
|
||||
Name: params.Name,
|
||||
|
@ -171,6 +175,7 @@ func Get(db *gorm.DB, inputItems []uint) *[]Item {
|
|||
}
|
||||
|
||||
func Update(db *gorm.DB, params ItemParams) error {
|
||||
var err error
|
||||
var newFunctions []function.Function
|
||||
if len(params.Functions) > 0 {
|
||||
newFunctions = *function.Get(db, params.Functions)
|
||||
|
@ -185,7 +190,10 @@ func Update(db *gorm.DB, params ItemParams) error {
|
|||
}
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Item{
|
||||
Name: params.Name,
|
||||
|
|
|
@ -14,7 +14,7 @@ type ItemTag struct {
|
|||
|
||||
type ItemTagParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package person
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"log"
|
||||
|
||||
group "example.com/database/group"
|
||||
|
||||
|
@ -18,7 +17,7 @@ type Person struct {
|
|||
|
||||
type PersonParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
Groups []uint `json:"groups"`
|
||||
|
@ -92,9 +91,12 @@ func (person Person) delete(db *gorm.DB) error {
|
|||
|
||||
func Create(db *gorm.DB, params PersonParams) error {
|
||||
var newGroups []group.Group
|
||||
log.Println(params)
|
||||
var err error
|
||||
if len(params.Groups) > 0 {
|
||||
newGroups = *group.Get(db, params.Groups)
|
||||
newGroups, err = group.Get(db, params.Groups)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Person{
|
||||
Name: params.Name,
|
||||
|
@ -124,8 +126,12 @@ func Get(db *gorm.DB, inputPersons []uint) *[]Person {
|
|||
|
||||
func Update(db *gorm.DB, params PersonParams) error {
|
||||
var newGroups []group.Group
|
||||
var err error
|
||||
if len(params.Groups) > 0 {
|
||||
newGroups = *group.Get(db, params.Groups)
|
||||
newGroups, err = group.Get(db, params.Groups)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Person{
|
||||
Model: gorm.Model{ID: params.IDArray[0]},
|
||||
|
|
|
@ -19,7 +19,7 @@ type Role struct {
|
|||
|
||||
type RoleParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Name string `json:"name"`
|
||||
Tiers []uint `json:"tiers"`
|
||||
|
@ -99,13 +99,17 @@ func (role Role) delete(db *gorm.DB) error {
|
|||
}
|
||||
|
||||
func Create(db *gorm.DB, params RoleParams) error {
|
||||
var err error
|
||||
var newTiers []tier.Tier
|
||||
if len(params.Tiers) > 0 {
|
||||
newTiers = *tier.Get(db, params.Tiers)
|
||||
}
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Role{
|
||||
Name: params.Name,
|
||||
|
@ -128,13 +132,17 @@ func Get(db *gorm.DB, inputRoles []uint) *[]Role {
|
|||
}
|
||||
|
||||
func Update(db *gorm.DB, params RoleParams) error {
|
||||
var err error
|
||||
var newTiers []tier.Tier
|
||||
if len(params.Tiers) > 0 {
|
||||
newTiers = *tier.Get(db, params.Tiers)
|
||||
}
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Role{
|
||||
Name: params.Name,
|
||||
|
|
|
@ -22,7 +22,7 @@ type Schematic struct {
|
|||
|
||||
type SchematicParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
Material []uint `json:"material"`
|
||||
Tools []uint `json:"tools"`
|
||||
|
@ -115,6 +115,7 @@ func (schematic Schematic) delete(db *gorm.DB) error {
|
|||
}
|
||||
|
||||
func Create(db *gorm.DB, params SchematicParams) error {
|
||||
var err error
|
||||
var newMaterial []inventoryslot.InventorySlot
|
||||
if len(params.Material) > 0 {
|
||||
newMaterial = *inventoryslot.Get(db, params.Material)
|
||||
|
@ -131,7 +132,10 @@ func Create(db *gorm.DB, params SchematicParams) error {
|
|||
newResult := resultArray[0]
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Schematic{
|
||||
Material: newMaterial,
|
||||
|
@ -157,6 +161,7 @@ func Get(db *gorm.DB, inputSchematics []uint) *[]Schematic {
|
|||
}
|
||||
|
||||
func Update(db *gorm.DB, params SchematicParams) error {
|
||||
var err error
|
||||
var newMaterial []inventoryslot.InventorySlot
|
||||
if len(params.Material) > 0 {
|
||||
newMaterial = *inventoryslot.Get(db, params.Material)
|
||||
|
@ -173,7 +178,10 @@ func Update(db *gorm.DB, params SchematicParams) error {
|
|||
newResult := resultArray[0]
|
||||
var newVisibility []group.Group
|
||||
if len(params.Visibility) > 0 {
|
||||
newVisibility = *group.Get(db, params.Visibility)
|
||||
newVisibility, err = group.Get(db, params.Visibility)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return Schematic{
|
||||
Material: newMaterial,
|
||||
|
|
|
@ -15,7 +15,7 @@ type Tier struct {
|
|||
|
||||
type TierParams struct {
|
||||
// ID(s) of the object being modified
|
||||
IDArray []uint `json:"id"`
|
||||
IDArray []uint
|
||||
// New fields
|
||||
FunctionSets []uint `json:"function_sets"`
|
||||
}
|
||||
|
|
120
test/api_test.go
Normal file
120
test/api_test.go
Normal file
|
@ -0,0 +1,120 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
character "example.com/database/character"
|
||||
customization "example.com/database/customization"
|
||||
function "example.com/database/function"
|
||||
functionset "example.com/database/functionset"
|
||||
functiontag "example.com/database/functiontag"
|
||||
group "example.com/database/group"
|
||||
inventoryslot "example.com/database/inventoryslot"
|
||||
item "example.com/database/item"
|
||||
itemtag "example.com/database/itemtag"
|
||||
person "example.com/database/person"
|
||||
role "example.com/database/role"
|
||||
schematic "example.com/database/schematic"
|
||||
tier "example.com/database/tier"
|
||||
user "example.com/database/user"
|
||||
functiontagtest "example.com/unit/functiontagtest"
|
||||
functiontest "example.com/unit/functiontest"
|
||||
grouptest "example.com/unit/grouptest"
|
||||
persontest "example.com/unit/persontest"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type testCharacter struct {
|
||||
Result []character.Character `json:"result"`
|
||||
}
|
||||
|
||||
type testCustomization struct {
|
||||
Result []customization.Customization `json:"result"`
|
||||
}
|
||||
|
||||
type testFunction struct {
|
||||
Result []function.Function `json:"result"`
|
||||
}
|
||||
|
||||
type testFunctionSet struct {
|
||||
Result []functionset.FunctionSet `json:"result"`
|
||||
}
|
||||
|
||||
type testFunctionTag struct {
|
||||
Result []functiontag.FunctionTag `json:"result"`
|
||||
}
|
||||
|
||||
type testInventorySlot struct {
|
||||
Result []inventoryslot.InventorySlot `json:"result"`
|
||||
}
|
||||
|
||||
type testItem struct {
|
||||
Result []item.Item `json:"result"`
|
||||
}
|
||||
|
||||
type testItemTag struct {
|
||||
Result []itemtag.ItemTag `json:"result"`
|
||||
}
|
||||
|
||||
type testPerson struct {
|
||||
Result []person.Person `json:"result"`
|
||||
}
|
||||
|
||||
type testRole struct {
|
||||
Result []role.Role `json:"result"`
|
||||
}
|
||||
|
||||
type testSchematic struct {
|
||||
Result []schematic.Schematic `json:"result"`
|
||||
}
|
||||
|
||||
type testTier struct {
|
||||
Result []tier.Tier `json:"result"`
|
||||
}
|
||||
|
||||
type testUser struct {
|
||||
Result []user.User `json:"result"`
|
||||
}
|
||||
|
||||
type apiTestSuite struct {
|
||||
suite.Suite
|
||||
globalAuthHeader string
|
||||
router *gin.Engine
|
||||
group group.Group
|
||||
groupJSON []byte
|
||||
}
|
||||
|
||||
func (s *apiTestSuite) TearDownTestSuite() {
|
||||
os.Remove("db/main.db")
|
||||
}
|
||||
|
||||
func TestSuite01Group(t *testing.T) {
|
||||
var groupSuite grouptest.GroupTestSuite
|
||||
groupSuite.SetupTestSuite()
|
||||
suite.Run(t, &groupSuite)
|
||||
groupSuite.TearDownTestSuite()
|
||||
}
|
||||
|
||||
func TestSuite02FunctionTag(t *testing.T) {
|
||||
var functionTagSuite functiontagtest.FunctionTagTestSuite
|
||||
functionTagSuite.SetupTestSuite()
|
||||
suite.Run(t, &functionTagSuite)
|
||||
functionTagSuite.TearDownTestSuite()
|
||||
}
|
||||
|
||||
func TestSuite03Person(t *testing.T) {
|
||||
var personSuite persontest.PersonTestSuite
|
||||
personSuite.SetupTestSuite()
|
||||
suite.Run(t, &personSuite)
|
||||
personSuite.TearDownTestSuite()
|
||||
}
|
||||
|
||||
func TestSuite04Function(t *testing.T) {
|
||||
var functionSuite functiontest.FunctionTestSuite
|
||||
functionSuite.SetupTestSuite()
|
||||
suite.Run(t, &functionSuite)
|
||||
functionSuite.TearDownTestSuite()
|
||||
}
|
0
test/db/.gitkeep
Normal file
0
test/db/.gitkeep
Normal file
120
test/go.mod
Normal file
120
test/go.mod
Normal file
|
@ -0,0 +1,120 @@
|
|||
module api_test
|
||||
|
||||
go 1.24.2
|
||||
|
||||
replace example.com/unit/persontest => ./unit/persontest
|
||||
|
||||
replace example.com/unit/grouptest => ./unit/grouptest
|
||||
|
||||
replace example.com/unit/functiontest => ./unit/functiontest
|
||||
|
||||
replace example.com/unit/functiontagtest => ./unit/functiontagtest
|
||||
|
||||
replace example.com/test/testrequest => ./lib/testrequest
|
||||
|
||||
replace example.com/test/testsetup => ./lib/testsetup
|
||||
|
||||
replace example.com/api => ../src/lib/api
|
||||
|
||||
replace example.com/database => ../src/lib/database
|
||||
|
||||
replace example.com/database/user => ../src/lib/database/user
|
||||
|
||||
replace example.com/database/character => ../src/lib/database/character
|
||||
|
||||
replace example.com/database/functionset => ../src/lib/database/functionset
|
||||
|
||||
replace example.com/database/inventoryslot => ../src/lib/database/inventoryslot
|
||||
|
||||
replace example.com/database/customization => ../src/lib/database/customization
|
||||
|
||||
replace example.com/database/item => ../src/lib/database/item
|
||||
|
||||
replace example.com/database/itemtag => ../src/lib/database/itemtag
|
||||
|
||||
replace example.com/database/person => ../src/lib/database/person
|
||||
|
||||
replace example.com/database/role => ../src/lib/database/role
|
||||
|
||||
replace example.com/database/schematic => ../src/lib/database/schematic
|
||||
|
||||
replace example.com/database/tier => ../src/lib/database/tier
|
||||
|
||||
replace example.com/database/group => ../src/lib/database/group
|
||||
|
||||
replace example.com/database/function => ../src/lib/database/function
|
||||
|
||||
replace example.com/database/functiontag => ../src/lib/database/functiontag
|
||||
|
||||
replace example.com/config/server => ../src/lib/config/server
|
||||
|
||||
replace example.com/auth/discord => ../src/lib/auth/discord
|
||||
|
||||
require (
|
||||
example.com/database/character v0.0.0
|
||||
example.com/database/customization v0.0.0
|
||||
example.com/database/function v0.0.0
|
||||
example.com/database/functionset v0.0.0
|
||||
example.com/database/functiontag v0.0.0
|
||||
example.com/database/group v0.0.0
|
||||
example.com/database/inventoryslot v0.0.0
|
||||
example.com/database/item v0.0.0
|
||||
example.com/database/itemtag v0.0.0
|
||||
example.com/database/person v0.0.0
|
||||
example.com/database/role v0.0.0
|
||||
example.com/database/schematic v0.0.0
|
||||
example.com/database/tier v0.0.0
|
||||
example.com/database/user v0.0.0
|
||||
example.com/unit/functiontagtest v0.0.0
|
||||
example.com/unit/functiontest v0.0.0
|
||||
example.com/unit/grouptest v0.0.0
|
||||
example.com/unit/persontest v0.0.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
example.com/api v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/auth/discord v0.0.0 // indirect
|
||||
example.com/config/server v0.0.0 // indirect
|
||||
example.com/database v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/test/testrequest v0.0.0 // indirect
|
||||
example.com/test/testsetup v0.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/cors v1.7.5 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xyproto/randomstring v1.2.0 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/sqlite v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
111
test/go.sum
Normal file
111
test/go.sum
Normal file
|
@ -0,0 +1,111 @@
|
|||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
34
test/lib/testrequest/go.mod
Normal file
34
test/lib/testrequest/go.mod
Normal file
|
@ -0,0 +1,34 @@
|
|||
module example.com/test/testrequest
|
||||
|
||||
go 1.24.2
|
||||
|
||||
require github.com/gin-gonic/gin v1.10.0
|
||||
|
||||
require (
|
||||
github.com/bytedance/sonic v1.11.6 // indirect
|
||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
golang.org/x/arch v0.8.0 // indirect
|
||||
golang.org/x/crypto v0.23.0 // indirect
|
||||
golang.org/x/net v0.25.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/text v0.15.0 // indirect
|
||||
google.golang.org/protobuf v1.34.1 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
89
test/lib/testrequest/go.sum
Normal file
89
test/lib/testrequest/go.sum
Normal file
|
@ -0,0 +1,89 @@
|
|||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
41
test/lib/testrequest/testrequest.go
Normal file
41
test/lib/testrequest/testrequest.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package testrequest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"net/http/httptest"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func MakePostRequest(json *[]byte, target string, authHeader string, router *gin.Engine) string {
|
||||
body := bytes.NewBuffer(*json)
|
||||
request := httptest.NewRequest("POST", target, body)
|
||||
request.Header.Set("Authorization", authHeader)
|
||||
recorder := httptest.NewRecorder()
|
||||
router.ServeHTTP(recorder, request)
|
||||
return recorder.Result().Status
|
||||
}
|
||||
|
||||
func MakeGetRequest(target string, router *gin.Engine) []byte {
|
||||
request := httptest.NewRequest("GET", target, nil)
|
||||
recorder := httptest.NewRecorder()
|
||||
router.ServeHTTP(recorder, request)
|
||||
return recorder.Body.Bytes()
|
||||
}
|
||||
|
||||
func MakePutRequest(json *[]byte, target string, authHeader string, router *gin.Engine) string {
|
||||
body := bytes.NewBuffer(*json)
|
||||
request := httptest.NewRequest("PUT", target, body)
|
||||
request.Header.Set("Authorization", authHeader)
|
||||
recorder := httptest.NewRecorder()
|
||||
router.ServeHTTP(recorder, request)
|
||||
return recorder.Result().Status
|
||||
}
|
||||
|
||||
func MakeDeleteRequest(target string, authHeader string, router *gin.Engine) string {
|
||||
request := httptest.NewRequest("DELETE", target, nil)
|
||||
request.Header.Set("Authorization", authHeader)
|
||||
recorder := httptest.NewRecorder()
|
||||
router.ServeHTTP(recorder, request)
|
||||
return recorder.Result().Status
|
||||
}
|
99
test/lib/testsetup/go.mod
Normal file
99
test/lib/testsetup/go.mod
Normal file
|
@ -0,0 +1,99 @@
|
|||
module example.com/test/testsetup
|
||||
|
||||
go 1.24.2
|
||||
|
||||
replace example.com/api => ../../../src/lib/api
|
||||
|
||||
replace example.com/database => ../../../src/lib/database
|
||||
|
||||
replace example.com/database/user => ../../../src/lib/database/user
|
||||
|
||||
replace example.com/database/character => ../../../src/lib/database/character
|
||||
|
||||
replace example.com/database/functionset => ../../../src/lib/database/functionset
|
||||
|
||||
replace example.com/database/inventoryslot => ../../../src/lib/database/inventoryslot
|
||||
|
||||
replace example.com/database/customization => ../../../src/lib/database/customization
|
||||
|
||||
replace example.com/database/item => ../../../src/lib/database/item
|
||||
|
||||
replace example.com/database/itemtag => ../../../src/lib/database/itemtag
|
||||
|
||||
replace example.com/database/person => ../../../src/lib/database/person
|
||||
|
||||
replace example.com/database/role => ../../../src/lib/database/role
|
||||
|
||||
replace example.com/database/schematic => ../../../src/lib/database/schematic
|
||||
|
||||
replace example.com/database/tier => ../../../src/lib/database/tier
|
||||
|
||||
replace example.com/database/group => ../../../src/lib/database/group
|
||||
|
||||
replace example.com/database/function => ../../../src/lib/database/function
|
||||
|
||||
replace example.com/database/functiontag => ../../../src/lib/database/functiontag
|
||||
|
||||
replace example.com/config/server => ../../../src/lib/config/server
|
||||
|
||||
replace example.com/auth/discord => ../../../src/lib/auth/discord
|
||||
|
||||
require (
|
||||
example.com/api v0.0.0-00010101000000-000000000000
|
||||
example.com/database v0.0.0-00010101000000-000000000000
|
||||
example.com/database/user v0.0.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2
|
||||
)
|
||||
|
||||
require (
|
||||
example.com/auth/discord v0.0.0 // indirect
|
||||
example.com/config/server v0.0.0 // indirect
|
||||
example.com/database/character v0.0.0 // indirect
|
||||
example.com/database/customization v0.0.0 // indirect
|
||||
example.com/database/function v0.0.0 // indirect
|
||||
example.com/database/functionset v0.0.0 // indirect
|
||||
example.com/database/functiontag v0.0.0 // indirect
|
||||
example.com/database/group v0.0.0 // indirect
|
||||
example.com/database/inventoryslot v0.0.0 // indirect
|
||||
example.com/database/item v0.0.0 // indirect
|
||||
example.com/database/itemtag v0.0.0 // indirect
|
||||
example.com/database/person v0.0.0 // indirect
|
||||
example.com/database/role v0.0.0 // indirect
|
||||
example.com/database/schematic v0.0.0 // indirect
|
||||
example.com/database/tier v0.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/cors v1.7.5 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xyproto/randomstring v1.2.0 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/sqlite v1.5.7 // indirect
|
||||
gorm.io/gorm v1.25.12 // indirect
|
||||
)
|
111
test/lib/testsetup/go.sum
Normal file
111
test/lib/testsetup/go.sum
Normal file
|
@ -0,0 +1,111 @@
|
|||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
67
test/lib/testsetup/testsetup.go
Normal file
67
test/lib/testsetup/testsetup.go
Normal file
|
@ -0,0 +1,67 @@
|
|||
package testsetup
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
api "example.com/api"
|
||||
database "example.com/database"
|
||||
user "example.com/database/user"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
const SERVERWAIT = 5
|
||||
const SERVERDOMAIN = "http://localhost:31337"
|
||||
const SERVERCONFIG = "./config.toml"
|
||||
|
||||
func SetupTestSuite() (string, *gin.Engine) {
|
||||
file, err := os.Create("./logs/test.log")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
gin.DefaultWriter = file
|
||||
gin.DefaultErrorWriter = file
|
||||
log.SetOutput(file)
|
||||
api.GlobalConfig.ParseConfig(SERVERCONFIG)
|
||||
api.GlobalDatabase = database.InitializeDatabase(api.GlobalConfig.Database.Path)
|
||||
api.SetFilteredModels()
|
||||
err = user.Create(
|
||||
api.GlobalDatabase,
|
||||
"12345",
|
||||
"test",
|
||||
"test",
|
||||
"",
|
||||
"",
|
||||
"{}",
|
||||
true)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
testusers := *user.Get(api.GlobalDatabase, []string{"12345"})
|
||||
err = testusers[0].GenerateAPIKey(api.GlobalDatabase, "test")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
secret := testusers[0].GetAPIKeySecret(api.GlobalDatabase, "test")
|
||||
block, _ := pem.Decode([]byte(secret))
|
||||
privateKey, err := x509.ParseECPrivateKey(block.Bytes)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
token := jwt.NewWithClaims(jwt.SigningMethodES256, jwt.MapClaims{
|
||||
"iss": "12345",
|
||||
"sub": "test",
|
||||
})
|
||||
signedToken, err := token.SignedString(privateKey)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
globalAuthHeader := fmt.Sprintf("Bearer %s", signedToken)
|
||||
// Initialize Router
|
||||
router := api.InitializeRouter()
|
||||
return globalAuthHeader, router
|
||||
}
|
0
test/logs/.gitkeep
Normal file
0
test/logs/.gitkeep
Normal file
106
test/unit/functiontagtest/functiontagtest.go
Normal file
106
test/unit/functiontagtest/functiontagtest.go
Normal file
|
@ -0,0 +1,106 @@
|
|||
package functiontagtest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
functiontag "example.com/database/functiontag"
|
||||
testrequest "example.com/test/testrequest"
|
||||
testsetup "example.com/test/testsetup"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TestFunctionTag struct {
|
||||
Result []functiontag.FunctionTag `json:"result"`
|
||||
}
|
||||
|
||||
type FunctionTagTestSuite struct {
|
||||
suite.Suite
|
||||
globalAuthHeader string
|
||||
router *gin.Engine
|
||||
functiontag functiontag.FunctionTag
|
||||
functiontagJSON []byte
|
||||
functiontagUpdate functiontag.FunctionTag
|
||||
}
|
||||
|
||||
func (s *FunctionTagTestSuite) SetupTestSuite() {
|
||||
s.globalAuthHeader, s.router = testsetup.SetupTestSuite()
|
||||
// Create Test Data
|
||||
s.functiontag = functiontag.FunctionTag{Model: gorm.Model{ID: 1}, Name: "test"}
|
||||
s.functiontagJSON, _ = json.Marshal(s.functiontag)
|
||||
s.functiontagUpdate = functiontag.FunctionTag{Model: gorm.Model{ID: 1}, Name: "another_test"}
|
||||
}
|
||||
|
||||
func (s *FunctionTagTestSuite) TearDownTestSuite() {
|
||||
os.Remove("db/main.db")
|
||||
}
|
||||
|
||||
func (s *FunctionTagTestSuite) Test01CreateFunctionTag() {
|
||||
// Setup variables
|
||||
var output TestFunctionTag
|
||||
target := fmt.Sprintf("/function-tag?id=%d", s.functiontag.ID)
|
||||
|
||||
// Attempt to create functiontag
|
||||
status := testrequest.MakePostRequest(&s.functiontagJSON, "/function-tag", s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "function tag created successfully")
|
||||
|
||||
// Attempt to get functiontag
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the functiontag listed matches the created functiontag
|
||||
s.Equal(s.functiontag.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *FunctionTagTestSuite) Test02GetFunctionTag() {
|
||||
// Setup variables
|
||||
var output TestFunctionTag
|
||||
|
||||
// Attempt to get functiontags
|
||||
body := testrequest.MakeGetRequest("/function-tag", s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the functiontags listed match the created functiontags
|
||||
s.Equal(s.functiontag.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *FunctionTagTestSuite) Test03UpdateFunctionTag() {
|
||||
// Setup variables
|
||||
var output TestFunctionTag
|
||||
body, _ := json.Marshal(s.functiontagUpdate)
|
||||
target := fmt.Sprintf("/function-tag?id=%d", s.functiontag.ID)
|
||||
|
||||
// Attempt to update functiontag
|
||||
status := testrequest.MakePutRequest(&body, target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "function tag created successfully")
|
||||
|
||||
// Attempt to get functiontag
|
||||
body = testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the functiontag listed matches the updated functiontag
|
||||
s.Equal(s.functiontagUpdate.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *FunctionTagTestSuite) Test04DeleteFunctionTag() {
|
||||
// Setup variables
|
||||
var output TestFunctionTag
|
||||
target := fmt.Sprintf("/function-tag?id=%d", s.functiontag.ID)
|
||||
|
||||
// Attempt to delete functiontag
|
||||
status := testrequest.MakeDeleteRequest(target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "function tag deleted successfully")
|
||||
|
||||
// Attempt to get functiontag
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the functiontag list is empty
|
||||
s.Equal(len(output.Result), 0, "input name matches output name")
|
||||
}
|
108
test/unit/functiontagtest/go.mod
Normal file
108
test/unit/functiontagtest/go.mod
Normal file
|
@ -0,0 +1,108 @@
|
|||
module example.com/unit/functiontagtest
|
||||
|
||||
go 1.24.2
|
||||
|
||||
replace example.com/api => ../../../src/lib/api
|
||||
|
||||
replace example.com/database => ../../../src/lib/database
|
||||
|
||||
replace example.com/database/user => ../../../src/lib/database/user
|
||||
|
||||
replace example.com/test/testrequest => ../../lib/testrequest
|
||||
|
||||
replace example.com/test/testsetup => ../../lib/testsetup
|
||||
|
||||
replace example.com/database/character => ../../../src/lib/database/character
|
||||
|
||||
replace example.com/database/functionset => ../../../src/lib/database/functionset
|
||||
|
||||
replace example.com/database/inventoryslot => ../../../src/lib/database/inventoryslot
|
||||
|
||||
replace example.com/database/customization => ../../../src/lib/database/customization
|
||||
|
||||
replace example.com/database/item => ../../../src/lib/database/item
|
||||
|
||||
replace example.com/database/itemtag => ../../../src/lib/database/itemtag
|
||||
|
||||
replace example.com/database/person => ../../../src/lib/database/person
|
||||
|
||||
replace example.com/database/role => ../../../src/lib/database/role
|
||||
|
||||
replace example.com/database/schematic => ../../../src/lib/database/schematic
|
||||
|
||||
replace example.com/database/tier => ../../../src/lib/database/tier
|
||||
|
||||
replace example.com/database/group => ../../../src/lib/database/group
|
||||
|
||||
replace example.com/database/function => ../../../src/lib/database/function
|
||||
|
||||
replace example.com/database/functiontag => ../../../src/lib/database/functiontag
|
||||
|
||||
replace example.com/config/server => ../../../src/lib/config/server
|
||||
|
||||
replace example.com/auth/discord => ../../../src/lib/auth/discord
|
||||
|
||||
require (
|
||||
example.com/database/functiontag v0.0.0
|
||||
example.com/test/testrequest v0.0.0
|
||||
example.com/test/testsetup v0.0.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
gorm.io/gorm v1.25.12
|
||||
)
|
||||
|
||||
require (
|
||||
example.com/api v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/auth/discord v0.0.0 // indirect
|
||||
example.com/config/server v0.0.0 // indirect
|
||||
example.com/database v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/database/character v0.0.0 // indirect
|
||||
example.com/database/customization v0.0.0 // indirect
|
||||
example.com/database/function v0.0.0 // indirect
|
||||
example.com/database/functionset v0.0.0 // indirect
|
||||
example.com/database/group v0.0.0 // indirect
|
||||
example.com/database/inventoryslot v0.0.0 // indirect
|
||||
example.com/database/item v0.0.0 // indirect
|
||||
example.com/database/itemtag v0.0.0 // indirect
|
||||
example.com/database/person v0.0.0 // indirect
|
||||
example.com/database/role v0.0.0 // indirect
|
||||
example.com/database/schematic v0.0.0 // indirect
|
||||
example.com/database/tier v0.0.0 // indirect
|
||||
example.com/database/user v0.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/cors v1.7.5 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xyproto/randomstring v1.2.0 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/sqlite v1.5.7 // indirect
|
||||
)
|
111
test/unit/functiontagtest/go.sum
Normal file
111
test/unit/functiontagtest/go.sum
Normal file
|
@ -0,0 +1,111 @@
|
|||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
171
test/unit/functiontest/functiontest.go
Normal file
171
test/unit/functiontest/functiontest.go
Normal file
|
@ -0,0 +1,171 @@
|
|||
package functiontest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
function "example.com/database/function"
|
||||
"example.com/database/functiontag"
|
||||
testrequest "example.com/test/testrequest"
|
||||
testsetup "example.com/test/testsetup"
|
||||
functiontagtest "example.com/unit/functiontagtest"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TestFunction struct {
|
||||
Result []function.Function `json:"result"`
|
||||
}
|
||||
|
||||
type FunctionTestSuite struct {
|
||||
suite.Suite
|
||||
globalAuthHeader string
|
||||
router *gin.Engine
|
||||
function function.Function
|
||||
functionJSON []byte
|
||||
functionUpdate function.Function
|
||||
functionUpdateJSON []byte
|
||||
}
|
||||
|
||||
func (s *FunctionTestSuite) SetupTestSuite() {
|
||||
s.globalAuthHeader, s.router = testsetup.SetupTestSuite()
|
||||
// Create Test Data
|
||||
testFunctionTag := functiontag.FunctionTag{
|
||||
Model: gorm.Model{ID: 1},
|
||||
Name: "test",
|
||||
}
|
||||
testFunction := function.Function{
|
||||
Model: gorm.Model{ID: 2},
|
||||
Name: "test",
|
||||
Tags: []functiontag.FunctionTag{},
|
||||
Requirements: []function.Function{},
|
||||
}
|
||||
s.function = function.Function{
|
||||
Model: gorm.Model{ID: 1},
|
||||
Name: "another_test",
|
||||
Tags: []functiontag.FunctionTag{},
|
||||
Requirements: []function.Function{},
|
||||
}
|
||||
s.functionJSON, _ = json.Marshal(s.function)
|
||||
s.functionUpdate = function.Function{
|
||||
Model: gorm.Model{ID: 1},
|
||||
Name: "yet_another_test",
|
||||
Tags: []functiontag.FunctionTag{
|
||||
testFunctionTag,
|
||||
},
|
||||
Requirements: []function.Function{
|
||||
testFunction,
|
||||
},
|
||||
}
|
||||
s.functionUpdateJSON, _ = json.Marshal(function.FunctionParams{
|
||||
Name: s.functionUpdate.Name,
|
||||
Tags: []uint{1},
|
||||
Requirements: []uint{2},
|
||||
})
|
||||
}
|
||||
|
||||
func (s *FunctionTestSuite) TearDownTestSuite() {
|
||||
os.Remove("db/main.db")
|
||||
}
|
||||
|
||||
func (s *FunctionTestSuite) Test01CreateFunction() {
|
||||
// Setup variables
|
||||
var output TestFunction
|
||||
target := fmt.Sprintf("/function?id=%d", s.function.ID)
|
||||
|
||||
// Attempt to create function
|
||||
status := testrequest.MakePostRequest(&s.functionJSON, "/function", s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "function created successfully")
|
||||
|
||||
// Attempt to get function
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the function listed matches the created function
|
||||
s.Equal(s.function.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *FunctionTestSuite) Test02GetFunction() {
|
||||
// Setup variables
|
||||
var output TestFunction
|
||||
|
||||
// Attempt to get functions
|
||||
body := testrequest.MakeGetRequest("/function", s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the functions listed match the created functions
|
||||
s.Equal(s.function.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *FunctionTestSuite) Test03UpdateFunction() {
|
||||
// Setup variables
|
||||
var output TestFunction
|
||||
target := fmt.Sprintf("/function?id=%d", s.function.ID)
|
||||
|
||||
// Create needed field objects
|
||||
// Setup variables
|
||||
var functionTagOutput functiontagtest.TestFunctionTag
|
||||
functionTagBody, _ := json.Marshal(s.functionUpdate.Tags[0])
|
||||
// Attempt to create function tag
|
||||
functionTagStatus := testrequest.MakePostRequest(&functionTagBody, "/function-tag", s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(functionTagStatus, "200 OK", "function tag created successfully")
|
||||
// Setup variables
|
||||
functionTagTarget := fmt.Sprintf("/function-tag?id=%d", s.functionUpdate.Tags[0].ID)
|
||||
// Attempt to get function tag
|
||||
functionTagBody = testrequest.MakeGetRequest(functionTagTarget, s.router)
|
||||
// Unamrshal the result
|
||||
json.Unmarshal(functionTagBody, &functionTagOutput)
|
||||
// Check that the function tag listed matches the created function tag
|
||||
s.Equal(s.functionUpdate.Tags[0].Name, functionTagOutput.Result[0].Name, "input function tag name matches created function tag name")
|
||||
// Setup variables
|
||||
var functionOutput TestFunction
|
||||
functionBody, _ := json.Marshal(s.functionUpdate.Requirements[0])
|
||||
// Attempt to create function
|
||||
functionStatus := testrequest.MakePostRequest(&functionBody, "/function", s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(functionStatus, "200 OK", "function created successfully")
|
||||
// Setup variables
|
||||
functionTarget := fmt.Sprintf("/function?id=%d", s.functionUpdate.Requirements[0].ID)
|
||||
// Attempt to get function
|
||||
functionBody = testrequest.MakeGetRequest(functionTarget, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(functionBody, &functionOutput)
|
||||
// Check that the function listed matches the created function
|
||||
s.Equal(s.functionUpdate.Requirements[0].Name, functionOutput.Result[0].Name, "input function name matches created function name")
|
||||
|
||||
// Attempt to update function
|
||||
status := testrequest.MakePutRequest(&s.functionUpdateJSON, target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "function created successfully")
|
||||
|
||||
// Attempt to get function
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the function listed matches the updated function
|
||||
s.Equal(s.functionUpdate.Name, output.Result[0].Name, "input name matches output name")
|
||||
s.Equal(s.functionUpdate.Tags[0].Name, output.Result[0].Tags[0].Name, "input tags match output tags")
|
||||
s.Equal(s.functionUpdate.Requirements[0].Name, output.Result[0].Requirements[0].Name, "input requirements match output requirements")
|
||||
}
|
||||
|
||||
func (s *FunctionTestSuite) Test04DeleteFunction() {
|
||||
// Setup variables
|
||||
var output TestFunction
|
||||
target := fmt.Sprintf("/function?id=%d", s.function.ID)
|
||||
|
||||
// Attempt to delete function
|
||||
status := testrequest.MakeDeleteRequest(target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "function deleted successfully")
|
||||
|
||||
// Attempt to get function
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the function list has one entry
|
||||
s.Equal(1, len(output.Result), "function list has one entry left")
|
||||
}
|
112
test/unit/functiontest/go.mod
Normal file
112
test/unit/functiontest/go.mod
Normal file
|
@ -0,0 +1,112 @@
|
|||
module example.com/unit/functiontest
|
||||
|
||||
go 1.24.2
|
||||
|
||||
replace example.com/api => ../../../src/lib/api
|
||||
|
||||
replace example.com/database => ../../../src/lib/database
|
||||
|
||||
replace example.com/database/user => ../../../src/lib/database/user
|
||||
|
||||
replace example.com/unit/functiontagtest => ../../unit/functiontagtest
|
||||
|
||||
replace example.com/test/testrequest => ../../lib/testrequest
|
||||
|
||||
replace example.com/test/testsetup => ../../lib/testsetup
|
||||
|
||||
replace example.com/database/character => ../../../src/lib/database/character
|
||||
|
||||
replace example.com/database/functionset => ../../../src/lib/database/functionset
|
||||
|
||||
replace example.com/database/inventoryslot => ../../../src/lib/database/inventoryslot
|
||||
|
||||
replace example.com/database/customization => ../../../src/lib/database/customization
|
||||
|
||||
replace example.com/database/item => ../../../src/lib/database/item
|
||||
|
||||
replace example.com/database/itemtag => ../../../src/lib/database/itemtag
|
||||
|
||||
replace example.com/database/person => ../../../src/lib/database/person
|
||||
|
||||
replace example.com/database/role => ../../../src/lib/database/role
|
||||
|
||||
replace example.com/database/schematic => ../../../src/lib/database/schematic
|
||||
|
||||
replace example.com/database/tier => ../../../src/lib/database/tier
|
||||
|
||||
replace example.com/database/group => ../../../src/lib/database/group
|
||||
|
||||
replace example.com/database/function => ../../../src/lib/database/function
|
||||
|
||||
replace example.com/database/functiontag => ../../../src/lib/database/functiontag
|
||||
|
||||
replace example.com/config/server => ../../../src/lib/config/server
|
||||
|
||||
replace example.com/auth/discord => ../../../src/lib/auth/discord
|
||||
|
||||
require (
|
||||
example.com/unit/functiontagtest v0.0.0
|
||||
example.com/database/group v0.0.0
|
||||
example.com/database/person v0.0.0
|
||||
example.com/test/testrequest v0.0.0
|
||||
example.com/test/testsetup v0.0.0
|
||||
example.com/unit/grouptest v0.0.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
gorm.io/gorm v1.25.12
|
||||
)
|
||||
|
||||
require (
|
||||
example.com/api v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/auth/discord v0.0.0 // indirect
|
||||
example.com/config/server v0.0.0 // indirect
|
||||
example.com/database v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/database/character v0.0.0 // indirect
|
||||
example.com/database/customization v0.0.0 // indirect
|
||||
example.com/database/function v0.0.0 // indirect
|
||||
example.com/database/functionset v0.0.0 // indirect
|
||||
example.com/database/functiontag v0.0.0 // indirect
|
||||
example.com/database/inventoryslot v0.0.0 // indirect
|
||||
example.com/database/item v0.0.0 // indirect
|
||||
example.com/database/itemtag v0.0.0 // indirect
|
||||
example.com/database/role v0.0.0 // indirect
|
||||
example.com/database/schematic v0.0.0 // indirect
|
||||
example.com/database/tier v0.0.0 // indirect
|
||||
example.com/database/user v0.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/cors v1.7.5 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xyproto/randomstring v1.2.0 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/sqlite v1.5.7 // indirect
|
||||
)
|
111
test/unit/functiontest/go.sum
Normal file
111
test/unit/functiontest/go.sum
Normal file
|
@ -0,0 +1,111 @@
|
|||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
108
test/unit/grouptest/go.mod
Normal file
108
test/unit/grouptest/go.mod
Normal file
|
@ -0,0 +1,108 @@
|
|||
module example.com/unit/grouptest
|
||||
|
||||
go 1.24.2
|
||||
|
||||
replace example.com/api => ../../../src/lib/api
|
||||
|
||||
replace example.com/database => ../../../src/lib/database
|
||||
|
||||
replace example.com/database/user => ../../../src/lib/database/user
|
||||
|
||||
replace example.com/test/testrequest => ../../lib/testrequest
|
||||
|
||||
replace example.com/test/testsetup => ../../lib/testsetup
|
||||
|
||||
replace example.com/database/character => ../../../src/lib/database/character
|
||||
|
||||
replace example.com/database/functionset => ../../../src/lib/database/functionset
|
||||
|
||||
replace example.com/database/inventoryslot => ../../../src/lib/database/inventoryslot
|
||||
|
||||
replace example.com/database/customization => ../../../src/lib/database/customization
|
||||
|
||||
replace example.com/database/item => ../../../src/lib/database/item
|
||||
|
||||
replace example.com/database/itemtag => ../../../src/lib/database/itemtag
|
||||
|
||||
replace example.com/database/person => ../../../src/lib/database/person
|
||||
|
||||
replace example.com/database/role => ../../../src/lib/database/role
|
||||
|
||||
replace example.com/database/schematic => ../../../src/lib/database/schematic
|
||||
|
||||
replace example.com/database/tier => ../../../src/lib/database/tier
|
||||
|
||||
replace example.com/database/group => ../../../src/lib/database/group
|
||||
|
||||
replace example.com/database/function => ../../../src/lib/database/function
|
||||
|
||||
replace example.com/database/functiontag => ../../../src/lib/database/functiontag
|
||||
|
||||
replace example.com/config/server => ../../../src/lib/config/server
|
||||
|
||||
replace example.com/auth/discord => ../../../src/lib/auth/discord
|
||||
|
||||
require (
|
||||
example.com/database/group v0.0.0
|
||||
example.com/test/testrequest v0.0.0
|
||||
example.com/test/testsetup v0.0.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
gorm.io/gorm v1.25.12
|
||||
)
|
||||
|
||||
require (
|
||||
example.com/api v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/auth/discord v0.0.0 // indirect
|
||||
example.com/config/server v0.0.0 // indirect
|
||||
example.com/database v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/database/character v0.0.0 // indirect
|
||||
example.com/database/customization v0.0.0 // indirect
|
||||
example.com/database/function v0.0.0 // indirect
|
||||
example.com/database/functionset v0.0.0 // indirect
|
||||
example.com/database/functiontag v0.0.0 // indirect
|
||||
example.com/database/inventoryslot v0.0.0 // indirect
|
||||
example.com/database/item v0.0.0 // indirect
|
||||
example.com/database/itemtag v0.0.0 // indirect
|
||||
example.com/database/person v0.0.0 // indirect
|
||||
example.com/database/role v0.0.0 // indirect
|
||||
example.com/database/schematic v0.0.0 // indirect
|
||||
example.com/database/tier v0.0.0 // indirect
|
||||
example.com/database/user v0.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/cors v1.7.5 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xyproto/randomstring v1.2.0 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/sqlite v1.5.7 // indirect
|
||||
)
|
111
test/unit/grouptest/go.sum
Normal file
111
test/unit/grouptest/go.sum
Normal file
|
@ -0,0 +1,111 @@
|
|||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
106
test/unit/grouptest/grouptest.go
Normal file
106
test/unit/grouptest/grouptest.go
Normal file
|
@ -0,0 +1,106 @@
|
|||
package grouptest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
group "example.com/database/group"
|
||||
testrequest "example.com/test/testrequest"
|
||||
testsetup "example.com/test/testsetup"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TestGroup struct {
|
||||
Result []group.Group `json:"result"`
|
||||
}
|
||||
|
||||
type GroupTestSuite struct {
|
||||
suite.Suite
|
||||
globalAuthHeader string
|
||||
router *gin.Engine
|
||||
group group.Group
|
||||
groupJSON []byte
|
||||
groupUpdate group.Group
|
||||
}
|
||||
|
||||
func (s *GroupTestSuite) SetupTestSuite() {
|
||||
s.globalAuthHeader, s.router = testsetup.SetupTestSuite()
|
||||
// Create Test Data
|
||||
s.group = group.Group{Model: gorm.Model{ID: 1}, Name: "test"}
|
||||
s.groupJSON, _ = json.Marshal(s.group)
|
||||
s.groupUpdate = group.Group{Model: gorm.Model{ID: 1}, Name: "another_test"}
|
||||
}
|
||||
|
||||
func (s *GroupTestSuite) TearDownTestSuite() {
|
||||
os.Remove("db/main.db")
|
||||
}
|
||||
|
||||
func (s *GroupTestSuite) Test01CreateGroup() {
|
||||
// Setup variables
|
||||
var output TestGroup
|
||||
target := fmt.Sprintf("/group?id=%d", s.group.ID)
|
||||
|
||||
// Attempt to create group
|
||||
status := testrequest.MakePostRequest(&s.groupJSON, "/group", s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "group created successfully")
|
||||
|
||||
// Attempt to get group
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the group listed matches the created group
|
||||
s.Equal(s.group.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *GroupTestSuite) Test02GetGroup() {
|
||||
// Setup variables
|
||||
var output TestGroup
|
||||
|
||||
// Attempt to get groups
|
||||
body := testrequest.MakeGetRequest("/group", s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the groups listed match the created groups
|
||||
s.Equal(s.group.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *GroupTestSuite) Test03UpdateGroup() {
|
||||
// Setup variables
|
||||
var output TestGroup
|
||||
body, _ := json.Marshal(s.groupUpdate)
|
||||
target := fmt.Sprintf("/group?id=%d", s.group.ID)
|
||||
|
||||
// Attempt to update group
|
||||
status := testrequest.MakePutRequest(&body, target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "group created successfully")
|
||||
|
||||
// Attempt to get group
|
||||
body = testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the group listed matches the updated group
|
||||
s.Equal(s.groupUpdate.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *GroupTestSuite) Test04DeleteGroup() {
|
||||
// Setup variables
|
||||
var output TestGroup
|
||||
target := fmt.Sprintf("/group?id=%d", s.group.ID)
|
||||
|
||||
// Attempt to delete group
|
||||
status := testrequest.MakeDeleteRequest(target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "group deleted successfully")
|
||||
|
||||
// Attempt to get group
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the group list is empty
|
||||
s.Equal(len(output.Result), 0, "input name matches output name")
|
||||
}
|
111
test/unit/persontest/go.mod
Normal file
111
test/unit/persontest/go.mod
Normal file
|
@ -0,0 +1,111 @@
|
|||
module example.com/unit/persontest
|
||||
|
||||
go 1.24.2
|
||||
|
||||
replace example.com/api => ../../../src/lib/api
|
||||
|
||||
replace example.com/database => ../../../src/lib/database
|
||||
|
||||
replace example.com/database/user => ../../../src/lib/database/user
|
||||
|
||||
replace example.com/unit/grouptest => ../../unit/grouptest
|
||||
|
||||
replace example.com/test/testrequest => ../../lib/testrequest
|
||||
|
||||
replace example.com/test/testsetup => ../../lib/testsetup
|
||||
|
||||
replace example.com/database/character => ../../../src/lib/database/character
|
||||
|
||||
replace example.com/database/functionset => ../../../src/lib/database/functionset
|
||||
|
||||
replace example.com/database/inventoryslot => ../../../src/lib/database/inventoryslot
|
||||
|
||||
replace example.com/database/customization => ../../../src/lib/database/customization
|
||||
|
||||
replace example.com/database/item => ../../../src/lib/database/item
|
||||
|
||||
replace example.com/database/itemtag => ../../../src/lib/database/itemtag
|
||||
|
||||
replace example.com/database/person => ../../../src/lib/database/person
|
||||
|
||||
replace example.com/database/role => ../../../src/lib/database/role
|
||||
|
||||
replace example.com/database/schematic => ../../../src/lib/database/schematic
|
||||
|
||||
replace example.com/database/tier => ../../../src/lib/database/tier
|
||||
|
||||
replace example.com/database/group => ../../../src/lib/database/group
|
||||
|
||||
replace example.com/database/function => ../../../src/lib/database/function
|
||||
|
||||
replace example.com/database/functiontag => ../../../src/lib/database/functiontag
|
||||
|
||||
replace example.com/config/server => ../../../src/lib/config/server
|
||||
|
||||
replace example.com/auth/discord => ../../../src/lib/auth/discord
|
||||
|
||||
require (
|
||||
example.com/unit/grouptest v0.0.0
|
||||
example.com/database/group v0.0.0
|
||||
example.com/database/person v0.0.0
|
||||
example.com/test/testrequest v0.0.0
|
||||
example.com/test/testsetup v0.0.0
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/stretchr/testify v1.10.0
|
||||
gorm.io/gorm v1.25.12
|
||||
)
|
||||
|
||||
require (
|
||||
example.com/api v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/auth/discord v0.0.0 // indirect
|
||||
example.com/config/server v0.0.0 // indirect
|
||||
example.com/database v0.0.0-00010101000000-000000000000 // indirect
|
||||
example.com/database/character v0.0.0 // indirect
|
||||
example.com/database/customization v0.0.0 // indirect
|
||||
example.com/database/function v0.0.0 // indirect
|
||||
example.com/database/functionset v0.0.0 // indirect
|
||||
example.com/database/functiontag v0.0.0 // indirect
|
||||
example.com/database/inventoryslot v0.0.0 // indirect
|
||||
example.com/database/item v0.0.0 // indirect
|
||||
example.com/database/itemtag v0.0.0 // indirect
|
||||
example.com/database/role v0.0.0 // indirect
|
||||
example.com/database/schematic v0.0.0 // indirect
|
||||
example.com/database/tier v0.0.0 // indirect
|
||||
example.com/database/user v0.0.0 // indirect
|
||||
github.com/bytedance/sonic v1.13.2 // indirect
|
||||
github.com/bytedance/sonic/loader v0.2.4 // indirect
|
||||
github.com/cloudwego/base64x v0.1.5 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
|
||||
github.com/gin-contrib/cors v1.7.5 // indirect
|
||||
github.com/gin-contrib/sse v1.0.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.26.0 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
||||
github.com/xyproto/randomstring v1.2.0 // indirect
|
||||
golang.org/x/arch v0.15.0 // indirect
|
||||
golang.org/x/crypto v0.36.0 // indirect
|
||||
golang.org/x/net v0.38.0 // indirect
|
||||
golang.org/x/oauth2 v0.29.0 // indirect
|
||||
golang.org/x/sys v0.31.0 // indirect
|
||||
golang.org/x/text v0.23.0 // indirect
|
||||
google.golang.org/protobuf v1.36.6 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
gorm.io/driver/sqlite v1.5.7 // indirect
|
||||
)
|
111
test/unit/persontest/go.sum
Normal file
111
test/unit/persontest/go.sum
Normal file
|
@ -0,0 +1,111 @@
|
|||
github.com/bytedance/sonic v1.13.2 h1:8/H1FempDZqC4VqjptGo14QQlJx8VdZJegxs6wwfqpQ=
|
||||
github.com/bytedance/sonic v1.13.2/go.mod h1:o68xyaF9u2gvVBuGHPlUVCy+ZfmNNO5ETf1+KgkJhz4=
|
||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
||||
github.com/bytedance/sonic/loader v0.2.4 h1:ZWCw4stuXUsn1/+zQDqeE7JKP+QO47tz7QCNan80NzY=
|
||||
github.com/bytedance/sonic/loader v0.2.4/go.mod h1:N8A3vUdtUebEY2/VQC0MyhYeKUFosQU6FxH2JmUe6VI=
|
||||
github.com/cloudwego/base64x v0.1.5 h1:XPciSp1xaq2VCSt6lF0phncD4koWyULpl5bUxbfCyP4=
|
||||
github.com/cloudwego/base64x v0.1.5/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
|
||||
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
|
||||
github.com/gin-contrib/cors v1.7.5 h1:cXC9SmofOrRg0w9PigwGlHG3ztswH6bqq4vJVXnvYMk=
|
||||
github.com/gin-contrib/cors v1.7.5/go.mod h1:4q3yi7xBEDDWKapjT2o1V7mScKDDr8k+jZ0fSquGoy0=
|
||||
github.com/gin-contrib/sse v1.0.0 h1:y3bT1mUWUxDpW4JLQg/HnTqV4rozuW4tC9eFKTxYI9E=
|
||||
github.com/gin-contrib/sse v1.0.0/go.mod h1:zNuFdwarAygJBht0NTKiSi3jRf6RbqeILZ9Sp6Slhe0=
|
||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.26.0 h1:SP05Nqhjcvz81uJaRfEV0YBSSSGMc/iMaVtFbr3Sw2k=
|
||||
github.com/go-playground/validator/v10 v10.26.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeDy8=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE=
|
||||
github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3 h1:x3LgcvujjG+mx8PUMfPmwn3tcu2aA95uCB6ilGGObWk=
|
||||
github.com/ravener/discord-oauth2 v0.0.0-20230514095040-ae65713199b3/go.mod h1:P/mZMYLZ87lqRSECEWsOqywGrO1hlZkk9RTwEw35IP4=
|
||||
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/xyproto/randomstring v1.2.0 h1:y7PXAEBM3XlwJjPG2JQg4voxBYZ4+hPgRdGKCfU8wik=
|
||||
github.com/xyproto/randomstring v1.2.0/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
|
||||
golang.org/x/arch v0.15.0 h1:QtOrQd0bTUnhNVNndMpLHNWrDmYzZ2KDqSrEymqInZw=
|
||||
golang.org/x/arch v0.15.0/go.mod h1:JmwW7aLIoRUKgaTzhkiEFxvcEiQGyOg9BMonBJUS7EE=
|
||||
golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34=
|
||||
golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc=
|
||||
golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8=
|
||||
golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8=
|
||||
golang.org/x/oauth2 v0.29.0 h1:WdYw2tdTK1S8olAzWHdgeqfy+Mtm9XNhv/xJsY65d98=
|
||||
golang.org/x/oauth2 v0.29.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik=
|
||||
golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
|
||||
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/sqlite v1.5.7 h1:8NvsrhP0ifM7LX9G4zPB97NwovUakUxc+2V2uuf3Z1I=
|
||||
gorm.io/driver/sqlite v1.5.7/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4=
|
||||
gorm.io/gorm v1.25.12 h1:I0u8i2hWQItBq1WfE0o2+WuL9+8L21K9e2HHSTE/0f8=
|
||||
gorm.io/gorm v1.25.12/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ=
|
||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
136
test/unit/persontest/persontest.go
Normal file
136
test/unit/persontest/persontest.go
Normal file
|
@ -0,0 +1,136 @@
|
|||
package persontest
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
group "example.com/database/group"
|
||||
person "example.com/database/person"
|
||||
testrequest "example.com/test/testrequest"
|
||||
testsetup "example.com/test/testsetup"
|
||||
grouptest "example.com/unit/grouptest"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type TestPerson struct {
|
||||
Result []person.Person `json:"result"`
|
||||
}
|
||||
|
||||
type PersonTestSuite struct {
|
||||
suite.Suite
|
||||
globalAuthHeader string
|
||||
router *gin.Engine
|
||||
person person.Person
|
||||
personJSON []byte
|
||||
personUpdate person.Person
|
||||
personUpdateJSON []byte
|
||||
}
|
||||
|
||||
func (s *PersonTestSuite) SetupTestSuite() {
|
||||
s.globalAuthHeader, s.router = testsetup.SetupTestSuite()
|
||||
// Create Test Data
|
||||
testGroup := group.Group{
|
||||
Model: gorm.Model{ID: 1},
|
||||
Name: "one",
|
||||
}
|
||||
testGroups := []group.Group{}
|
||||
var updatedGroups []group.Group
|
||||
updatedGroups = append(updatedGroups, testGroup)
|
||||
s.person = person.Person{
|
||||
Model: gorm.Model{ID: 2},
|
||||
Name: "another_test",
|
||||
Groups: testGroups,
|
||||
}
|
||||
s.personJSON, _ = json.Marshal(s.person)
|
||||
s.personUpdate = person.Person{
|
||||
Model: gorm.Model{ID: 2},
|
||||
Name: "yet_another_test",
|
||||
Groups: updatedGroups,
|
||||
}
|
||||
s.personUpdateJSON, _ = json.Marshal(person.PersonParams{
|
||||
Name: s.personUpdate.Name,
|
||||
Groups: []uint{1},
|
||||
})
|
||||
}
|
||||
|
||||
func (s *PersonTestSuite) TearDownTestSuite() {
|
||||
os.Remove("db/main.db")
|
||||
}
|
||||
|
||||
func (s *PersonTestSuite) Test01CreatePerson() {
|
||||
// Setup variables
|
||||
var output TestPerson
|
||||
target := fmt.Sprintf("/person?id=%d", s.person.ID)
|
||||
|
||||
// Attempt to create person
|
||||
status := testrequest.MakePostRequest(&s.personJSON, "/person", s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "person created successfully")
|
||||
|
||||
// Attempt to get person
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the person listed matches the created person
|
||||
s.Equal(s.person.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *PersonTestSuite) Test02GetPerson() {
|
||||
// Setup variables
|
||||
var output TestPerson
|
||||
|
||||
// Attempt to get persons
|
||||
body := testrequest.MakeGetRequest("/person", s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the persons listed match the created persons
|
||||
s.Equal(s.person.Name, output.Result[1].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *PersonTestSuite) Test03UpdatePerson() {
|
||||
// Setup variables
|
||||
var output TestPerson
|
||||
target := fmt.Sprintf("/person?id=%d", s.person.ID)
|
||||
|
||||
// Create needed field objects
|
||||
var groupOutput grouptest.TestGroup
|
||||
groupBody, _ := json.Marshal(s.personUpdate.Groups[0])
|
||||
groupStatus := testrequest.MakePostRequest(&groupBody, "/group", s.globalAuthHeader, s.router)
|
||||
s.Equal(groupStatus, "200 OK", "group created successfully")
|
||||
groupTarget := fmt.Sprintf("/group?id=%d", s.personUpdate.Groups[0].ID)
|
||||
groupBody = testrequest.MakeGetRequest(groupTarget, s.router)
|
||||
json.Unmarshal(groupBody, &groupOutput)
|
||||
|
||||
// Attempt to update person
|
||||
status := testrequest.MakePutRequest(&s.personUpdateJSON, target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "person created successfully")
|
||||
|
||||
// Attempt to get person
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the person listed matches the updated person
|
||||
s.Equal(s.personUpdate.Name, output.Result[0].Name, "input name matches output name")
|
||||
}
|
||||
|
||||
func (s *PersonTestSuite) Test04DeletePerson() {
|
||||
// Setup variables
|
||||
var output TestPerson
|
||||
target := fmt.Sprintf("/person?id=%d", s.person.ID)
|
||||
|
||||
// Attempt to delete person
|
||||
status := testrequest.MakeDeleteRequest(target, s.globalAuthHeader, s.router)
|
||||
// Check that the request was successful
|
||||
s.Equal(status, "200 OK", "person deleted successfully")
|
||||
|
||||
// Attempt to get person
|
||||
body := testrequest.MakeGetRequest(target, s.router)
|
||||
// Unmarshal the result
|
||||
json.Unmarshal(body, &output)
|
||||
// Check that the person list is empty
|
||||
s.Equal(1, len(output.Result), "person list is empty")
|
||||
}
|
Loading…
Reference in a new issue