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

Method TestCodegenOptionals

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

Source from the content-addressed store, hash-verified

547}
548
549func (ModuleSuite) TestCodegenOptionals(ctx context.Context, t *testctx.T) {
550 // Same code as TestOptionalDefaults since it guarantees this is being
551 // registered correctly and equally by all SDKs.
552 src := `package main
553
554import "fmt"
555
556type Dep struct {}
557
558func (m *Dep) Ctl(
559 a string,
560 // +optional
561 b *string,
562 // +default="foo"
563 c string,
564 // +default=null
565 d *string,
566 // +default="bar"
567 e *string,
568) string {
569 return fmt.Sprintf("%+v, %+v, %+v, %+v, %+v", a, b, c, d, *e)
570}
571`
572 expected := "foo, <nil>, foo, <nil>, bar"
573
574 for _, tc := range []struct {
575 sdk string
576 source string
577 }{
578 {
579 sdk: "go",
580 source: `package main
581
582import "context"
583
584type Test struct {}
585
586func (m *Test) Test(ctx context.Context) (string, error) {
587 return dag.Dep().Ctl(ctx, "foo")
588}
589`,
590 },
591 {
592 sdk: "python",
593 source: `import dagger
594from dagger import dag
595
596
597@dagger.object_type
598class Test:
599 @dagger.function
600 async def test(self) -> str:
601 return await dag.dep().ctl("foo")
602`,
603 },
604 {
605 sdk: "typescript",
606 source: `import { dag, object, func } from "@dagger.io/dagger"

Callers

nothing calls this directly

Calls 9

modInitFunction · 0.85
withModInitAtFunction · 0.85
daggerExecFunction · 0.85
daggerCallFunction · 0.85
connectFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.65
StdoutMethod · 0.45
WithMethod · 0.45

Tested by

no test coverage detected