mirror of
https://github.com/chylex/SMTP-Relay.git
synced 2025-08-16 04:31:41 +02:00
.github
cmd
internal
config
account.go
config.go
ini.go
proto.go
proto_test.go
logger
smtp
smtprelay.go
tools
.gitignore
Dockerfile
LICENSE
README.md
go.mod
go.sum
smtprelay.ini
51 lines
864 B
Go
51 lines
864 B
Go
package config
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
func TestSplitProto(t *testing.T) {
|
|
var tests = []struct {
|
|
input string
|
|
proto string
|
|
addr string
|
|
}{
|
|
{
|
|
input: "localhost",
|
|
proto: "",
|
|
addr: "localhost",
|
|
},
|
|
{
|
|
input: "tls://my.local.domain",
|
|
proto: "tls",
|
|
addr: "my.local.domain",
|
|
},
|
|
{
|
|
input: "starttls://my.local.domain",
|
|
proto: "starttls",
|
|
addr: "my.local.domain",
|
|
},
|
|
}
|
|
|
|
for i, test := range tests {
|
|
testName := test.input
|
|
t.Run(
|
|
testName, func(t *testing.T) {
|
|
pa := splitProto(test.input)
|
|
if pa.Protocol != test.proto {
|
|
t.Errorf(
|
|
"Testcase %d: Incorrect proto: expected %v, got %v",
|
|
i, test.proto, pa.Protocol,
|
|
)
|
|
}
|
|
if pa.Address != test.addr {
|
|
t.Errorf(
|
|
"Testcase %d: Incorrect addr: expected %v, got %v",
|
|
i, test.addr, pa.Address,
|
|
)
|
|
}
|
|
},
|
|
)
|
|
}
|
|
}
|