MCPcopy
hub / github.com/fabiolb/fabio / TestNewTableCustom

Function TestNewTableCustom

route/table_test.go:674–736  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

672}
673
674func TestNewTableCustom(t *testing.T) {
675
676 var routes []RouteDef
677 var tags = []string{"tag1", "tag2"}
678 var opts = make(map[string]string)
679 opts["tlsskipverify"] = "true"
680 opts["proto"] = "http"
681
682 var route1 = RouteDef{
683 Cmd: "route add",
684 Service: "service1",
685 Src: "app.com",
686 Dst: "http://10.1.1.1:8080",
687 Weight: 0.50,
688 Tags: tags,
689 Opts: opts,
690 }
691 var route2 = RouteDef{
692 Cmd: "route add",
693 Service: "service1",
694 Src: "app.com",
695 Dst: "http://10.1.1.2:8080",
696 Weight: 0.50,
697 Tags: tags,
698 Opts: opts,
699 }
700 var route3 = RouteDef{
701 Cmd: "route add",
702 Service: "service2",
703 Src: "app.com",
704 Dst: "http://10.1.1.3:8080",
705 Weight: 0.25,
706 Tags: tags,
707 Opts: opts,
708 }
709
710 routes = append(routes, route1)
711 routes = append(routes, route2)
712 routes = append(routes, route3)
713
714 table, err := NewTableCustom(&routes)
715
716 if err != nil {
717 fmt.Printf("Got error from NewTableCustom - %s", err.Error())
718 t.FailNow()
719 }
720
721 tableString := table.String()
722 if !strings.Contains(tableString, route1.Dst) {
723 fmt.Printf("Table Missing Destination %s -- Table -- %s", route1.Dst, tableString)
724 t.FailNow()
725 }
726
727 if !strings.Contains(tableString, route2.Dst) {
728 fmt.Printf("Table Missing Destination %s -- Table -- %s", route1.Dst, tableString)
729 t.FailNow()
730 }
731

Callers

nothing calls this directly

Calls 3

NewTableCustomFunction · 0.85
ErrorMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected