Files
OpenFlux/transport_spec_url_test.go
meepo161 d7dc7b8335 main: keep .conf transport URLs when per-type flags are unset
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.
2026-09-26 19:08:10 +03:00

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)
}
}