MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestNeedsCredentialRefresh

Function TestNeedsCredentialRefresh

server/server_test.go:172–218  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

170 {"httpfs", "httpfs", "httpfs"},
171 {"cache_httpfs FROM community", "cache_httpfs", "cache_httpfs FROM community"},
172 {"cache_httpfs from community", "cache_httpfs", "cache_httpfs from community"},
173 {"cache_httpfs FROM COMMUNITY", "cache_httpfs", "cache_httpfs FROM COMMUNITY"},
174 {"my_ext FROM my_repo", "my_ext", "my_ext FROM my_repo"},
175 {"ext FROM source", "ext", "ext FROM source"},
176 }
177
178 for _, tt := range tests {
179 t.Run(tt.input, func(t *testing.T) {
180 name, installCmd := parseExtensionName(tt.input)
181 if name != tt.wantName {
182 t.Errorf("parseExtensionName(%q) name = %q, want %q", tt.input, name, tt.wantName)
183 }
184 if installCmd != tt.wantInstall {
185 t.Errorf("parseExtensionName(%q) installCmd = %q, want %q", tt.input, installCmd, tt.wantInstall)
186 }
187 })
188 }
189}
190
191func TestNewFailsWhenBundledExtensionBootstrapFails(t *testing.T) {
192 bundledRoot := filepath.Join(t.TempDir(), "extensions-file")
193 if err := os.WriteFile(bundledRoot, []byte("not-a-directory"), 0o644); err != nil {
194 t.Fatalf("write bundled root file: %v", err)
195 }
196
197 prevBundledRoot := bundledDuckDBExtensionsDir
198 bundledDuckDBExtensionsDir = bundledRoot
199 defer func() { bundledDuckDBExtensionsDir = prevBundledRoot }()
200
201 bundledExtensionBootstrap = struct {
202 mu sync.Mutex
203 byPath map[string]error
204 }{}
205
206 certDir := t.TempDir()
207 certFile := filepath.Join(certDir, "server.crt")
208 keyFile := filepath.Join(certDir, "server.key")
209 if err := generateSelfSignedCert(certFile, keyFile); err != nil {
210 t.Fatalf("generateSelfSignedCert: %v", err)
211 }
212
213 _, err := New(Config{
214 Host: "127.0.0.1",
215 Port: 5432,
216 DataDir: t.TempDir(),
217 Users: map[string]string{"postgres": "postgres"},
218 TLSCertFile: certFile,
219 TLSKeyFile: keyFile,
220 })
221 if err == nil {

Callers

nothing calls this directly

Calls 2

needsCredentialRefreshFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected