Fis test pipeline
This commit is contained in:
parent
d21d775764
commit
b3ce926309
@ -41,14 +41,14 @@ jobs:
|
|||||||
- name: Setup Go
|
- name: Setup Go
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version-file: '${{ gitea.workspace }}/go.mod'
|
go-version-file: '${{ gitea.workspace }}/scnserver/go.mod'
|
||||||
cache: false
|
cache: false
|
||||||
|
|
||||||
- name: Print Go Version
|
- name: Print Go Version
|
||||||
run: go version
|
run: go version
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: cd "${{ gitea.workspace }}/scnserver" && make dgi && make swagger && make test
|
run: cd "${{ gitea.workspace }}/scnserver" && make dgi && make swagger && SCN_TEST_LOGLEVEL=WARN make test
|
||||||
|
|
||||||
- name: Send failure mail
|
- name: Send failure mail
|
||||||
if: failure()
|
if: failure()
|
||||||
|
@ -65,6 +65,8 @@ class _AppBarFilterDialogState extends State<AppBarFilterDialog> {
|
|||||||
_buildFilterItem(context, FontAwesomeIcons.bolt, 'Priority', _showPriorityModal),
|
_buildFilterItem(context, FontAwesomeIcons.bolt, 'Priority', _showPriorityModal),
|
||||||
Divider(),
|
Divider(),
|
||||||
_buildFilterItem(context, FontAwesomeIcons.gearCode, 'Key', _showKeytokenModal),
|
_buildFilterItem(context, FontAwesomeIcons.gearCode, 'Key', _showKeytokenModal),
|
||||||
|
Divider(),
|
||||||
|
_buildFilterItem(context, FontAwesomeIcons.magnifyingGlassPlus, 'Search (Plain)', _showPlainSearchModal),
|
||||||
SizedBox(height: 4),
|
SizedBox(height: 4),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -113,4 +115,8 @@ class _AppBarFilterDialogState extends State<AppBarFilterDialog> {
|
|||||||
void _showTimeModal(BuildContext context) {
|
void _showTimeModal(BuildContext context) {
|
||||||
showDialog<void>(context: context, builder: (BuildContext context) => FilterModalTime());
|
showDialog<void>(context: context, builder: (BuildContext context) => FilterModalTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showPlainSearchModal(BuildContext context) {
|
||||||
|
//TODO showDialog<void>(context: context, builder: (BuildContext context) => FilterModalSearchPlain());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,6 @@ func TestMain(m *testing.M) {
|
|||||||
if !exerr.Initialized() {
|
if !exerr.Initialized() {
|
||||||
exerr.Init(exerr.ErrorPackageConfigInit{ZeroLogErrTraces: langext.PFalse, ZeroLogAllTraces: langext.PFalse})
|
exerr.Init(exerr.ErrorPackageConfigInit{ZeroLogErrTraces: langext.PFalse, ZeroLogAllTraces: langext.PFalse})
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(m.Run())
|
os.Exit(m.Run())
|
||||||
}
|
}
|
||||||
|
@ -599,8 +599,8 @@ func TestGetSubscriptionToForeignChannel(t *testing.T) {
|
|||||||
|
|
||||||
assertCount2 := func(u tt.Userdat, c int, dir string, conf string, ext string) {
|
assertCount2 := func(u tt.Userdat, c int, dir string, conf string, ext string) {
|
||||||
slist := tt.RequestAuthGet[sublist](t, u.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions?direction=%s&confirmation=%s&external=%s", u.UID, dir, conf, ext))
|
slist := tt.RequestAuthGet[sublist](t, u.AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/subscriptions?direction=%s&confirmation=%s&external=%s", u.UID, dir, conf, ext))
|
||||||
fmt.Printf("assertCount2 := %d\n", len(slist.Subscriptions))
|
//fmt.Printf("assertCount2 := %d\n", len(slist.Subscriptions))
|
||||||
//tt.AssertEqual(t, dir+"."+conf+"."+ext+".len", c, len(slist.Subscriptions))
|
tt.AssertEqual(t, dir+"."+conf+"."+ext+".len", c, len(slist.Subscriptions))
|
||||||
}
|
}
|
||||||
|
|
||||||
clist := tt.RequestAuthGet[chanlist](t, data.User[16].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", data.User[16].UID))
|
clist := tt.RequestAuthGet[chanlist](t, data.User[16].AdminKey, baseUrl, fmt.Sprintf("/api/v2/users/%s/channels", data.User[16].UID))
|
||||||
|
@ -12,7 +12,17 @@ func InitTests() {
|
|||||||
log.Logger = createLogger(createConsoleWriter())
|
log.Logger = createLogger(createConsoleWriter())
|
||||||
|
|
||||||
gin.SetMode(gin.TestMode)
|
gin.SetMode(gin.TestMode)
|
||||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
|
||||||
|
if llstr, ok := os.LookupEnv("SCN_TEST_LOGLEVEL"); ok {
|
||||||
|
ll, err := zerolog.ParseLevel(llstr)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
zerolog.SetGlobalLevel(ll)
|
||||||
|
} else {
|
||||||
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func createConsoleWriter() *zerolog.ConsoleWriter {
|
func createConsoleWriter() *zerolog.ConsoleWriter {
|
||||||
|
@ -3,6 +3,7 @@ package util
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -27,18 +28,22 @@ func ClearBufLogger(dump bool) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TPrintf(format string, a ...any) {
|
func TPrintf(lvl zerolog.Level, format string, a ...any) {
|
||||||
if buflogger != nil {
|
if zerolog.GlobalLevel() <= lvl {
|
||||||
buflogger.Printf(format, a...)
|
if buflogger != nil {
|
||||||
} else {
|
buflogger.Printf(format, a...)
|
||||||
fmt.Printf(format, a...)
|
} else {
|
||||||
|
fmt.Printf(format, a...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TPrintln(a ...any) {
|
func TPrintln(lvl zerolog.Level, a ...any) {
|
||||||
if buflogger != nil {
|
if zerolog.GlobalLevel() <= lvl {
|
||||||
buflogger.Println(a...)
|
if buflogger != nil {
|
||||||
} else {
|
buflogger.Println(a...)
|
||||||
fmt.Println(a...)
|
} else {
|
||||||
|
fmt.Println(a...)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||||
"io"
|
"io"
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
@ -101,7 +102,7 @@ func RequestAuthDeleteShouldFail(t *testing.T, akey string, baseURL string, urlS
|
|||||||
func RequestAny[TResult any](t *testing.T, akey string, method string, baseURL string, urlSuffix string, body any, deserialize bool) TResult {
|
func RequestAny[TResult any](t *testing.T, akey string, method string, baseURL string, urlSuffix string, body any, deserialize bool) TResult {
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
|
|
||||||
TPrintf("[-> REQUEST] (%s) %s%s [%s] [%s]\n", method, baseURL, urlSuffix, langext.Conditional(akey == "", "NO AUTH", "AUTH"), langext.Conditional(body == nil, "NO BODY", "BODY"))
|
TPrintf(zerolog.InfoLevel, "[-> REQUEST] (%s) %s%s [%s] [%s]\n", method, baseURL, urlSuffix, langext.Conditional(akey == "", "NO AUTH", "AUTH"), langext.Conditional(body == nil, "NO BODY", "BODY"))
|
||||||
|
|
||||||
bytesbody := make([]byte, 0)
|
bytesbody := make([]byte, 0)
|
||||||
contentType := ""
|
contentType := ""
|
||||||
@ -159,16 +160,16 @@ func RequestAny[TResult any](t *testing.T, akey string, method string, baseURL s
|
|||||||
TestFailErr(t, err)
|
TestFailErr(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintln("")
|
TPrintln(zerolog.DebugLevel, "")
|
||||||
TPrintf("---------------- RESPONSE (%d) ----------------\n", resp.StatusCode)
|
TPrintf(zerolog.DebugLevel, "---------------- RESPONSE (%d) ----------------\n", resp.StatusCode)
|
||||||
if len(respBodyBin) > 100_000 {
|
if len(respBodyBin) > 100_000 {
|
||||||
TPrintln("[[RESPONSE TOO LONG]]")
|
TPrintln(zerolog.DebugLevel, "[[RESPONSE TOO LONG]]")
|
||||||
} else {
|
} else {
|
||||||
TPrintln(langext.TryPrettyPrintJson(string(respBodyBin)))
|
TPrintln(zerolog.DebugLevel, langext.TryPrettyPrintJson(string(respBodyBin)))
|
||||||
}
|
}
|
||||||
TryPrintTraceObj("---------------- -------- ----------------", respBodyBin, "")
|
TryPrintTraceObj(zerolog.DebugLevel, "---------------- -------- ----------------", respBodyBin, "")
|
||||||
TPrintln("---------------- -------- ----------------")
|
TPrintln(zerolog.DebugLevel, "---------------- -------- ----------------")
|
||||||
TPrintln("")
|
TPrintln(zerolog.DebugLevel, "")
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
TestFailFmt(t, "Statuscode != 200 (actual = %d)", resp.StatusCode)
|
TestFailFmt(t, "Statuscode != 200 (actual = %d)", resp.StatusCode)
|
||||||
@ -195,7 +196,7 @@ func RequestAny[TResult any](t *testing.T, akey string, method string, baseURL s
|
|||||||
func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL string, urlSuffix string, body any, expectedStatusCode int, errcode apierr.APIError) {
|
func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL string, urlSuffix string, body any, expectedStatusCode int, errcode apierr.APIError) {
|
||||||
client := http.Client{}
|
client := http.Client{}
|
||||||
|
|
||||||
TPrintf("[-> REQUEST] (%s) %s%s [%s] (should-fail with %d/%d)\n", method, baseURL, urlSuffix, langext.Conditional(akey == "", "NO AUTH", "AUTH"), expectedStatusCode, errcode)
|
TPrintf(zerolog.InfoLevel, "[-> REQUEST] (%s) %s%s [%s] (should-fail with %d/%d)\n", method, baseURL, urlSuffix, langext.Conditional(akey == "", "NO AUTH", "AUTH"), expectedStatusCode, errcode)
|
||||||
|
|
||||||
bytesbody := make([]byte, 0)
|
bytesbody := make([]byte, 0)
|
||||||
contentType := ""
|
contentType := ""
|
||||||
@ -250,14 +251,14 @@ func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL
|
|||||||
TestFailErr(t, err)
|
TestFailErr(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintln("")
|
TPrintln(zerolog.DebugLevel, "")
|
||||||
TPrintf("---------------- RESPONSE (%d) ----------------\n", resp.StatusCode)
|
TPrintf(zerolog.DebugLevel, "---------------- RESPONSE (%d) ----------------\n", resp.StatusCode)
|
||||||
TPrintln(langext.TryPrettyPrintJson(string(respBodyBin)))
|
TPrintln(zerolog.DebugLevel, langext.TryPrettyPrintJson(string(respBodyBin)))
|
||||||
if (expectedStatusCode != 0 && resp.StatusCode != expectedStatusCode) || (expectedStatusCode == 0 && resp.StatusCode == 200) {
|
if (expectedStatusCode != 0 && resp.StatusCode != expectedStatusCode) || (expectedStatusCode == 0 && resp.StatusCode == 200) {
|
||||||
TryPrintTraceObj("---------------- -------- ----------------", respBodyBin, "")
|
TryPrintTraceObj(zerolog.DebugLevel, "---------------- -------- ----------------", respBodyBin, "")
|
||||||
}
|
}
|
||||||
TPrintln("---------------- -------- ----------------")
|
TPrintln(zerolog.DebugLevel, "---------------- -------- ----------------")
|
||||||
TPrintln("")
|
TPrintln(zerolog.DebugLevel, "")
|
||||||
|
|
||||||
if expectedStatusCode != 0 && resp.StatusCode != expectedStatusCode {
|
if expectedStatusCode != 0 && resp.StatusCode != expectedStatusCode {
|
||||||
TestFailFmt(t, "Statuscode != %d (expected failure, but got %d)", expectedStatusCode, resp.StatusCode)
|
TestFailFmt(t, "Statuscode != %d (expected failure, but got %d)", expectedStatusCode, resp.StatusCode)
|
||||||
@ -290,19 +291,19 @@ func RequestAuthAnyShouldFail(t *testing.T, akey string, method string, baseURL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TryPrintTraceObj(prefix string, body []byte, suffix string) {
|
func TryPrintTraceObj(lvl zerolog.Level, prefix string, body []byte, suffix string) {
|
||||||
v1 := gin.H{}
|
v1 := gin.H{}
|
||||||
if err := json.Unmarshal(body, &v1); err == nil {
|
if err := json.Unmarshal(body, &v1); err == nil {
|
||||||
if v2, ok := v1["traceObj"]; ok {
|
if v2, ok := v1["traceObj"]; ok {
|
||||||
if v3, ok := v2.(string); ok {
|
if v3, ok := v2.(string); ok {
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
TPrintln(prefix)
|
TPrintln(lvl, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintln(strings.TrimSpace(v3))
|
TPrintln(lvl, strings.TrimSpace(v3))
|
||||||
|
|
||||||
if suffix != "" {
|
if suffix != "" {
|
||||||
TPrintln(suffix)
|
TPrintln(lvl, suffix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"blackforestbytes.com/simplecloudnotifier/jobs"
|
"blackforestbytes.com/simplecloudnotifier/jobs"
|
||||||
"blackforestbytes.com/simplecloudnotifier/logic"
|
"blackforestbytes.com/simplecloudnotifier/logic"
|
||||||
"blackforestbytes.com/simplecloudnotifier/push"
|
"blackforestbytes.com/simplecloudnotifier/push"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/ginext"
|
"gogs.mikescher.com/BlackForestBytes/goext/ginext"
|
||||||
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
"gogs.mikescher.com/BlackForestBytes/goext/langext"
|
||||||
"os"
|
"os"
|
||||||
@ -71,9 +72,9 @@ func StartSimpleWebserver(t *testing.T) (*logic.Application, string, func()) {
|
|||||||
TestFailErr(t, err)
|
TestFailErr(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintln("DatabaseFile<main>: " + dbfile1)
|
TPrintln(zerolog.InfoLevel, "DatabaseFile<main>: "+dbfile1)
|
||||||
TPrintln("DatabaseFile<requests>: " + dbfile2)
|
TPrintln(zerolog.InfoLevel, "DatabaseFile<requests>: "+dbfile2)
|
||||||
TPrintln("DatabaseFile<logs>: " + dbfile3)
|
TPrintln(zerolog.InfoLevel, "DatabaseFile<logs>: "+dbfile3)
|
||||||
|
|
||||||
scn.Conf = CreateTestConfig(t, dbfile1, dbfile2, dbfile3)
|
scn.Conf = CreateTestConfig(t, dbfile1, dbfile2, dbfile3)
|
||||||
|
|
||||||
@ -113,10 +114,10 @@ func StartSimpleWebserver(t *testing.T) (*logic.Application, string, func()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stop := func() {
|
stop := func() {
|
||||||
t.Logf("Stopping App")
|
TPrintln(zerolog.InfoLevel, "Stopping App")
|
||||||
app.Stop()
|
app.Stop()
|
||||||
_ = app.IsRunning.WaitWithTimeout(5*time.Second, false)
|
_ = app.IsRunning.WaitWithTimeout(5*time.Second, false)
|
||||||
t.Logf("Stopped App")
|
TPrintln(zerolog.InfoLevel, "Stopped App")
|
||||||
_ = os.Remove(dbfile1)
|
_ = os.Remove(dbfile1)
|
||||||
_ = os.Remove(dbfile2)
|
_ = os.Remove(dbfile2)
|
||||||
_ = os.Remove(dbfile3)
|
_ = os.Remove(dbfile3)
|
||||||
@ -186,9 +187,9 @@ func StartSimpleTestspace(t *testing.T) (string, string, string, scn.Config, fun
|
|||||||
TestFailErr(t, err)
|
TestFailErr(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
TPrintln("DatabaseFile<main>: " + dbfile1)
|
TPrintln(zerolog.InfoLevel, "DatabaseFile<main>: "+dbfile1)
|
||||||
TPrintln("DatabaseFile<requests>: " + dbfile2)
|
TPrintln(zerolog.InfoLevel, "DatabaseFile<requests>: "+dbfile2)
|
||||||
TPrintln("DatabaseFile<logs>: " + dbfile3)
|
TPrintln(zerolog.InfoLevel, "DatabaseFile<logs>: "+dbfile3)
|
||||||
|
|
||||||
scn.Conf = CreateTestConfig(t, dbfile1, dbfile2, dbfile3)
|
scn.Conf = CreateTestConfig(t, dbfile1, dbfile2, dbfile3)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user