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

Method TestFunctionCacheControl

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

Source from the content-addressed store, hash-verified

7406}
7407
7408func (ModuleSuite) TestFunctionCacheControl(ctx context.Context, t *testctx.T) {
7409 for _, tc := range []struct {
7410 sdk string
7411 source string
7412 }{
7413 {
7414 // TODO: add test that function doc strings still get parsed correctly, don't include //+ etc.
7415 sdk: "go",
7416 source: `package main
7417
7418import (
7419 "crypto/rand"
7420)
7421
7422type Test struct{}
7423
7424// My cool doc on TestTtl
7425// +cache="40s"
7426func (m *Test) TestTtl() string {
7427 return rand.Text()
7428}
7429
7430// My dope doc on TestCachePerSession
7431// +cache="session"
7432func (m *Test) TestCachePerSession() string {
7433 return rand.Text()
7434}
7435
7436// My darling doc on TestNeverCache
7437// +cache="never"
7438func (m *Test) TestNeverCache() string {
7439 return rand.Text()
7440}
7441
7442// My rad doc on TestAlwaysCache
7443func (m *Test) TestAlwaysCache() string {
7444 return rand.Text()
7445}
7446`,
7447 },
7448 {
7449 sdk: "python",
7450 source: `import dagger
7451import random
7452import string
7453
7454@dagger.object_type
7455class Test:
7456 @dagger.function(cache="40s")
7457 def test_ttl(self) -> str:
7458 return ''.join(random.choices(string.ascii_lowercase + string.digits, k=10))
7459
7460 @dagger.function(cache="session")
7461 def test_cache_per_session(self) -> str:
7462 return ''.join(random.choices(string.ascii_lowercase + string.digits, k=10))
7463
7464 @dagger.function(cache="never")
7465 def test_never_cache(self) -> str:

Callers

nothing calls this directly

Calls 15

modInitFunction · 0.85
daggerCallFunction · 0.85
goGitBaseFunction · 0.85
daggerExecFunction · 0.85
sdkSourceFunction · 0.85
hostDaggerCommandFunction · 0.85
MkdirAllMethod · 0.80
connectFunction · 0.70
RunMethod · 0.65
CloseMethod · 0.65
EqualMethod · 0.65
StdoutMethod · 0.45

Tested by

no test coverage detected