tests: update makefile and add test for validators and writter
All checks were successful
CI.yml / build (push) Successful in 2m20s

This commit is contained in:
d3m0k1d
2026-01-15 17:27:46 +03:00
parent 623bd87b4c
commit 14c6c64989
3 changed files with 90 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package storage
import (
"testing"
"time"
)
func TestWrite(t *testing.T) {
var ip string
d := createTestDBStruct(t)
err := d.CreateTable()
if err != nil {
t.Fatal(err)
}
resultCh := make(chan *LogEntry)
go Write(d, resultCh)
resultCh <- &LogEntry{
Service: "test",
IP: "127.0.0.1",
Path: "/test",
Method: "GET",
Status: "200",
}
close(resultCh)
time.Sleep(100 * time.Millisecond)
err = d.db.QueryRow("SELECT ip FROM requests LIMIT 1").Scan(&ip)
if err != nil {
t.Fatal(err)
}
if ip != "127.0.0.1" {
t.Fatal("ip should be 127.0.0.1")
}
}