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

Method TestGitMod

core/integration/module_call_test.go:2245–2364  ·  view source on GitHub ↗
(ctx context.Context, t *testctx.T)

Source from the content-addressed store, hash-verified

2243}
2244
2245func (CallSuite) TestGitMod(ctx context.Context, t *testctx.T) {
2246 testOnMultipleVCS(t, func(ctx context.Context, t *testctx.T, tc vcsTestCase) {
2247 t.Run("go", func(ctx context.Context, t *testctx.T) {
2248 c := connect(ctx, t)
2249 privateSetup, cleanup := privateRepoSetup(c, t, tc)
2250 defer cleanup()
2251
2252 out, err := goGitBase(t, c).
2253 With(privateSetup).
2254 With(daggerCallAt(testGitModuleRef(tc, "top-level"), "fn")).
2255 Stdout(ctx)
2256 require.NoError(t, err)
2257 require.Equal(t, "hi from top level hi from dep hi from dep2", strings.TrimSpace(out))
2258 })
2259
2260 t.Run("go dep", func(ctx context.Context, t *testctx.T) {
2261 c := connect(ctx, t)
2262 privateSetup, cleanup := privateRepoSetup(c, t, tc)
2263 defer cleanup()
2264
2265 out, err := goGitBase(t, c).
2266 With(privateSetup).
2267 With(daggerExec("init", "--source=.", "--name=foo", "--sdk=go")).
2268 With(daggerExec("install", testGitModuleRef(tc, "top-level"))).
2269 WithNewFile("main.go", `package main
2270import (
2271 "context"
2272)
2273
2274type Foo struct {}
2275
2276func (m *Foo) Fn(ctx context.Context) (string, error) {
2277 return dag.TopLevel().Fn(ctx)
2278}
2279`).
2280 With(daggerCall("fn")).
2281 Stdout(ctx)
2282 require.NoError(t, err)
2283 require.Equal(t, "hi from top level hi from dep hi from dep2", strings.TrimSpace(out))
2284 })
2285
2286 t.Run("typescript", func(ctx context.Context, t *testctx.T) {
2287 c := connect(ctx, t)
2288 privateSetup, cleanup := privateRepoSetup(c, t, tc)
2289 defer cleanup()
2290
2291 out, err := goGitBase(t, c).
2292 With(privateSetup).
2293 With(daggerCallAt(testGitModuleRef(tc, "ts"), "container-echo", "--string-arg", "yoyo", "stdout")).
2294 Stdout(ctx)
2295 require.NoError(t, err)
2296 require.Equal(t, "yoyo", strings.TrimSpace(out))
2297 })
2298
2299 t.Run("typescript dep", func(ctx context.Context, t *testctx.T) {
2300 c := connect(ctx, t)
2301 privateSetup, cleanup := privateRepoSetup(c, t, tc)
2302 defer cleanup()

Callers

nothing calls this directly

Calls 13

testOnMultipleVCSFunction · 0.85
privateRepoSetupFunction · 0.85
goGitBaseFunction · 0.85
daggerCallAtFunction · 0.85
testGitModuleRefFunction · 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