MCPcopy Index your code
hub / github.com/rilldata/rill / NewWithOptionalRuntime

Function NewWithOptionalRuntime

admin/testadmin/testadmin.go:80–226  ·  view source on GitHub ↗
(t *testing.T, startRt bool)

Source from the content-addressed store, hash-verified

78}
79
80func NewWithOptionalRuntime(t *testing.T, startRt bool) *Fixture {
81 ctx := t.Context()
82
83 // Postgres
84 pg := pgtestcontainer.New(t)
85 t.Cleanup(func() { pg.Terminate(t) })
86
87 // Logger
88 cfg := zap.NewProductionConfig()
89 cfg.Level.SetLevel(zap.ErrorLevel)
90 logger, err := cfg.Build()
91 require.NoError(t, err)
92
93 // Sender
94 sender := email.NewTestSender()
95 emailClient := email.New(sender)
96
97 // Application-managed column encryption keyring
98 keyring, err := database.NewRandomKeyring()
99 require.NoError(t, err)
100 keyringJSON, err := json.Marshal(keyring)
101 require.NoError(t, err)
102
103 // Ports and external URLs - find both ports (guaranteed to be different)
104 port, runtimePort := findTwoPorts(t)
105 externalURL := fmt.Sprintf("http://localhost:%d", port)
106 var runtimeExternalURL string
107 if startRt {
108 runtimeExternalURL = fmt.Sprintf("http://localhost:%d", runtimePort)
109 } else {
110 runtimeExternalURL = "http://example.org"
111 }
112 frontendURL := "http://frontend.mock"
113
114 // JWT issuer
115 issuer, err := runtimeauth.NewEphemeralIssuer(externalURL)
116 require.NoError(t, err)
117
118 // Runtime provisioner - if startRt is false, we set up a provisioner that points to a non-existent runtime server.
119 runtimeAudienceURL := runtimeExternalURL
120 defaultProvisioner := "static"
121 provisionerSetJSON := must(json.Marshal(map[string]any{
122 "static": map[string]any{
123 "type": "static",
124 "spec": map[string]any{
125 "runtimes": []map[string]any{
126 {
127 "host": runtimeExternalURL,
128 "slots": 1000000,
129 "audience_url": runtimeAudienceURL,
130 },
131 },
132 },
133 },
134 }))
135
136 // Initialize mock AI using drivers.Open pattern
137 mockAIHandle, err := drivers.Open("mock_ai", "", "test", map[string]any{}, storage.MustNew(os.TempDir(), nil), activity.NewNoopClient(), logger)

Callers 5

TestRuntimeDeploymentsFunction · 0.92
TestPrimaryBranchChangeFunction · 0.92
TestEmbedOpenFunction · 0.92
TestDeploymentJWTsFunction · 0.92
NewFunction · 0.85

Calls 15

NewFunction · 0.92
NewTestSenderFunction · 0.92
NewFunction · 0.92
NewRandomKeyringFunction · 0.92
OpenFunction · 0.92
MustNewFunction · 0.92
NewNoopClientFunction · 0.92
NewFunction · 0.92
NewNoopFunction · 0.92
NewNoopFunction · 0.92
SplitGithubRemoteFunction · 0.92
NewNoopFunction · 0.92

Tested by 4

TestRuntimeDeploymentsFunction · 0.74
TestPrimaryBranchChangeFunction · 0.74
TestEmbedOpenFunction · 0.74
TestDeploymentJWTsFunction · 0.74