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

Function TestDeployWithSettings

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

Source from the content-addressed store, hash-verified

693}
694
695func TestDeployWithSettings(t *testing.T) {
696 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
697 defer cancel()
698
699 ns, err := docker.NewNamespace("once-settings-test")
700 require.NoError(t, err)
701 defer ns.Teardown(ctx, true)
702
703 require.NoError(t, ns.EnsureNetwork(ctx))
704 require.NoError(t, ns.Proxy().Boot(ctx, getProxyPorts(t)))
705
706 settings := docker.ApplicationSettings{
707 Name: "settingsapp",
708 Image: "ghcr.io/basecamp/once-campfire:main",
709 Host: "settingsapp.localhost",
710 DisableTLS: true,
711 EnvVars: map[string]string{"CUSTOM_VAR": "custom_value", "ANOTHER": "thing"},
712 SMTP: docker.SMTPSettings{
713 Server: "smtp.example.com",
714 Port: "587",
715 Username: "user",
716 Password: "pass",
717 From: "noreply@example.com",
718 },
719 Resources: docker.ContainerResources{CPUs: 1, MemoryMB: 512},
720 AutoUpdate: false,
721 Backup: docker.BackupSettings{Path: "/backups", AutoBackup: true},
722 }
723
724 app := deployApp(t, ctx, ns, settings)
725
726 // Verify settings persisted via label restore
727 ns2, err := docker.RestoreNamespace(ctx, "once-settings-test")
728 require.NoError(t, err)
729
730 restored := ns2.Application("settingsapp")
731 require.NotNil(t, restored)
732 assert.True(t, restored.Settings.DisableTLS)
733 assert.Equal(t, "custom_value", restored.Settings.EnvVars["CUSTOM_VAR"])
734 assert.Equal(t, "thing", restored.Settings.EnvVars["ANOTHER"])
735 assert.Equal(t, "smtp.example.com", restored.Settings.SMTP.Server)
736 assert.Equal(t, "587", restored.Settings.SMTP.Port)
737 assert.False(t, restored.Settings.AutoUpdate)
738 assert.Equal(t, "/backups", restored.Settings.Backup.Path)
739 assert.True(t, restored.Settings.Backup.AutoBackup)
740
741 // Verify container env vars
742 containerName, err := app.ContainerName(ctx)
743 require.NoError(t, err)
744 envVars := inspectContainerEnv(t, ctx, containerName)
745 assert.Contains(t, envVars, "CUSTOM_VAR=custom_value")
746 assert.Contains(t, envVars, "ANOTHER=thing")
747 assert.Contains(t, envVars, "SMTP_ADDRESS=smtp.example.com")
748
749 // Verify container resources
750 assertContainerResources(t, ctx, containerName, 1e9, 512*1024*1024)
751}
752

Callers

nothing calls this directly

Calls 13

TeardownMethod · 0.95
EnsureNetworkMethod · 0.95
ProxyMethod · 0.95
NewNamespaceFunction · 0.92
RestoreNamespaceFunction · 0.92
getProxyPortsFunction · 0.85
deployAppFunction · 0.85
inspectContainerEnvFunction · 0.85
assertContainerResourcesFunction · 0.85
BootMethod · 0.80
ApplicationMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…