MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestConfig_MergeWithFile

Function TestConfig_MergeWithFile

internal/config/config_test.go:365–470  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

363}
364
365func TestConfig_MergeWithFile(t *testing.T) {
366 // Create a temporary directory for test files
367 tempDir := t.TempDir()
368
369 tests := []struct {
370 name string
371 initialConfig *Config
372 fileContent string
373 expectedConfig *Config
374 expectError bool
375 }{
376 {
377 name: "merge with valid YAML file",
378 initialConfig: &Config{
379 Addr: "https://initial.example.com:8006",
380 User: "initialuser",
381 },
382 fileContent: `
383addr: "https://merged.example.com:8006"
384password: "mergedpass"
385debug: true
386insecure: true
387`,
388 expectedConfig: &Config{
389 Addr: "https://merged.example.com:8006",
390 User: "initialuser", // Should keep initial value
391 Password: "mergedpass",
392 Debug: true,
393 Insecure: true,
394 },
395 expectError: false,
396 },
397 {
398 name: "merge with empty file path",
399 initialConfig: &Config{
400 Addr: "https://initial.example.com:8006",
401 User: "initialuser",
402 },
403 fileContent: "",
404 expectedConfig: &Config{
405 Addr: "https://initial.example.com:8006",
406 User: "initialuser",
407 },
408 expectError: false,
409 },
410 {
411 name: "merge with invalid YAML",
412 initialConfig: &Config{
413 Addr: "https://initial.example.com:8006",
414 },
415 fileContent: `
416invalid: yaml: content:
417 - malformed
418`,
419 expectError: true,
420 },
421 }
422

Callers

nothing calls this directly

Calls 5

RunMethod · 0.80
MergeWithFileMethod · 0.80
NameMethod · 0.65
CloseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected