MCPcopy Create free account
hub / github.com/amitsaha/gitbackup / TestHandleValidateConfig

Function TestHandleValidateConfig

config_file_test.go:94–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestHandleValidateConfig(t *testing.T) {
95 tmpDir := t.TempDir()
96 configPath := filepath.Join(tmpDir, defaultConfigFile)
97
98 // Validate should fail if no config file exists
99 err := handleValidateConfig(configPath)
100 if err == nil {
101 t.Fatal("Expected error when config file doesn't exist")
102 }
103
104 // Create a valid config and set the required env var
105 err = handleInitConfig(configPath)
106 if err != nil {
107 t.Fatalf("Expected no error creating config, got: %v", err)
108 }
109
110 os.Setenv("GITHUB_TOKEN", "testtoken")
111 defer os.Unsetenv("GITHUB_TOKEN")
112
113 err = handleValidateConfig(configPath)
114 if err != nil {
115 t.Fatalf("Expected valid config, got: %v", err)
116 }
117}
118
119func TestHandleValidateConfigInvalidService(t *testing.T) {
120 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 2

handleValidateConfigFunction · 0.85
handleInitConfigFunction · 0.85

Tested by

no test coverage detected