oficina / sheets Public

Clone
git clone https://amadan.net/oficina/sheets

Plain git — no account needed to clone.

Download

Download this file

1package guards
2
3import (
4 "testing"
5)
6
7// excelizeImport is the XLSX library's import path.
8const excelizeImport = "github.com/xuri/excelize/v2"
9
10// excelizeHome is the package tree allowed to import it — xlsx itself
11// and any subpackage of it. Matched as a tree, not by exact directory
12// equality: equality would make a future xlsx subpackage look like it
13// was outside home and wrongly forbid it from importing excelize (the
14// over-strict direction — a false positive, not a leak — but still
15// wrong). Confining excelize's quirks to this one tree keeps the XLSX
16// format's weirdness from leaking into the rest of Sheets.
17const excelizeHome = "internal/sheets/xlsx"
18
19// TestExcelizeConfinedToXLSXPackage fails on any excelize import outside
20// the internal/sheets/xlsx tree.
21func TestExcelizeConfinedToXLSXPackage(t *testing.T) {
22 root := repoRoot(t)
23 for _, path := range goFiles(t, root) {
24 rel := relPath(t, root, path)
25 if inTree(rel, excelizeHome) {
26 continue
27 }
28 for _, imp := range fileImports(t, path) {
29 if imp == excelizeImport {
30 t.Errorf("%s: imports %q, confined to %s (excelize confinement)", rel, excelizeImport, excelizeHome)
31 }
32 }
33 }
34}
35