mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
Some of the files were quite big:
- asns.csv ~ 3 MB
- index.js ~ 1.5 MB
- *.svg ~ 2 MB
Use a ZIP archive to put them all and embed it. This reduce the binary
size from 89 MB to 82 MB. 🤯
This also pulls some code modernization (use of http.ServeFileFS).
29 lines
635 B
Go
29 lines
635 B
Go
// SPDX-FileCopyrightText: 2025 Free Mobile
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package embed_test
|
|
|
|
import (
|
|
"io"
|
|
"testing"
|
|
|
|
"akvorado/common/embed"
|
|
"akvorado/common/helpers"
|
|
)
|
|
|
|
func TestData(t *testing.T) {
|
|
f, err := embed.Data().Open("orchestrator/clickhouse/data/protocols.csv")
|
|
if err != nil {
|
|
t.Fatalf("Open() error:\n%+v", err)
|
|
}
|
|
expected := "proto,name,description"
|
|
got := make([]byte, len(expected))
|
|
_, err = io.ReadFull(f, got)
|
|
if err != nil {
|
|
t.Fatalf("ReadFull() error:\n%+v", err)
|
|
}
|
|
if diff := helpers.Diff(string(got), expected); diff != "" {
|
|
t.Fatalf("ReadFull() (-got, +want):\n%s", diff)
|
|
}
|
|
}
|