MCPcopy Create free account
hub / github.com/dagger/dagger / TestOptionalDefaults

Method TestOptionalDefaults

core/integration/module_test.go:395–547  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

393}
394
395func (ModuleSuite) TestOptionalDefaults(ctx context.Context, t *testctx.T) {
396 // Test expressiveness for following schema:
397 // a: String!
398 // b: String
399 // c: String! = "foo"
400 // d: String = null
401 // e: String = "bar"
402
403 for _, tc := range []struct {
404 sdk string
405 source string
406 expected string
407 }{
408 {
409 sdk: "go",
410 source: `package main
411
412import "fmt"
413
414type Test struct{ }
415
416func (m *Test) Foo(
417 a string,
418 // +optional
419 b *string,
420 // +default="foo"
421 c string,
422 // +default=null
423 d *string,
424 // +default="bar"
425 e *string,
426) string {
427 return fmt.Sprintf("%+v, %+v, %+v, %+v, %+v", a, b, c, d, *e)
428}
429`,
430 expected: "test, <nil>, foo, <nil>, bar",
431 },
432 {
433 sdk: "python",
434 source: `from dagger import field, function, object_type
435
436@object_type
437class Test:
438 @function
439 def foo(
440 self,
441 a: str,
442 b: str | None,
443 c: str = "foo",
444 d: str | None = None,
445 e: str | None = "bar",
446 ) -> str:
447 return ", ".join(repr(x) for x in (a, b, c, d, e))
448`,
449 expected: "'test', None, 'foo', None, 'bar'",
450 },
451 {
452 sdk: "typescript",

Callers

nothing calls this directly

Calls 12

modInitFunction · 0.85
daggerQueryFunction · 0.85
daggerCallFunction · 0.85
connectFunction · 0.70
RunMethod · 0.65
GetMethod · 0.65
EqualMethod · 0.65
StringMethod · 0.65
ValueMethod · 0.65
DocMethod · 0.45
StdoutMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected