lab4: вложения в S3 (MinIO), reconciler PostgreSQL↔S3, тесты и CI

This commit is contained in:
2026-11-04 20:11:33 +03:00
parent ec540a1a72
commit 77b6e5c2c7
86 changed files with 6921 additions and 2 deletions
+39
View File
@@ -0,0 +1,39 @@
package service
import (
"strings"
"testing"
)
func TestValidatePassword(t *testing.T) {
cases := []struct {
name string
in string
want bool
}{
{"обычный", "correct-horse-12", true},
{"ровно 12", strings.Repeat("a", 12), true},
{"128 code points", strings.Repeat("я", 128), true},
{"двоеточие допустимо", "pass:word:1234", true},
{"пробелы внутри допустимы", " pass word ", true},
{"короче 12", strings.Repeat("a", 11), false},
{"длиннее 128", strings.Repeat("a", 129), false},
{"12 пробелов", strings.Repeat(" ", 12), false},
{"пробельные символы разных видов", strings.Repeat(" \t\n ", 4), false},
{"пусто", "", false},
}
for _, c := range cases {
if got := validatePassword(c.in); got != c.want {
t.Errorf("%s: validatePassword(%q) = %v, want %v", c.name, c.in, got, c.want)
}
}
}
func TestValidateText(t *testing.T) {
if validateText(strings.Repeat(" ", 5)) {
t.Error("whitespace-only text must be rejected")
}
if !validateText("привет") {
t.Error("normal text must be accepted")
}
}