Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
shueybubbles committed Mar 1, 2024
1 parent e868109 commit d4192bc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions namedpipe/namepipe_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ func TestParseServer(t *testing.T) {
err = n.ParseServer(`\\.\pipe\MSSQL$Instance\sql\query`, c)
assert.NoError(t, err, "ParseServer with a full pipe name")
assert.Equal(t, "", c.Host, "Config Host with a full pipe name")
data, ok := c.ProtocolParameters[n.Protocol()]
assert.True(t, ok, "Should have added ProtocolParameters when server is pipe name")
switch d := data.(type) {
case namedPipeData:
assert.Equal(t, `\\.\pipe\MSSQL$Instance\sql\query`, d.PipeName, "Pipe name in ProtocolParameters when server is pipe name")
default:
assert.Fail(t, "Incorrect protocol parameters type:", d)
}

c = &msdsn.Config{
Parameters: make(map[string]string),
Expand All @@ -31,7 +39,7 @@ func TestParseServer(t *testing.T) {
assert.NoError(t, err, "ParseServer .")
assert.Equal(t, "localhost", c.Host, `Config Host with server == .\instance`)
assert.Equal(t, "instance", c.Instance, `Config Instance with server == .\instance`)
_, ok := c.ProtocolParameters[n.Protocol()]
_, ok = c.ProtocolParameters[n.Protocol()]
assert.Equal(t, ok, false, "Should have no namedPipeData when pipe name omitted")

c = &msdsn.Config{
Expand All @@ -42,7 +50,7 @@ func TestParseServer(t *testing.T) {
c.Parameters["pipe"] = `myinstance\sql\query`
err = n.ParseServer(`anything`, c)
assert.NoError(t, err, "ParseServer anything")
data, ok := c.ProtocolParameters[n.Protocol()]
data, ok = c.ProtocolParameters[n.Protocol()]
assert.True(t, ok, "Should have added ProtocolParameters when pipe name is provided")
switch d := data.(type) {
case namedPipeData:
Expand Down

0 comments on commit d4192bc

Please sign in to comment.