You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
673 B
Go

7 years ago
package main
import (
"os"
7 years ago
"testing"
yaml "gopkg.in/yaml.v2"
7 years ago
)
func TestConf(t *testing.T) {
data, err := os.ReadFile("config.sample.yaml")
7 years ago
if err != nil {
t.Fatal(err)
}
var c conf
if err := yaml.Unmarshal(data, &c); err != nil {
t.Fatal(err)
}
4 years ago
// fmt.Printf("%+v\n", c)
7 years ago
var testdata = map[string]string{
"www.example.com": "127.0.0.1:8443 proxy-v2",
"b.example.com": "127.0.0.1:8542",
7 years ago
}
r := forwardRules(c.ForwardRules)
for k, v := range testdata {
s := r.Get(k)
if s != v {
t.Errorf("expected: %s, got: %s", v, s)
}
}
if r.GetN("a.com", 9999) != "a.com:443" {
t.Errorf("expected a.com:9999, got %s", r.GetN("a.com", 9999))
}
}