Feat: format-servers CLI command

This commit is contained in:
Quentin McGaw (desktop)
2021-09-23 13:13:17 +00:00
parent c22e0e9db7
commit 03ba9169f4
6 changed files with 440 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package models
import (
"testing"
"github.com/stretchr/testify/assert"
)
func Test_CyberghostServers_ToMarkdown(t *testing.T) {
t.Parallel()
servers := CyberghostServers{
Servers: []CyberghostServer{
{Region: "a", Group: "A", Hostname: "xa"},
{Region: "b", Group: "A", Hostname: "xb"},
},
}
markdown := servers.ToMarkdown()
const expected = "| Region | Group | Hostname |\n" +
"| --- | --- | --- |\n" +
"| a | A | `xa` |\n" +
"| b | A | `xb` |\n"
assert.Equal(t, expected, markdown)
}
func Test_FastestvpnServers_ToMarkdown(t *testing.T) {
t.Parallel()
servers := FastestvpnServers{
Servers: []FastestvpnServer{
{Country: "a", Hostname: "xa", TCP: true},
{Country: "b", Hostname: "xb", UDP: true},
},
}
markdown := servers.ToMarkdown()
const expected = "| Country | Hostname | TCP | UDP |\n" +
"| --- | --- | --- | --- |\n" +
"| a | `xa` | ✅ | ❎ |\n" +
"| b | `xb` | ❎ | ✅ |\n"
assert.Equal(t, expected, markdown)
}