MCPcopy Create free account
hub / github.com/google/go-cloud / TestOpenSubscriptionFromURL

Function TestOpenSubscriptionFromURL

pubsub/mempubsub/mem_test.go:102–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

100}
101
102func TestOpenSubscriptionFromURL(t *testing.T) {
103 tests := []struct {
104 URL string
105 WantErr bool
106 }{
107 // OK.
108 {"mem://mytopic", false},
109 // OK with ackdeadline
110 {"mem://mytopic?ackdeadline=30s", false},
111 // Invalid ackdeadline
112 {"mem://mytopic?ackdeadline=notaduration", true},
113 // Nonexistent topic.
114 {"mem://nonexistenttopic", true},
115 // Invalid parameter.
116 {"mem://myproject/mysub?param=value", true},
117 }
118
119 ctx := context.Background()
120 pubsub.OpenTopic(ctx, "mem://mytopic")
121 for _, test := range tests {
122 sub, err := pubsub.OpenSubscription(ctx, test.URL)
123 if (err != nil) != test.WantErr {
124 t.Errorf("%s: got error %v, want error %v", test.URL, err, test.WantErr)
125 }
126 if sub != nil {
127 sub.Shutdown(ctx)
128 }
129 }
130}
131
132func TestSendNoSubs(t *testing.T) {
133 // It's OK to send a message to a topic with no subscribers.

Callers

nothing calls this directly

Calls 3

OpenTopicFunction · 0.92
OpenSubscriptionFunction · 0.92
ShutdownMethod · 0.65

Tested by

no test coverage detected