-
Notifications
You must be signed in to change notification settings - Fork 22
/
shared_test.go
43 lines (38 loc) · 1.08 KB
/
shared_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package shuffle
import (
"testing"
"net/http"
)
func TestIsLoop(t *testing.T) {
handlers := []struct {
arg string
expected bool
}{
{"$exec.#1-2", true},
{"$exec.#.value.#1", true},
{"$exec.#1", false},
{"$exec", false},
{"$exec.#1.value.#2", false},
{"$start_node.#", true},
{"\n$Change_Me\n.#3.value\n", false},
{"\n\n\n\n$Change_Me\n\n.\n#\n.\n\nvalue\n\n\n", true},
}
for _, tt := range handlers {
result := isLoop(tt.arg)
if result != tt.expected {
t.Errorf("isLoop(%s) = %v; expected %v", tt.arg, result, tt.expected)
}
}
}
// Simple Test for HandleInternalProxy(client)
// set env SHUFFLE_INTERNAL_HTTP_PROXY to test the function.
func TestHandleInternalProxy(t *testing.T) {
client := &http.Client{}
result := HandleInternalProxy(client)
if result.Transport.(*http.Transport).Proxy != nil {
proxyURL, _ := result.Transport.(*http.Transport).Proxy(nil)
t.Logf("Proxy URL set: %v", proxyURL)
} else {
t.Log("No proxy set")
}
}