| 1 | package manpagescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 5 | |
| 6 | "golang.org/x/text/languagescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/" |
| 7 | ) |
| 8 | |
| 9 | func TestManpageFromManPathscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/TestManpageFromManPath().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 10 | table := []struct { |
| 11 | path string |
| 12 | pkg PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta# |
| 13 | wantLang string |
| 14 | wantSection string |
| 15 | wantServingPath string |
| 16 | }{ |
| 17 | // Verify the codeset is stripped from the path. |
| 18 | { |
| 19 | path: "bg.UTF-8/man6/hex-a-hop.6.gz", |
| 20 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "hex-a-hop", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 21 | wantLang: "bg", |
| 22 | wantSection: "6", |
| 23 | wantServingPath: "testing/hex-a-hop/hex-a-hop.6.bg", |
| 24 | }, |
| 25 | |
| 26 | // Verify the modifier is retained from the path. |
| 27 | { |
| 28 | path: "ca@valencia/man1/deja-dup.1.gz", |
| 29 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "deja-dup", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 30 | wantLang: "ca@valencia", |
| 31 | wantSection: "1", |
| 32 | wantServingPath: "testing/deja-dup/deja-dup.1.ca@valencia", |
| 33 | }, |
| 34 | |
| 35 | // Verify the section is parsed correctly for files which do |
| 36 | // not have a .gz extension. |
| 37 | { |
| 38 | path: "man3/el_init.3", |
| 39 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "libedit-dev", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 40 | wantLang: "en", |
| 41 | wantSection: "3", |
| 42 | wantServingPath: "testing/libedit-dev/el_init.3.en", |
| 43 | }, |
| 44 | |
| 45 | // Verify subsections are parsed correctly. |
| 46 | { |
| 47 | path: "man3/editline.3edit", |
| 48 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "libedit-dev", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 49 | wantLang: "en", |
| 50 | wantSection: "3edit", |
| 51 | wantServingPath: "testing/libedit-dev/editline.3edit.en", |
| 52 | }, |
| 53 | } |
| 54 | |
| 55 | for _, entry := range table { |
| 56 | entry := entry // capture |
| 57 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(entry.path, func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 58 | t.Parallelscip-go gomod github.com/golang/go/src go1.13 testing/T#Parallel().() |
| 59 | m, err := FromManPathscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/FromManPath().(entry.path, &entry.pkg) |
| 60 | if err != nil { |
| 61 | t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err) |
| 62 | } |
| 63 | if got, want := m.Languagescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/Meta#Language., entry.wantLang; got != want { |
| 64 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Unexpected language: got %q, want %q", got, want) |
| 65 | } |
| 66 | if got, want := m.Sectionscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/Meta#Section., entry.wantSection; got != want { |
| 67 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Unexpected section: got %q, want %q", got, want) |
| 68 | } |
| 69 | if got, want := m.ServingPathscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/Meta#ServingPath().(), entry.wantServingPath; got != want { |
| 70 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Unexpected serving path: got %q, want %q", got, want) |
| 71 | } |
| 72 | }) |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | func TestLanguageTagscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/TestLanguageTag().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 77 | table := []struct { |
| 78 | path string |
| 79 | pkg PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta# |
| 80 | wantTag languagescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/.Tagscip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/Tag# |
| 81 | }{ |
| 82 | // Verify pt_BR can be parsed (text/language calls it pt-BR) |
| 83 | { |
| 84 | path: "pt_BR/man1/deja-dup.1.gz", |
| 85 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "deja-dup", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 86 | wantTag: languagescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/.BrazilianPortuguesescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/BrazilianPortuguese., |
| 87 | }, |
| 88 | |
| 89 | { |
| 90 | path: "pt_PT/man1/deja-dup.1.gz", |
| 91 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "deja-dup", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 92 | wantTag: languagescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/.EuropeanPortuguesescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/EuropeanPortuguese., |
| 93 | }, |
| 94 | |
| 95 | { |
| 96 | path: "sr@latin/man1/ark.1.gz", |
| 97 | pkg: PkgMetascip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#{Binarypkgscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Binarypkg.: "kde-l10n-sr", Suitescip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/PkgMeta#Suite.: "testing"}, |
| 98 | wantTag: languagescip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/.SerbianLatinscip-go gomod golang.org/x/text v0.3.2 `golang.org/x/text/language`/SerbianLatin., |
| 99 | }, |
| 100 | } |
| 101 | |
| 102 | for _, entry := range table { |
| 103 | entry := entry // capture |
| 104 | t.Runscip-go gomod github.com/golang/go/src go1.13 testing/T#Run().(entry.path, func(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 105 | t.Parallelscip-go gomod github.com/golang/go/src go1.13 testing/T#Parallel().() |
| 106 | m, err := FromManPathscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/FromManPath().(entry.path, &entry.pkg) |
| 107 | if err != nil { |
| 108 | t.Fatalscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatal().(err) |
| 109 | } |
| 110 | if got, want := m.LanguageTagscip-go gomod github.com/Debian/debiman . `github.com/Debian/debiman/internal/manpage`/Meta#LanguageTag., entry.wantTag; got != want { |
| 111 | t.Fatalfscip-go gomod github.com/golang/go/src go1.13 testing/common#Fatalf().("Unexpected language: got %q, want %q", got, want) |
| 112 | } |
| 113 | }) |
| 114 | } |
| 115 | } |