Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fortuna committed Dec 11, 2024
1 parent 6c199bf commit dbaf0a2
Showing 1 changed file with 73 additions and 1 deletion.
74 changes: 73 additions & 1 deletion client/go/outline/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,78 @@

package outline

import "testing"
import (
"testing"

"github.com/stretchr/testify/require"
)


func Test_NewClientFromJSON_Success(t *testing.T) {
tests := []struct {
name string
input string
}{
{
name: "SS URL",
input: "ss://[email protected]:4321/",
}, {
name: "Legacy JSON",
input:
`{
"server": "example.com",
"server_port": 4321,
"method": "chacha20-ietf-poly1305",
"password": "SECRET"
}`,
},{
name: "Flexible JSON",
input:
`{
# Comment
$type: ss,
server: example.com,
server_port: 4321,
method: chacha20-ietf-poly1305,
password: SECRET
}`,
},{
name: "YAML",
input:
`# Comment
$type: ss
server: example.com
server_port: 4321
method: chacha20-ietf-poly1305
password: SECRET`,
},{
name: "Explicit endpoint",
input:
`$type: ss
endpoint:
$type: dial
address: canary.getoutline.org:443
cipher: chacha20-ietf-poly1305
secret: SECRET`,
},{
name: "Explicit endpoint",
input:
`$type: ss
endpoint:
$type: dial
address: example.com:4321
dialer: ss://[email protected]:4321/
cipher: chacha20-ietf-poly1305
secret: SECRET`,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := NewClient(tt.input)
require.Nil(t, result.Error)
})
}
}

func Test_NewClientFromJSON_Errors(t *testing.T) {
tests := []struct {
Expand Down Expand Up @@ -76,3 +147,4 @@ func Test_NewClientFromJSON_Errors(t *testing.T) {
})
}
}

0 comments on commit dbaf0a2

Please sign in to comment.