generated from VLADIMIR/template
up
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 5.6 MiB |
@@ -5,6 +5,7 @@ import (
|
|||||||
"archive/zip"
|
"archive/zip"
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
_ "embed"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -28,6 +29,12 @@ const (
|
|||||||
maxPackageSize = 256 << 20
|
maxPackageSize = 256 << 20
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed assets/organizer-map.png
|
||||||
|
var organizerMap []byte
|
||||||
|
|
||||||
|
//go:embed assets/organizer-payment.png
|
||||||
|
var organizerPayment []byte
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrPackageTooLarge = errors.New("материалы для печати превышают 256 МБ")
|
ErrPackageTooLarge = errors.New("материалы для печати превышают 256 МБ")
|
||||||
ErrInvalidPrintText = errors.New("текст материалов содержит неподдерживаемые символы")
|
ErrInvalidPrintText = errors.New("текст материалов содержит неподдерживаемые символы")
|
||||||
@@ -119,6 +126,17 @@ func (s *GamePrintService) Download(ctx context.Context, gameID int) ([]byte, st
|
|||||||
_, err = entry.Write(data)
|
_, err = entry.Write(data)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
for _, material := range []struct {
|
||||||
|
name string
|
||||||
|
data []byte
|
||||||
|
}{
|
||||||
|
{"карта лил бразил.png", organizerMap},
|
||||||
|
{"evening-detective-payment-a4.png", organizerPayment},
|
||||||
|
} {
|
||||||
|
if err := add(hostFolder+material.name, material.data); err != nil {
|
||||||
|
return nil, "", err
|
||||||
|
}
|
||||||
|
}
|
||||||
intro := ""
|
intro := ""
|
||||||
if story.Introduction != nil {
|
if story.Introduction != nil {
|
||||||
intro = cleaner.NewCleaner().ClearText(story.Introduction.Text)
|
intro = cleaner.NewCleaner().ClearText(story.Introduction.Text)
|
||||||
|
|||||||
@@ -157,6 +157,17 @@ func TestDownloadPrintMaterials(t *testing.T) {
|
|||||||
t.Errorf("missing PDF %s", name)
|
t.Errorf("missing PDF %s", name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, material := range []struct {
|
||||||
|
name string
|
||||||
|
data []byte
|
||||||
|
}{
|
||||||
|
{"карта лил бразил.png", organizerMap},
|
||||||
|
{"evening-detective-payment-a4.png", organizerPayment},
|
||||||
|
} {
|
||||||
|
if !bytes.Equal(entries[hostFolder+material.name], material.data) {
|
||||||
|
t.Errorf("original organizer material changed or missing: %s", material.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
diplomas := 0
|
diplomas := 0
|
||||||
for name := range entries {
|
for name := range entries {
|
||||||
if strings.HasPrefix(name, hostFolder+"Дипломы/") {
|
if strings.HasPrefix(name, hostFolder+"Дипломы/") {
|
||||||
@@ -178,7 +189,7 @@ func TestDownloadPrintMaterials(t *testing.T) {
|
|||||||
if !bytes.Equal(entries[playerFolder+"Улики/001 - Письмо _ улика.pdf"], f.files["clue.pdf"]) {
|
if !bytes.Equal(entries[playerFolder+"Улики/001 - Письмо _ улика.pdf"], f.files["clue.pdf"]) {
|
||||||
t.Fatal("original clue was changed or missing")
|
t.Fatal("original clue was changed or missing")
|
||||||
}
|
}
|
||||||
wantEntries := 10
|
wantEntries := 12
|
||||||
if tc.wantQR {
|
if tc.wantQR {
|
||||||
wantEntries++
|
wantEntries++
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user