package register

import (
	"testing"

	"github.com/stretchr/testify/require"
	service_config "github.com/tidbcloud/dataflow-service-ng/internal/config"
)

// The base URL is what the observation worker keys off, and the two must agree:
// a deployment that schedules no observer has nothing for the collector to
// report, and no table for it to read.
func TestRunsDataPipelineFollowsTheConfiguredBaseURL(t *testing.T) {
	t.Parallel()

	for name, testCase := range map[string]struct {
		baseURL string
		want    bool
	}{
		"configured": {baseURL: "http://lake-svc-proxy:8080", want: true},
		"absent":     {baseURL: "", want: false},
		"whitespace": {baseURL: "   ", want: false},
	} {
		t.Run(name, func(t *testing.T) {
			t.Parallel()
			require.Equal(t, testCase.want,
				runsDataPipeline(service_config.DataPipelineConfig{LakeBaseURL: testCase.baseURL}))
		})
	}
}
