MCPcopy Create free account
hub / github.com/golang/appengine / TestVariadicFunctionArguments

Function TestVariadicFunctionArguments

v2/delay/delay_test.go:157–181  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestVariadicFunctionArguments(t *testing.T) {
158 // Check the argument type validation for variadic functions.
159 c := newFakeContext()
160
161 calls := 0
162 taskqueueAdder = func(c context.Context, t *taskqueue.Task, _ string) (*taskqueue.Task, error) {
163 calls++
164 return t, nil
165 }
166
167 for _, testTarget := range []*Function{varFunc, varRegister} {
168 // reset state
169 calls = 0
170 testTarget.Call(c.ctx, "hi")
171 testTarget.Call(c.ctx, "%d", 12)
172 testTarget.Call(c.ctx, "%d %d %d", 3, 1, 4)
173 if calls != 3 {
174 t.Errorf("Got %d calls to taskqueueAdder, want 3", calls)
175 }
176
177 if got, want := testTarget.Call(c.ctx, "%d %s", 12, "a string is bad"), errors.New("delay: argument 3 has wrong type: string is not assignable to int"); got.Error() != want.Error() {
178 t.Errorf("Incorrect error: got %q, want %q", got, want)
179 }
180 }
181}
182
183func TestBadArguments(t *testing.T) {
184 // Try running regFunc with different sets of inappropriate arguments.

Callers

nothing calls this directly

Calls 3

newFakeContextFunction · 0.70
CallMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…