golang-lib/web/auth/api_my_delete_test.go

40 lines
861 B
Go
Raw Permalink Normal View History

2021-06-01 10:51:35 +02:00
package auth
import (
"net/http"
"testing"
"github.com/stretchr/testify/assert"
2023-10-23 21:40:10 +02:00
"codeberg.org/genofire/golang-lib/web"
"codeberg.org/genofire/golang-lib/web/webtest"
2021-06-01 10:51:35 +02:00
)
2021-06-30 15:55:34 +02:00
func TestAPIDeleteMyProfil(t *testing.T) {
2021-06-01 10:51:35 +02:00
assert := assert.New(t)
s, err := webtest.NewWithDBSetup(Register, SetupMigration)
2021-06-28 13:59:27 +02:00
assert.NoError(err)
defer s.Close()
2021-06-01 10:51:35 +02:00
assert.NotNil(s)
hErr := web.HTTPError{}
// invalid
2021-06-30 15:55:34 +02:00
err = s.Request(http.MethodDelete, "/api/v1/my/profil", nil, http.StatusUnauthorized, &hErr)
2021-06-28 12:14:20 +02:00
assert.NoError(err)
2021-07-22 18:16:05 +02:00
assert.Equal(ErrAPINoSession.Error(), hErr.Message)
2021-06-01 10:51:35 +02:00
2021-06-30 15:55:34 +02:00
err = s.Login(webtest.Login{
Username: "admin",
Password: "CHANGEME",
})
2021-06-28 12:14:20 +02:00
assert.NoError(err)
2021-06-01 10:51:35 +02:00
2021-06-30 15:55:34 +02:00
res := false
// company
err = s.Request(http.MethodDelete, "/api/v1/my/profil", nil, http.StatusOK, &res)
2021-06-28 12:14:20 +02:00
assert.NoError(err)
2021-06-30 15:55:34 +02:00
assert.True(true)
2021-06-01 10:51:35 +02:00
2021-07-14 12:29:58 +02:00
s.DB.ReMigrate("10-data-0008-01-user")
2021-06-01 10:51:35 +02:00
}