MCPcopy Index your code
hub / github.com/dagger/dagger / TestIsSameModuleReference

Function TestIsSameModuleReference

engine/server/session_test.go:337–371  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

335}
336
337func TestIsSameModuleReference(t *testing.T) {
338 t.Parallel()
339
340 local := func(contextPath, rootSubpath, sourceSubpath string) *core.ModuleSource {
341 return &core.ModuleSource{
342 Kind: core.ModuleSourceKindLocal,
343 Local: &core.LocalModuleSource{ContextDirectoryPath: contextPath},
344 SourceRootSubpath: rootSubpath,
345 SourceSubpath: sourceSubpath,
346 }
347 }
348
349 t.Run("same local source root and pin", func(t *testing.T) {
350 t.Parallel()
351 a := local("/work/mod", ".", ".")
352 b := local("/work/mod", ".", ".")
353 require.True(t, isSameModuleReference(a, b))
354 })
355
356 t.Run("different local source", func(t *testing.T) {
357 t.Parallel()
358 a := local("/work/mod-a", ".", ".")
359 b := local("/work/mod-b", ".", ".")
360 require.False(t, isSameModuleReference(a, b))
361 })
362
363 t.Run("same module through different local refs", func(t *testing.T) {
364 t.Parallel()
365 // a points at the workspace root where dagger.json has sourceSubpath
366 // ".dagger/modules/dagger-dev". b points directly at that module dir.
367 a := local("/root/src/dagger", ".", ".dagger/modules/dagger-dev")
368 b := local("/root/src/dagger/.dagger/modules/dagger-dev", ".", ".")
369 require.True(t, isSameModuleReference(a, b))
370 })
371}
372
373func TestEnsureWorkspaceLoadedInheritsParentWorkspace(t *testing.T) {
374 t.Parallel()

Callers

nothing calls this directly

Calls 2

isSameModuleReferenceFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected