mirror of
https://github.com/p1neappleXpress/OpenFlux.git
synced 2026-10-02 05:04:39 +08:00
buildTransportSpecs overrode every [Transport] URL with its per-type flag (--vyandex-url, --yandex-url, ...) even when the flag was unset, so an exit started from --config ran vyandex with an empty URL (Get "": unsupported protocol scheme "") and never reached its document. Only a flag that was set overrides now.
22 lines
884 B
Go
22 lines
884 B
Go
package main
|
|
|
|
import "testing"
|
|
|
|
// A per-type URL flag overrides a .conf transport's URL only when it is set:
|
|
// the unset flags are "", and overriding with them wiped the document URL of
|
|
// every [Transport] section, so a --config exit started vyandex with no URL.
|
|
func TestBuildTransportSpecsKeepsConfURL(t *testing.T) {
|
|
specs := []transportSpec{
|
|
{Name: "vyandex", Type: "vyandex", URL: "https://docs.yandex.ru/edit/d/conf"},
|
|
{Name: "yandex", Type: "yandex", URL: "https://disk.yandex.ru/i/conf"},
|
|
}
|
|
urls := map[string]string{"vyandex": "", "yandex": "https://disk.yandex.ru/i/flag"}
|
|
got := buildTransportSpecs(specs, urls, nil)
|
|
if got[0].URL != "https://docs.yandex.ru/edit/d/conf" {
|
|
t.Fatalf("unset flag wiped the conf URL: %q", got[0].URL)
|
|
}
|
|
if got[1].URL != "https://disk.yandex.ru/i/flag" {
|
|
t.Fatalf("a set flag must override the conf URL: %q", got[1].URL)
|
|
}
|
|
}
|