Link to source
This commit is contained in:
@@ -156,6 +156,43 @@ func TestParseRefusesStrayArguments(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// The source link is a URL someone will set by hand on a fork, so a value that
|
||||
// would render a broken link has to be refused at startup rather than shipped
|
||||
// to every page.
|
||||
func TestSourceURLMustBeAbsoluteOrEmpty(t *testing.T) {
|
||||
base := func() Config {
|
||||
c := Config{}
|
||||
fs := NewSet("test", "UNCENSORED_SEND_TEST_")
|
||||
c.Register(fs)
|
||||
if err := fs.Parse(nil); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
c := base()
|
||||
if err := c.Normalise(); err != nil {
|
||||
t.Fatalf("the default source URL was refused: %v", err)
|
||||
}
|
||||
if c.SourceURL == "" {
|
||||
t.Error("the default build links no source at all")
|
||||
}
|
||||
|
||||
c = base()
|
||||
c.SourceURL = ""
|
||||
if err := c.Normalise(); err != nil {
|
||||
t.Errorf("switching the source link off was refused: %v", err)
|
||||
}
|
||||
|
||||
for _, bad := range []string{"not a url", "/relative/path", "example.org/repo"} {
|
||||
c = base()
|
||||
c.SourceURL = bad
|
||||
if err := c.Normalise(); err == nil {
|
||||
t.Errorf("--source-url %q was accepted", bad)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The convention is: one hyphen for a letter, two for a word. It is enforced
|
||||
// here because the stdlib flag package treats both forms as the same.
|
||||
func TestHyphenConvention(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user