Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alibaba100 20180709 #1663

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
59 changes: 56 additions & 3 deletions ctrd/image_proxy_util_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,68 @@
package ctrd

import "testing"
import (
"testing"
"net/url"
)

func TestHasPort(t *testing.T) {
// TODO
}

func TestCanonicalAddr(t *testing.T) {
// TODO

tests := []struct {
name string
url url.URL
want bool
}{
{url: url.URL{Scheme: string("http"), Host: string("localhost")}, want: true},
{url: url.URL{Scheme: string("http"), Host: string("192.168.1.1")}, want: true},
{url: url.URL{Scheme: string("http"), Host: string("127.0.0.1")}, want: true},
{url: url.URL{Scheme: string("https"), Host: string("127.0.0.1")}, want: true},
{url: url.URL{Scheme: string("x"), Host: string("127.0.0.1:8081")}, want: true},
}
portMap = map[string]string{
"http": "80",
"https": "443",
"socks5": "1080",
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := canonicalAddr(&test.url)
//if url.URL.Port(test.url.Host)!="" {
// if got != test.url.Host+":80" {
// t.Errorf("canonicalAddr() = %v, want %v", got, test.want)
// return
// }
//}
if got != test.url.Host+":"+portMap[test.url.Scheme] {
t.Errorf("canonicalAddr() = %v, want %v", got, test.want)
return
}
})
}

}

func TestUseProxy(t *testing.T) {
// TODO
tests := []struct {
name string
addr string
want bool
}{
{addr: string("192.168.1.1:80"), want: true},
{addr: string("192.168.1.2:80"), want: true},
{addr: string("192.168.1.3:80"), want: true},
{addr: string("192.168.1.4:80"), want: true},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
got := useProxy(test.addr)
if got == false {
t.Errorf("useProxy(%v) = %v, want %v", test.addr, got, test.want)
return
}
})
}
}
1 change: 0 additions & 1 deletion test/z_cli_daemon_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package main

import (
"encoding/json"
"fmt"
Expand Down