oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package websource
2
3import (
4 "slices"
5 "testing"
6)
7
8func mentioned(text string) []string {
9 var out []string
10 for _, u := range Mentions(text) {
11 out = append(out, u.String())
12 }
13 return out
14}
15
16// TestMentions: the person's own words give their http(s) URLs as typed
17// (made canonical) and their bare domains as https://<domain>/, in the
18// order written, once each. File names, e-mail addresses, abbreviations,
19// version numbers and refused hosts are not sources.
20func TestMentions(t *testing.T) {
21 for text, want := range map[string][]string{
22 "Make it look like https://shop.example.com/about.": {"https://shop.example.com/about"},
23 "Our site is shop.example.com, and the menu is at shop.example.com/menu": {"https://shop.example.com/", "https://shop.example.com/menu"},
24 "(see http://Example.org/Hours?day=mon) and HTTPS://example.net": {"http://example.org/Hours?day=mon", "https://example.net/"},
25 "https://shop.example.com and shop.example.com again": {"https://shop.example.com/"},
26 "Fix README.md and main.go, like Next.js does, e.g. in v1.2.3 i.e. now": nil,
27 "Mail owner@shop.example.com or first.last@example.org": nil,
28 "Not http://localhost:8080/, http://10.0.0.1/ or box.example.ts.net": nil,
29 "ftp://example.com/file and https://user:pw@example.com/": nil,
30 "Brand: barber.example.co.uk; logo at https://cdn.example.com/logo.png)": {"https://barber.example.co.uk/", "https://cdn.example.com/logo.png"},
31 "": nil,
32 } {
33 if got := mentioned(text); !slices.Equal(got, want) {
34 t.Errorf("%q: %v, want %v", text, got, want)
35 }
36 }
37}
38