package web import ( "net/http/httptest" "os" "path/filepath" "strings" "testing" "nasmon/internal/shares" ) func TestSharesPageListsExternal(t *testing.T) { srv, _, _ := newTestServer(t) f := &shareRunner{} withShareRunner(srv, f) dir := t.TempDir() smbDir, nfsDir := filepath.Join(dir, "smb.conf.d"), filepath.Join(dir, "exports.d") _ = os.MkdirAll(smbDir, 0o755) _ = os.MkdirAll(nfsDir, 0o755) _ = os.WriteFile(filepath.Join(smbDir, "repoiso.conf"), []byte("[iso-pve]\n path = /tank/iso/export/pve\n"), 0o644) _ = os.WriteFile(filepath.Join(nfsDir, "repoiso.exports"), []byte("\"/tank/iso/export/pve\" 10.10.0.0/24(ro)\n"), 0o644) srv.shm.IncludeDir, srv.shm.ExportsDir, srv.shm.Exports = smbDir, nfsDir, filepath.Join(nfsDir, shares.DefaultExports) rec := httptest.NewRecorder() srv.ServeHTTP(rec, httptest.NewRequest("GET", "/shares", nil)) body := rec.Body.String() for _, want := range []string{`id="external"`, "iso-pve", "/tank/iso/export/pve", "10.10.0.0/24(ro)", ">repoiso<"} { if !strings.Contains(body, want) { t.Errorf("shares page lacks %q", want) } } }