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

Method TestJSONField

core/integration/module_go_test.go:1455–1483  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

1453}
1454
1455func (GoSuite) TestJSONField(ctx context.Context, t *testctx.T) {
1456 c := connect(ctx, t)
1457
1458 modGen := c.Container().From(golangImage).
1459 WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
1460 WithWorkdir("/work").
1461 With(daggerExec("init", "--source=.", "--name=minimal", "--sdk=go")).
1462 WithNewFile("main.go", `package main
1463
1464import (
1465 "dagger/minimal/internal/dagger"
1466)
1467
1468type Minimal struct {
1469 Config dagger.JSON
1470}
1471
1472func New() *Minimal {
1473 return &Minimal{
1474 Config: "{\"a\":1}",
1475 }
1476}
1477`,
1478 )
1479
1480 out, err := modGen.With(daggerQuery(`{config}`)).Stdout(ctx)
1481 require.NoError(t, err)
1482 require.JSONEq(t, `{"config":"{\"a\":1}"}`, out)
1483}
1484
1485// this is no longer allowed, but verify the Engine errors out
1486func (GoSuite) TestExtendCore(ctx context.Context, t *testctx.T) {

Callers

nothing calls this directly

Calls 11

daggerCliFileFunction · 0.85
daggerExecFunction · 0.85
daggerQueryFunction · 0.85
connectFunction · 0.70
WithNewFileMethod · 0.45
WithMethod · 0.45
WithWorkdirMethod · 0.45
WithMountedFileMethod · 0.45
FromMethod · 0.45
ContainerMethod · 0.45
StdoutMethod · 0.45

Tested by

no test coverage detected