MCPcopy Index your code
hub / github.com/Shopify/toxiproxy / TestDeleteProxy

Function TestDeleteProxy

api_test.go:619–661  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

617}
618
619func TestDeleteProxy(t *testing.T) {
620 WithServer(t, func(addr string) {
621 testProxy, err := client.CreateProxy("mysql_master", "localhost:3310", "localhost:20001")
622 if err != nil {
623 t.Fatal("Unable to create proxy:", err)
624 }
625
626 proxies, err := client.Proxies()
627 if err != nil {
628 t.Fatal("Error listing proxies:", err)
629 }
630
631 if len(proxies) == 0 {
632 t.Fatal("Expected new proxy in list")
633 }
634
635 AssertProxyUp(t, testProxy.Listen, true)
636
637 err = testProxy.Delete()
638 if err != nil {
639 t.Fatal("Failed deleting proxy:", err)
640 }
641
642 AssertProxyUp(t, testProxy.Listen, false)
643
644 proxies, err = client.Proxies()
645 if err != nil {
646 t.Fatal("Error listing proxies:", err)
647 }
648
649 if len(proxies) > 0 {
650 t.Fatal("Expected proxy to be deleted from list")
651 }
652
653 expected := "Delete: HTTP 404: proxy not found"
654 err = testProxy.Delete()
655 if err == nil {
656 t.Error("Proxy did not result in not found.")
657 } else if err.Error() != expected {
658 t.Errorf("Expected error `%s',\n\tgot: `%s'", expected, err)
659 }
660 })
661}
662
663func TestCreateProxyPortConflict(t *testing.T) {
664 WithServer(t, func(addr string) {

Callers

nothing calls this directly

Calls 6

WithServerFunction · 0.85
AssertProxyUpFunction · 0.85
CreateProxyMethod · 0.80
DeleteMethod · 0.80
ProxiesMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…