xorm/dialects/mssql_test.go
Lunny Xiao bf25a77bca
All checks were successful
continuous-integration/drone/push Build is passing
Merge core package back into the main repository and split into serval sub packages. (#1543)
Fix test

Improve fmt

update go.mod

Move core as a sub package

Reviewed-on: #1543
2020-02-24 08:53:18 +00:00

34 lines
880 B
Go

// Copyright 2019 The Xorm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package dialects
import (
"reflect"
"testing"
)
func TestParseMSSQL(t *testing.T) {
tests := []struct {
in string
expected string
valid bool
}{
{"sqlserver://sa:yourStrong(!)Password@localhost:1433?database=db&connection+timeout=30", "db", true},
{"server=localhost;user id=sa;password=yourStrong(!)Password;database=db", "db", true},
}
driver := QueryDriver("mssql")
for _, test := range tests {
uri, err := driver.Parse("mssql", test.in)
if err != nil && test.valid {
t.Errorf("%q got unexpected error: %s", test.in, err)
} else if err == nil && !reflect.DeepEqual(test.expected, uri.DBName) {
t.Errorf("%q got: %#v want: %#v", test.in, uri.DBName, test.expected)
}
}
}