mirror of
https://git.evilfox.cc/test2/wg.git
synced 2026-08-01 12:23:22 +00:00
Add Go WireGuard panel with PostgreSQL 17 and Dokploy compose.
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package mysqlimport
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestParseDump(t *testing.T) {
|
||||
path := `D:\Новая папка (10)\wg\wg.sql`
|
||||
raw, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Skip(err)
|
||||
}
|
||||
text := string(raw)
|
||||
counts := map[string]int{}
|
||||
for _, m := range reInsert.FindAllStringSubmatch(text, -1) {
|
||||
table := m[1]
|
||||
rows, err := splitValueTuples(m[2])
|
||||
if err != nil {
|
||||
t.Fatalf("%s: %v", table, err)
|
||||
}
|
||||
for _, row := range rows {
|
||||
cols, err := tableColumns(table)
|
||||
if err != nil {
|
||||
t.Fatalf("cols %s: %v", table, err)
|
||||
}
|
||||
vals, err := parseRowValues(row)
|
||||
if err != nil {
|
||||
t.Fatalf("row %s: %v", table, err)
|
||||
}
|
||||
if len(vals) != len(cols) {
|
||||
t.Fatalf("%s col mismatch got=%d want=%d sample=%s", table, len(vals), len(cols), truncate(row, 100))
|
||||
}
|
||||
}
|
||||
counts[table] += len(rows)
|
||||
}
|
||||
if counts["wg_configs"] < 1 {
|
||||
t.Fatalf("expected wg_configs rows, got %+v", counts)
|
||||
}
|
||||
if counts["users"] < 1 {
|
||||
t.Fatalf("expected users rows, got %+v", counts)
|
||||
}
|
||||
t.Logf("counts: %+v", counts)
|
||||
}
|
||||
Reference in New Issue
Block a user