MCPcopy Create free account
hub / github.com/sql-machine-learning/sqlflow / testingMaxComputeConfig

Function testingMaxComputeConfig

go/database/testing.go:122–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

120}
121
122func testingMaxComputeConfig() *gomaxcompute.Config {
123 endpoint := test.GetEnv("SQLFLOW_TEST_DB_MAXCOMPUTE_ENDPOINT", "http://service-maxcompute.com/api")
124 urlAndArgs := strings.Split(endpoint, "?")
125 // accept format like http://service-maxcompute.com/api
126 // if got service-maxcompute.com/api?curr_project=xxxx&scheme=http, reformat to http://service-maxcompute.com/api
127 if len(urlAndArgs) == 2 {
128 if !(strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://")) {
129 argList := strings.Split(urlAndArgs[1], "&")
130 for _, kv := range argList {
131 kvList := strings.Split(kv, "=")
132 if len(kvList) == 2 && kvList[0] == "scheme" {
133 endpoint = fmt.Sprintf("%s://%s", kvList[1], urlAndArgs[0])
134 break
135 }
136 }
137 }
138 } else {
139 if !(strings.HasPrefix(endpoint, "http://") || strings.HasPrefix(endpoint, "https://")) {
140 log.Fatal("SQLFLOW_TEST_DB_MAXCOMPUTE_ENDPOINT must be the form of http://service-maxcompute.com/api or service-maxcompute.com/api?scheme=http")
141 }
142 }
143 return &gomaxcompute.Config{
144 AccessID: test.GetEnv("SQLFLOW_TEST_DB_MAXCOMPUTE_AK", "test"),
145 AccessKey: test.GetEnv("SQLFLOW_TEST_DB_MAXCOMPUTE_SK", "test"),
146 Project: test.GetEnv("SQLFLOW_TEST_DB_MAXCOMPUTE_PROJECT", "test"),
147 Endpoint: endpoint,
148 }
149}
150
151func testingMaxComputeURL() string {
152 return fmt.Sprintf("maxcompute://%s", testingMaxComputeConfig().FormatDSN())

Callers 1

testingMaxComputeURLFunction · 0.85

Calls 2

GetEnvFunction · 0.92
FatalMethod · 0.80

Tested by

no test coverage detected