Debian Codegraph @

testserver/testserver_test.go

raw symbols SCIP
1 // Copyright 2016 The Cockroach Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 // implied. See the License for the specific language governing
13 // permissions and limitations under the License.
14
15 package testserver_test
16
17 import (
18 "strings"
19 "testing"
20
21 "github.com/cockroachdb/cockroach-go/testserver"
22 )
23
24 func TestRunServer(t *testing.T) {
25 db, stop := testserver.NewDBForTest(t)
26 defer stop()
27
28 if _, err := db.Exec("SELECT 1"); err != nil {
29 t.Fatal(err)
30 }
31 }
32
33 func TestPGURLWhitespace(t *testing.T) {
34 ts, err := testserver.NewTestServer()
35 if err != nil {
36 t.Fatal(err)
37 }
38 if err := ts.Start(); err != nil {
39 t.Fatal(err)
40 }
41 url := ts.PGURL().String()
42 if trimmed := strings.TrimSpace(url); url != trimmed {
43 t.Errorf("unexpected whitespace in server URL: %q", url)
44 }
45 }