mirror of
https://github.com/hoernschen/dendrite.git
synced 2024-12-27 07:28:27 +00:00
d88f71ab71
### Pull Request Checklist <!-- Please read https://matrix-org.github.io/dendrite/development/contributing before submitting your pull request --> * [x] I have added Go unit tests or [Complement integration tests](https://github.com/matrix-org/complement) for this PR _or_ I have justified why this PR doesn't need tests * [x] Pull request includes a [sign off below using a legally identifiable name](https://matrix-org.github.io/dendrite/development/contributing#sign-off) _or_ I have already signed off privately Signed-off-by: `Boris Rybalkin <ribalkin@gmail.com>`
43 lines
1.1 KiB
Go
43 lines
1.1 KiB
Go
package config
|
|
|
|
import (
|
|
"io/fs"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestHttpAddress_ParseGood(t *testing.T) {
|
|
address, err := HTTPAddress("http://localhost:123")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "localhost:123", address.Address)
|
|
assert.Equal(t, "tcp", address.Network())
|
|
}
|
|
|
|
func TestHttpAddress_ParseBad(t *testing.T) {
|
|
_, err := HTTPAddress(":")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestUnixSocketAddress_Network(t *testing.T) {
|
|
address, err := UnixSocketAddress("/tmp", "0755")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "unix", address.Network())
|
|
}
|
|
|
|
func TestUnixSocketAddress_Permission_LeadingZero_Ok(t *testing.T) {
|
|
address, err := UnixSocketAddress("/tmp", "0755")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, fs.FileMode(0755), address.UnixSocketPermission)
|
|
}
|
|
|
|
func TestUnixSocketAddress_Permission_NoLeadingZero_Ok(t *testing.T) {
|
|
address, err := UnixSocketAddress("/tmp", "755")
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, fs.FileMode(0755), address.UnixSocketPermission)
|
|
}
|
|
|
|
func TestUnixSocketAddress_Permission_NonOctal_Bad(t *testing.T) {
|
|
_, err := UnixSocketAddress("/tmp", "855")
|
|
assert.Error(t, err)
|
|
}
|