mirror of
https://git.freecumextremist.com/grumbulon/pomme.git
synced 2024-11-22 04:23:46 +00:00
remove unused code and file.
This commit is contained in:
parent
e06e8c4e25
commit
b5302bdc8c
2 changed files with 5 additions and 48 deletions
|
@ -2,9 +2,7 @@ package api
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
@ -24,12 +22,6 @@ import (
|
|||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type response struct {
|
||||
Username string `json:"username"`
|
||||
Message string `json:"message"`
|
||||
Status int `json:"status"`
|
||||
}
|
||||
|
||||
type accountTest struct {
|
||||
username string
|
||||
password string
|
||||
|
@ -52,7 +44,7 @@ func makeTestToken(username string) (tokenString string, err error) {
|
|||
func TestAPI(t *testing.T) {
|
||||
config, err := internal.ReadConfig()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
pomme := chi.NewRouter()
|
||||
|
@ -204,8 +196,6 @@ func (a *accountTest) TestOpenRoutes(t *testing.T) {
|
|||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var target response
|
||||
|
||||
client := http.Client{}
|
||||
|
||||
form := url.Values{}
|
||||
|
@ -222,13 +212,6 @@ func (a *accountTest) TestOpenRoutes(t *testing.T) {
|
|||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
|
||||
err = json.Unmarshal(respBody, &target)
|
||||
if err != nil {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
assert.Equal(t, tc.expected.response, resp.StatusCode)
|
||||
}
|
||||
})
|
||||
|
@ -260,8 +243,6 @@ func (a *accountTest) TestRateLimit(t *testing.T) {
|
|||
}
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var target response
|
||||
|
||||
client := http.Client{}
|
||||
|
||||
form := url.Values{}
|
||||
|
@ -275,12 +256,6 @@ func (a *accountTest) TestRateLimit(t *testing.T) {
|
|||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
|
||||
err = json.Unmarshal(respBody, &target)
|
||||
if err != nil {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
if resp.StatusCode == tc.expected.response {
|
||||
assert.Equal(t, tc.expected.response, resp.StatusCode)
|
||||
}
|
||||
|
@ -320,11 +295,10 @@ func (a *accountTest) TestProtectedRoutes(t *testing.T) {
|
|||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var (
|
||||
f *os.File
|
||||
target response
|
||||
err error
|
||||
buf = new(bytes.Buffer)
|
||||
w = multipart.NewWriter(buf)
|
||||
f *os.File
|
||||
err error
|
||||
buf = new(bytes.Buffer)
|
||||
w = multipart.NewWriter(buf)
|
||||
)
|
||||
|
||||
f, err = os.CreateTemp(".", "zonefile")
|
||||
|
@ -373,13 +347,6 @@ func (a *accountTest) TestProtectedRoutes(t *testing.T) {
|
|||
if err != nil {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
|
||||
respBody, _ := io.ReadAll(resp.Body)
|
||||
|
||||
err = json.Unmarshal(respBody, &target)
|
||||
if err != nil {
|
||||
assert.NotNil(t, err)
|
||||
}
|
||||
assert.Equal(t, tc.expected.response, resp.StatusCode)
|
||||
}
|
||||
})
|
||||
|
@ -387,15 +354,6 @@ func (a *accountTest) TestProtectedRoutes(t *testing.T) {
|
|||
}
|
||||
|
||||
func (a *accountTest) CleanUp(db *gorm.DB) {
|
||||
var (
|
||||
user internal.User
|
||||
req internal.ZoneRequest
|
||||
)
|
||||
|
||||
db.Where("username = ?", a.username).Delete(&user)
|
||||
|
||||
db.Where("user = ?", a.username).Delete(&req)
|
||||
|
||||
if err := os.Remove("pomme-test.sqlite"); err != nil {
|
||||
l := newResponder(Response[any]{
|
||||
Message: "unable to clean up test DB",
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
package logger
|
Loading…
Reference in a new issue