Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion mole/mole.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ func (c *Configuration) Merge(al *alias.Alias, givenFlags []string) error {
}
c.Timeout = tim

c.SshConfig = al.SshConfig
if al.SshConfig != "" {
c.SshConfig = al.SshConfig
}

c.Rpc = al.Rpc

Expand Down
32 changes: 29 additions & 3 deletions mole/mole_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,48 @@ func TestAliasMerge(t *testing.T) {
Detach: true,
},
},
{
&alias.Alias{
Verbose: false,
Insecure: false,
Detach: false,
Source: []string{"127.0.0.1:80"},
Destination: []string{"172.17.0.100:8080"},
Server: "user@example.com:22",
Key: "path/to/key/1",
KeepAliveInterval: "3s",
ConnectionRetries: 3,
WaitAndRetry: "10s",
SshAgent: "path/to/sshagent",
Timeout: "3s",
},
[]string{},
mole.Configuration{
SshConfig: "path/to/config",
},
mole.Configuration{
SshConfig: "path/to/config",
},
},
}

for id, test := range tests {
conf := test.conf
conf.Merge(test.alias, test.givenFlags)

if test.expected.Verbose != conf.Verbose {
t.Errorf("alias verbose doesn't match on test %d: expected: %t, value: %t", id, test.expected.Verbose, test.alias.Verbose)
t.Errorf("verbose doesn't match on test %d: expected: %t, value: %t", id, test.expected.Verbose, conf.Verbose)
}

if test.expected.Insecure != conf.Insecure {
t.Errorf("alias insecure doesn't match on test %d: expected: %t, value: %t", id, test.expected.Insecure, test.alias.Insecure)
t.Errorf("insecure doesn't match on test %d: expected: %t, value: %t", id, test.expected.Insecure, conf.Insecure)
}

if test.expected.Detach != conf.Detach {
t.Errorf("alias detach doesn't match on test %d: expected: %t, value: %t", id, test.expected.Detach, test.alias.Detach)
t.Errorf("detach doesn't match on test %d: expected: %t, value: %t", id, test.expected.Detach, conf.Detach)
}
if test.expected.SshConfig != conf.SshConfig {
t.Errorf("sshConfig doesn't match on test %d: expected: %s, value: %s", id, test.expected.SshConfig, conf.SshConfig)
}
}

Expand Down