Files
gluetun/internal/models/markdown_test.go

57 lines
1.3 KiB
Go
Raw Normal View History

2021-09-23 13:13:17 +00:00
package models
import (
"testing"
"github.com/qdm12/gluetun/internal/constants/providers"
2021-09-23 13:13:17 +00:00
"github.com/stretchr/testify/assert"
)
func Test_Servers_ToMarkdown(t *testing.T) {
2021-09-23 13:13:17 +00:00
t.Parallel()
testCases := map[string]struct {
provider string
servers Servers
expectedMarkdown string
}{
providers.Cyberghost: {
provider: providers.Cyberghost,
servers: Servers{
Servers: []Server{
{Country: "a", UDP: true, Hostname: "xa"},
{Country: "b", TCP: true, Hostname: "xb"},
},
},
expectedMarkdown: "| Country | Hostname | TCP | UDP |\n" +
"| --- | --- | --- | --- |\n" +
"| a | `xa` | ❌ | ✅ |\n" +
"| b | `xb` | ✅ | ❌ |\n",
},
providers.Fastestvpn: {
provider: providers.Fastestvpn,
servers: Servers{
Servers: []Server{
{Country: "a", Hostname: "xa", TCP: true},
{Country: "b", Hostname: "xb", UDP: true},
},
},
expectedMarkdown: "| Country | Hostname | TCP | UDP |\n" +
"| --- | --- | --- | --- |\n" +
"| a | `xa` | ✅ | ❌ |\n" +
"| b | `xb` | ❌ | ✅ |\n",
2021-09-23 13:13:17 +00:00
},
}
for name, testCase := range testCases {
testCase := testCase
t.Run(name, func(t *testing.T) {
t.Parallel()
2021-09-23 13:13:17 +00:00
markdown := testCase.servers.ToMarkdown(testCase.provider)
2021-09-23 13:13:17 +00:00
assert.Equal(t, testCase.expectedMarkdown, markdown)
})
2021-09-23 13:13:17 +00:00
}
}