MCPcopy
hub / github.com/basecamp/once / TestRestoreWithPostRestoreHook

Function TestRestoreWithPostRestoreHook

integration/docker_test.go:563–586  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

561}
562
563func TestRestoreWithPostRestoreHook(t *testing.T) {
564 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
565 defer cancel()
566
567 registryURL := startLocalRegistry(t, ctx)
568 hookImage := buildHookImage(t, ctx, registryURL, "restore-hook-success", "#!/bin/sh\ncp /storage/hook-input /storage/hook-output")
569
570 backup := buildTestBackup(t, hookImage)
571
572 ns, err := docker.NewNamespace("once-restore-hook-test")
573 require.NoError(t, err)
574 defer ns.Teardown(ctx, true)
575
576 require.NoError(t, ns.EnsureNetwork(ctx))
577 require.NoError(t, ns.Proxy().Boot(ctx, getProxyPorts(t)))
578
579 restoredApp, err := ns.Restore(ctx, bytes.NewReader(backup))
580 require.NoError(t, err)
581 assert.NotEmpty(t, restoredApp.Settings.Name)
582
583 containerName, err := restoredApp.ContainerName(ctx)
584 require.NoError(t, err)
585 execInContainer(t, ctx, containerName, []string{"test", "-f", "/storage/hook-output"})
586}
587
588func TestRestoreFailsWithFailedPostRestoreHook(t *testing.T) {
589 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)

Callers

nothing calls this directly

Calls 12

TeardownMethod · 0.95
EnsureNetworkMethod · 0.95
ProxyMethod · 0.95
RestoreMethod · 0.95
NewNamespaceFunction · 0.92
startLocalRegistryFunction · 0.85
buildHookImageFunction · 0.85
buildTestBackupFunction · 0.85
getProxyPortsFunction · 0.85
BootMethod · 0.80
ContainerNameMethod · 0.80
execInContainerFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…