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

Method TestUnbundleSDK

core/integration/module_test.go:2329–2388  ·  view source on GitHub ↗

TestUnbundleSDK verifies that you can implement a SDK without having to implements the full interface but only the ones you want. cc: https://github.com/dagger/dagger/issues/7707

(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

2327// having to implements the full interface but only the ones you want.
2328// cc: https://github.com/dagger/dagger/issues/7707
2329func (ModuleSuite) TestUnbundleSDK(ctx context.Context, t *testctx.T) {
2330 t.Run("only codegen", func(ctx context.Context, t *testctx.T) {
2331 c := connect(ctx, t)
2332
2333 ctr := c.Container().From(golangImage).
2334 WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
2335 WithDirectory("/work/sdk", c.Host().Directory("./testdata/sdks/only-codegen")).
2336 WithWorkdir("/work").
2337 With(daggerExec("init", "--name=test", "--sdk=./sdk", "--source=."))
2338
2339 t.Run("can run dagger develop", func(ctx context.Context, t *testctx.T) {
2340 generatedFile, err := ctr.With(daggerExec("develop")).File("/work/hello.txt").Contents(ctx)
2341
2342 require.NoError(t, err)
2343 require.Equal(t, "Hello, world!", generatedFile)
2344 })
2345
2346 t.Run("explicit error on dagger call", func(ctx context.Context, t *testctx.T) {
2347 _, err := ctr.With(daggerExec("call", "foo")).Sync(ctx)
2348
2349 requireErrOut(t, err, `"./sdk" SDK does not support defining and executing functions`)
2350 })
2351
2352 t.Run("explicit error on dagger functions", func(ctx context.Context, t *testctx.T) {
2353 _, err := ctr.With(daggerFunctions()).Sync(ctx)
2354
2355 requireErrOut(t, err, `"./sdk" SDK does not support defining and executing functions`)
2356 })
2357 })
2358
2359 t.Run("only runtime", func(ctx context.Context, t *testctx.T) {
2360 c := connect(ctx, t)
2361
2362 ctr := c.Container().From(golangImage).
2363 WithMountedFile(testCLIBinPath, daggerCliFile(t, c)).
2364 WithDirectory("/work/sdk", c.Host().Directory("./testdata/sdks/only-runtime")).
2365 WithWorkdir("/work").
2366 With(daggerExec("init", "--name=test", "--sdk=./sdk", "--source=."))
2367
2368 t.Run("can run dagger develop without failing", func(ctx context.Context, t *testctx.T) {
2369 _, err := ctr.With(daggerExec("develop")).Sync(ctx)
2370
2371 require.NoError(t, err)
2372 })
2373
2374 t.Run("can run dagger functions", func(ctx context.Context, t *testctx.T) {
2375 out, err := ctr.With(daggerFunctions()).Stdout(ctx)
2376
2377 require.NoError(t, err)
2378 require.Contains(t, out, "hello-world")
2379 })
2380
2381 t.Run("can run dagger call", func(ctx context.Context, t *testctx.T) {
2382 out, err := ctr.With(daggerCall("hello-world")).Stdout(ctx)
2383
2384 require.NoError(t, err)
2385 require.Contains(t, out, "Hello world")
2386 })

Callers

nothing calls this directly

Calls 15

daggerCliFileFunction · 0.85
daggerExecFunction · 0.85
requireErrOutFunction · 0.85
daggerFunctionsFunction · 0.85
daggerCallFunction · 0.85
connectFunction · 0.70
RunMethod · 0.65
DirectoryMethod · 0.65
HostMethod · 0.65
FileMethod · 0.65
EqualMethod · 0.65
SyncMethod · 0.65

Tested by

no test coverage detected